Changing widget's style
Widget's style can be accessed via 'style' property. However, that property is not writeable directly, so the style needs to be changed via set_style() method of GtkWidget.

Most of GtkStyle fields are settable directly, but with GC's special care has to be taken due to current deficiencies in the Zend engine. Which GtkStyle properties are used for drawing depends totally on the widget. GtkButton for example, draws its background using 'bg' color, but GtkLabel draws its string using 'fg_gc' context.

 1: <?php
 2
:   $win = &new GtkWindow();
 
3:   $win->set_border_width(5);
 
4:   $win->set_usize(100100);
 
5
 
6:   $button = &new GtkButton('Press me');
 
7:   $button->connect('clicked''press_me');
 
8:   $win->add($button);
 
9
10:   $win->show_all();
11:   
12:   gtk::main();
13
14:   function press_me($button)
15:   {
16:       $style $button->style;
17:       $style $style->copy();
18:       $cmap $button->get_colormap(); 
19:       $color $cmap->alloc('#406090');
20:       $style->bg[GTK_STATE_PRELIGHT] = $color;
21:       $button->set_style($style);
22
23:       $label $button->child;
24:       $style $label->style;
25:       $style $style->copy();
26:       $style->font gdk::font_load('-*-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*');
27:       $label->set_style($style);
28:   }
29?>
In this example we change the style of the button and its label. Note that we copy the style first before changing its properties. Its usually a good idea to do so, however, copying a style nulls out the GC properties. In that case you can try rebuilding the GCs by hand.