diff options
author | C. Scott Ananian <cscott@laptop.org> | 2008-10-06 17:53:02 (GMT) |
---|---|---|
committer | C. Scott Ananian <cscott@laptop.org> | 2008-10-06 20:18:21 (GMT) |
commit | 45b547d7d01f3867eed34eb4f1b01a1a1950235c (patch) | |
tree | d589e0d596791273f23bb56d953003541e0cb433 | |
parent | a0c2037277d70a29c5014b7845052e9cf0a8e345 (diff) |
Trac #8778: allow prelighting of buttons.
Buttons don't want to be prelit by default. This required a hack in the
sugar theme engine, because just setting
bg[GTK_STATE_NORMAL] == bg[GTK_STATE_PRELIGHT]
caused odd behavior for toggle buttons in the GTK_STATE_ACTIVE state: if
normal color was black, and active color was white, then the toggle buttons
would still prelight 'black' when they were active. Unfortunately, GTK does
not distinguish a GTK_STATE_PRELIGHT_ACTIVE state.
This patch narrows our hack by restricting it to the case where
GTK_STATE_NORMAL == GTK_STATE_PRELIGHT. This allows UI designers to use
prelighting in cases where it is warranted by setting a PRELIGHT color,
while retaining our existing behavior in the default case (where the
normal and prelight colors are identical).
-rw-r--r-- | gtk/engine/sugar-info.c | 4 | ||||
-rw-r--r-- | gtk/engine/sugar-style.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/gtk/engine/sugar-info.c b/gtk/engine/sugar-info.c index 954a930..b4313a7 100644 --- a/gtk/engine/sugar-info.c +++ b/gtk/engine/sugar-info.c @@ -234,7 +234,9 @@ sugar_fill_generic_info (SugarInfo *info, } /* Ignore the prelight state in some cases. */ - if (info->state == GTK_STATE_PRELIGHT) { + if (info->state == GTK_STATE_PRELIGHT && + gdk_color_equal(&style->bg[GTK_STATE_PRELIGHT], + &style->bg[GTK_STATE_NORMAL])) { if (DETAIL ("button") || DETAIL ("buttondefault") || DETAIL ("spinbutton_down") || DETAIL ("spinbutton_up")) { diff --git a/gtk/engine/sugar-style.c b/gtk/engine/sugar-style.c index e048fc1..00bfb5e 100644 --- a/gtk/engine/sugar-style.c +++ b/gtk/engine/sugar-style.c @@ -788,7 +788,9 @@ sugar_style_draw_layout(GtkStyle *style, else /* It appears, that this is not a label inside a button. */ btn = NULL; } - if (state_type != GTK_STATE_INSENSITIVE && btn) { + if (state_type != GTK_STATE_INSENSITIVE && btn && + gdk_color_equal(&btn->style->bg[GTK_STATE_PRELIGHT], + &btn->style->bg[GTK_STATE_NORMAL])) { /* Access private information ... */ sugar_state = GTK_BUTTON (btn)->depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; } |