Re: GTK+ 2.8.17 and background colours



On Fri, 2006-04-21 at 20:36 +0200, Francesco Montorsi wrote:

Hi,
      I'm struggling with my GTK+ (2.8.17 - coming with ubuntu dapper) to
be able to set the background colour of a button.

I've googled and searched the archives of this mailing list and I have
found exactly same questions with attached test programs.

I'm attaching two short, simple test programs which *should* be able to
set the background colour of a button to a different colour from the
standard one.

Unfortunately running them I don't see any difference with a standard
GtkButton: i.e. the calls to gtk_widget_modify_bg and
gtk_widget_modify_fg seems not to have any effect !

Could anyone more expert try to compile those files and run them to see
if they get standard colours or not ?
(to compile them I usually place them in the gtk\examples\helloworld
folder and rename them to helloworld.c ;))

This seems like a GTK+ bug to me...

Thanks a lot,
Francesco

The biggest tip I can share is "If the desired widget does not have a GtkWindow of its own, it draws on its 
parent's window!".  Now the parent window may not be the one you expect or think you've coded.  Use this 
sequence to change of the color of a widget without its own GtkWindow.

  GdkColor color;
...
  gdk_color_parse ("blue", &color);
...
 button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
..
 gtk_widget_modify_bg ( gtk_widget_get_parent(button), GTK_STATE_NORMAL,
&color);



gtk_widget_get_parent() is the magic api to permit changing colors of
widgets reliably. 

James,

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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