Revision [32917]

This is an old revision of gtkdialogDocTips9.1 made by zigbert on 2020-07-31 02:40:44.

 

HomePage > SoftwareIndex Software Index > SoftwareDevelopment Development > gtkdialog gtkdialog > gtkdialogDocTips Tips and Tricks

9. Tips and Tricks



1.
How to change the gui without restarting the app
Recent Gtkdialog allows to hide/show widgets, To hide many widgets at once, you can hide a <hbox> or <vbox>. This will hide all widgets inside the box.

Another approach is to use the notebook attributes <notebook show-tabs="false" show-border="false">. Using several tabs in a notebook with hidden header, we can simulate a gui re-render. The only thing that is happening is that we switch tab, but since the user can't see those, he will be fooled...
More info at http://www.murga-linux.com/puppy/viewtopic.php?p=553833#553833.


2.
Control the icon/label of menuitems
If you have met problems to show a certain icon and at the same time give it an unique label, this will illustrate how it is recommended to be implemented for the benefit of anyone and everyone.

<menuitem stock="gtk-undo" label="'$LOC118'" accel-key="0x07a" accel-mods="4">
  <action>. '$APPDIR'/func -undo</action>
  <action>refresh:PLAYLIST</action>
</menuitem>'

Doing it this way makes GTK+ deal with the left-to-right and right-to-left internationalisation of the icons if applicable. You might think this won't work because GTK+ will make a stock label "Undo", and it will. But, straight afterwards it will update the label with $LOC118. Because it initially was a stock label, use-underline is automatically set to true, and you can use underscores in your custom text.


3.
Understand the alignment
Gtkdialog tends to align objects to the right side of the window. Exceptions are radiobuttons and checkboxes which are aligned to the left. It is easy to center whatever object in your gui. Here's some alignment explanation:

Using vertical rows can be troublesome, because often, the label defines the width of the objects. This leads to different width and it all looks crappy. You can override this by the attribute <vbox width-request="x">...</vbox>, where x represent the number of pixels for the width of the row. There is also a height-request attribute.


4.
Insert empty gap

Static:
<text width-chars="40" height-request="120"><label>" "</label></text>

Dynamic:
(align one button to the left, another to the right)
<hbox space-expand="false" space-fill="false">
 <button yes></button>
 <hbox space-expand="true" space-fill="true"><text><label>" "</label></text></hbox>
 <button no></button>
</hbox>



5.
Window header icon
You can add your own icon (symlinks also work) if you place it in a gtk-theme directory structure as /usr/share/icons/hicolor/. ie. /usr/share/icons/hicolor/48x48/apps/games48.png
Now, run this command in the terminal to refresh the icon cache;
gtk-update-icon-cache -f -i /usr/share/icons/hicolor
Your gtkdialog code would look like this;
<window title="A GTKDialog" icon-name="games48" resizable="false" decorated="true">
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki