HomePage > Software Index > Development > gtkdialog > Tips and Tricks

9.10 Define unique gtk-theme


Sometimes it is nice to change the gtktheme just for my app. Like this I get more options for my gtkdialog script.


Mono font
Gtkdialog does not support monospace in the <edit> widget, but I can make it work by adding a unique gtk-theme only for my app. The best way to this is to add my new gtk-theme on top of the already existing. Now my gtk-theme can hold ONLY information about monospace, else it will use gtk-settings specified by user.

By giving the text-widget a name (see example), it is possible to have a gtk-theme for only this unique text string. This also works for text in widgets like <entry>.

echo 'style "specialmono"
{
  font_name="Mono 12"
}
widget "*mono" style "specialmono"
class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono

export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0

export test_app="
<vbox>
  <text name=\"mono\"><label>This text-widget uses monospace font....</label></text>
  <text><label>...while this text-widget don't.</label></text>
  <edit><default>All edit-widgets gets monospace.</default></edit>
</vbox>"
gtkdialog --program=test_app



Color all backgrounds
How to control background color of different widgets.
Forum Q/A:

echo 'style "specialbg"
{
  bg[NORMAL]="#FF0"
  base[NORMAL]="#FF0"
}
widget "*bg" style "specialbg"
class "GtkNotebook" style "specialbg"
class "GtkViewport" style "specialbg"' > /tmp/gtkrc_bg

export GTK2_RC_FILES=/tmp/gtkrc_bg:/root/.gtkrc-2.0

echo $'
<vbox width-request="280">
  <notebook>
	<edit name="bg"><default>This edit widget has a yellow background</default></edit>
	<vbox name="bg"><text label="This vbox contains a text widget\nand backround of the whole box\nneeds to be made same\nas edit widget in Page1. How? Like so"></text></vbox>
	<vbox name="bg" scrollable="true"><text label="This scrollable vbox contains a text widget and backround of the whole box\nneeds to be made same as edit widget in Page1. How? Aha!"></text></vbox>
  </notebook>
  <button></button>
</vbox>' | gtkdialog -s



Categories
CategoryGtkdialog
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki