Re: gtk widget subclasses and theme/style inheritance



On Wed, 7 Jul 2004, Owen Taylor wrote:

On Wed, 2004-07-07 at 17:20, Brian J. Tarricone wrote:
hello-

forgive me if this has been discussed elsewhere, but i've been unable to 
find anything relevant via google, and the mailing list search feature 
appears to be broken.

i've written a subclass of GtkImageMenuItem, called XfceAppMenuItem.  
visually, it's the same as GtkImageMenuItem (or at least it's supposed 
to be).  however, it doesn't seem to be inheriting its theme properly.  
if i have a menu with mixed items (some GtkImageMenuItem, some 
XfceAppMenuItem), and i select the "Default" gtk2 theme, the 
GtkImageMenuItem instances have a white text color when the item is 
highlighted, but XfceAppMenuItem keeps its black text when highlighted.  
i've heard reports that something similar happens with some other (but 
not all) themes as well.

i've tried using gtk_widget_set_name(mi, "GtkMenuItem"), but that didn't 
work.  i've used gdb to examine the GtkStyle struct returned by 
gtk_widget_get_style() for both a regular GtkMenuItem and an 
XfceAppMenuItem, and the color listings are identical (for all 5 
GTK_STATE_* types).

i'm getting rather frustrated, and i'm hoping someone might be able to 
shed some light on this.

You can replace gtk_rc_get_style() with gtk_rc_get_style_by_paths()
to pretend to be a different type of widget.

ah, i see.  i had tried something like that previously, but with no 
luck, but it just dawned on me to try using that on the GtkLabel itself 
rather than just on the XfceAppMenuItem, which seems to do the trick.

thank you,
brian




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