From 45b547d7d01f3867eed34eb4f1b01a1a1950235c Mon Sep 17 00:00:00 2001 From: C. Scott Ananian Date: Mon, 06 Oct 2008 17:53:02 +0000 Subject: 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). --- 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; } -- cgit v0.9.1