tags:

views:

58

answers:

1

In my application I'm trying to use GTK rc file to style the widgets:

style "boxstyle1"
{
    bg[ACTIVE] = { 0.0, 1.0, 0.0 }
    bg[NORMAL] = { 1.0, 0.0, 0.0 }
    bg[PRELIGHT] = { 0.0, 0.0, 1.0 }
}
widget "*.eventbox1" style "boxstyle1"

while the normal color is taken but the other states not. anyone experienced with this problem?


EDIT:
When debug after widget initialized, widget->style gets all the values stored correctly.

I register state-changed event which never fires when 'state' changed. And in enter, leave, push, release events, I checked widget->state is always 0. Continue checking...

Same thing if I put for example a image in the eventbox, image->state never updated also...

I'm using GTK 2.16, use GtkBuilder to load xml


so does gtk_widget_modify_bg(widget, GTK_STATE_ACTIVE, color) won't change for states besides 0 (NORMAL)

A: 

GtkEvent does not have any state: it is only a container without anything drawn by default (hence without anything that can be activated or prelighted).

If you are expecting to customize the children widgets of your event box, you should use proper glob syntax in the rc file:

widget "*.eventbox1.*" style "boxstyle1"

The newly appended .* matches all the children of eventbox1.

fetasail
did test that:add a image inside eventbox and registered following signals:enter, leave, press, release callbacks are entered no problem, but within callback when I checked widget->state, it always is 0. seems doesn't matter the resource file now...
madcat
Add a GtkButton instead: a GtkImage is a passive widget that usually does react to state changes (that is, when you are not using an icon set).http://library.gnome.org/devel/gtk/stable/GtkImage.html#gtk-image-new-from-pixbuf
fetasail
thanks!GtkButton in eventbox does change states nowbut the button is not accepting even the NORMAL bg color set in RC file.
madcat
Did you append `.*` to the widget selector? Also, GTK+ theme engines are free to draw the widgets as they wish, also ignoring the color hints you provided, so ensure you do not have any engine active when testing. To be sure, you can modify temporarely the selector to `widget "*" style "boxstyle1"` to be sure the color changes (on my system, bg[NORMAL] works as expected).
fetasail
used widget "*" style "boxstyle1"bg[NORMAL] does work on window and certain widgets. but not on button.any other states never worked in my case.
madcat
Disable your GTK+ theme engine! If you are using a pixmap based one, there is very little you can do. Here is working...
fetasail
thanks! calling gtk_rc_set_default_files() will use only my styles now..
madcat