cgtkgtk2

GTK Modifying Background Color of GtkButton


Trying to change background/foreground color....Using Gtk+ and C.

  GdkColor color;
  gdk_color_parse( "#0080FF", &color );
  gtk_widget_modify_fg( GTK_WIDGET(button), GTK_STATE_SELECTED, &color );
  gtk_widget_modify_fg( GTK_WIDGET(button), GTK_STATE_NORMAL, &color );

I am using above functionality but it is not giving any results.

I am looking for something asked in this question(But in C):
GTK: create a colored regular button

how to Change Style of Button using button Style? Can anybody provide some examples?


Solution

  • Picture of Red GtkButton http://www.ubuntu-pics.de/bild/30465/screenshot_001_1Jt60q.png

    GdkColor color;
    
    gdk_color_parse ("red", &color);
    
    gtk_widget_modify_bg ( GTK_WIDGET(button), GTK_STATE_NORMAL, &color);
    

    Notice that we are modifying bg instead of fg.