Can gtk resource file change the attributes of a group of widget inone call?



I want to know whether the rc of gtk can change the
attributes of a group of widgets. So I build the
following resource file: test.rc
 
style "pink_button"  {
 bg[NORMAL]={1.0,0.7,0.7}
}
style "blue_button"  {
 bg[NORMAL]={0.7,0.7,1.0}
}
style "green_button"  {
 bg[NORMAL]={0.7,1.0,0.7}
}
 
widget "pinkmain.*GtkButton*" style "pink_button"
widget "bluemain.*GtkButton*" style "blue_button"
widget "greenmain.*GtkButton*" style "green_button"
And then, the corresponding c program testrc.c:
 
#include <gtk/gtk.h>
 
GtkWidget *pink_button,*blue_button,*green_button;
 
void set_to_pink(GtkObject *pgo)  {
 gtk_widget_set_name(GTK_WIDGET(pgo),"pinkmain");
}
void set_to_blue(GtkObject *pgo)  {
 gtk_widget_set_name(GTK_WIDGET(pgo),"bluemain");
}
void set_to_green(GtkObject *pgo)  {
 gtk_widget_set_name(GTK_WIDGET(pgo),"greenmain");
}
 
int main( int   argc,
          char *argv[] )
{
  /* GtkWidget is the storage type for widgets */
  GtkWidget *window;
  GtkWidget *box;
 
  /* Initialize the toolkit */
  gtk_init (&argc, &argv);
 
  gtk_rc_parse("test.rc");
 
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
  gtk_window_set_title (GTK_WINDOW (window), "RC Buttons");
 
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
                      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
 
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 
  box = gtk_hbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (box), 2);
  gtk_container_add (GTK_CONTAINER (window), box);
 
  gtk_widget_show(box);
 
  pink_button = gtk_button_new_with_label("Pink");
  gtk_signal_connect_object(GTK_OBJECT(pink_button),"clicked",
    GTK_SIGNAL_FUNC(set_to_pink),GTK_OBJECT(window));
  gtk_box_pack_start (GTK_BOX (box), pink_button, FALSE, FALSE, 3);
  gtk_widget_show(pink_button);
 
  blue_button = gtk_button_new_with_label("Blue");
  gtk_signal_connect_object(GTK_OBJECT(blue_button),"clicked",
    GTK_SIGNAL_FUNC(set_to_blue),GTK_OBJECT(window));
  gtk_box_pack_start(GTK_BOX (box), blue_button, FALSE, FALSE, 3);
  gtk_widget_show(blue_button);
 
  green_button = gtk_button_new_with_label("Green");
  gtk_signal_connect_object(GTK_OBJECT(green_button),"clicked",
    GTK_SIGNAL_FUNC(set_to_green),GTK_OBJECT(window));
  gtk_box_pack_start(GTK_BOX (box), green_button, FALSE, FALSE, 3);
  gtk_widget_show(green_button);
 
  gtk_widget_show (window);
 
  gtk_main ();
 
  return(0);
}
After I compile it by 'gcc -Wall -o testrc testrc.c `gtk-config
--cflags --libs`'. The color of the three button don't change
there background color with my click.
 
What the mechanism of the gtk resource file? Is it can change
a group of widgets in one call?
 
Thank You My Friends.
 
Li. Wang.
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]