To: maxence.guesdon at inria.fr Cc: lablgtk at kaba.or.jp Subject: Re: set_bg seems to no work In-Reply-To: <3BEC2EA2.6010001 at inria.fr> References: <3BEC2EA2.6010001 at inria.fr> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20011113083513E.garrigue at kurims.kyoto-u.ac.jp> Date: Tue, 13 Nov 2001 08:35:13 +0900 From: Jacques Garrigue Lines: 34 From: Maxence Guesdon > I'm trying to change bg color for labels of tree items. > I create the tree item this way : > then i try to change font and color : > The font is changed but not the bg color :-( This should be a FAQ: set_bg only works for widgets with an X window, that is widgets which an event sub-object. The simple workaround is to wrap yur label into an event_box, and use set_bg on the event_box let item = GTree.tree_item () in let ali = GBin.alignment ~x:0. ~xscale:0. ~packing:item#add () in let ev = GBin.event_box ~packing:ali#add () in let label = GMisc.label ~packing:ev#add ~text: "hi" () in ... ev#misc#set_bg ... Remark however that this is often seen as bad style to change colors in GTK, as this may not work well with various themes. Balance this with your UI needs. > By the way, i'd like to add the methods for changing foreground color > but i don't know where, for example, "ml_gtk_style_set_bg" is defined. This is because I heavily use CPP to dramatically reduce the size of the C wrappers. Actually this function is a "setter" whose name is automatically built: $ grep -n "gtk_style.*bg *.c ml_gtk.c:99:Make_Array_Extractor (gtk_style_get, GtkStyle_val, State_type_val, bg, Val_copy) ml_gtk.c:100:Make_Array_Setter (gtk_style_set, GtkStyle_val, State_type_val, *GdkColor_val, bg) Jacques