[gnome-panel/wip/3.0-freeze-break: 22/32] panel: Move highlight_launchers_on_mouseover setting from gconf to theme



commit 35db35e0de6caf97424c480e544845d81c1adb49
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Mar 23 19:15:52 2011 +0100

    panel: Move highlight_launchers_on_mouseover setting from gconf to theme
    
    I don't think people want to change this as a setting. However, for
    themes, it might make sense.
    
    It can be changed with "-ButtonWidget-hover-highlight: false;" set for
    ButtonWidget. By default, it's set to true, and ButtonWidgets are
    highlighted on hover.

 data/org.gnome.gnome-panel.gschema.xml |    5 -----
 gnome-panel/button-widget.c            |   24 +++++++++++++++++++++---
 gnome-panel/panel-config-global.c      |   13 -------------
 gnome-panel/panel-config-global.h      |    1 -
 gnome-panel/panel-global.schemas.in    |    6 ++----
 5 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/data/org.gnome.gnome-panel.gschema.xml b/data/org.gnome.gnome-panel.gschema.xml
index 5315df0..b3df2b0 100644
--- a/data/org.gnome.gnome-panel.gschema.xml
+++ b/data/org.gnome.gnome-panel.gschema.xml
@@ -18,11 +18,6 @@
       <summary>Confirm panel removal</summary>
       <description>If true, a dialog is shown asking for confirmation if the user wants to remove a panel.</description>
     </key>
-    <key name="highlight-launchers-on-mouseover" type="b">
-      <default>true</default>
-      <summary>Highlight launchers on mouseover</summary>
-      <description>If true, a launcher is highlighted when the user moves the pointer over it.</description>
-    </key>
   </schema>
 
   <schema id="org.gnome.gnome-panel.layout" path="/org/gnome/gnome-panel/layout/">
diff --git a/gnome-panel/button-widget.c b/gnome-panel/button-widget.c
index 911646d..87de33a 100644
--- a/gnome-panel/button-widget.c
+++ b/gnome-panel/button-widget.c
@@ -332,6 +332,7 @@ button_widget_draw (GtkWidget *widget,
 	ButtonWidget *button_widget = BUTTON_WIDGET (widget);
 	GtkStyleContext *context;
 	GtkStateFlags state_flags;
+	gboolean hover_highlight;
 	int off;
         int width, height;
         int x, y, w, h;
@@ -345,6 +346,8 @@ button_widget_draw (GtkWidget *widget,
 
 	/* offset for pressed buttons */
 	state_flags = gtk_widget_get_state_flags (widget);
+	gtk_widget_style_get (widget, "hover-highlight", &hover_highlight, NULL);
+
 	off = (button_widget->priv->activatable && (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
 	       (state_flags & GTK_STATE_FLAG_ACTIVE)) ?
 		BUTTON_WIDGET_DISPLACEMENT * height / 48.0 : 0;
@@ -356,7 +359,7 @@ button_widget_draw (GtkWidget *widget,
 						  pb,
 						  0.8,
 						  TRUE);
-	} else if (panel_global_config_get_highlight_when_over () && 
+	} else if (hover_highlight &&
 		   (state_flags & GTK_STATE_FLAG_PRELIGHT || gtk_widget_has_focus (widget)))
 		pb = g_object_ref (button_widget->priv->pixbuf_hc);
 	else
@@ -533,6 +536,7 @@ button_widget_enter_notify (GtkWidget *widget, GdkEventCrossing *event)
 {
 	GtkStateFlags state_flags;
 	gboolean in_button;
+	gboolean hover_highlight;
 
 	g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
 
@@ -542,8 +546,10 @@ button_widget_enter_notify (GtkWidget *widget, GdkEventCrossing *event)
 	GTK_WIDGET_CLASS (button_widget_parent_class)->enter_notify_event (widget, event);
 
 	state_flags = gtk_widget_get_state_flags (widget);
+	gtk_widget_style_get (widget, "hover-highlight", &hover_highlight, NULL);
+
 	if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
-	    panel_global_config_get_highlight_when_over ())
+	    hover_highlight)
 		gtk_widget_queue_draw (widget);
 
 	return FALSE;
@@ -554,6 +560,7 @@ button_widget_leave_notify (GtkWidget *widget, GdkEventCrossing *event)
 {
 	GtkStateFlags state_flags;
 	gboolean in_button;
+	gboolean hover_highlight;
 
 	g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
 
@@ -563,8 +570,10 @@ button_widget_leave_notify (GtkWidget *widget, GdkEventCrossing *event)
 	GTK_WIDGET_CLASS (button_widget_parent_class)->leave_notify_event (widget, event);
 
 	state_flags = gtk_widget_get_state_flags (widget);
+	gtk_widget_style_get (widget, "hover-highlight", &hover_highlight, NULL);
+
 	if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) &&
-	    panel_global_config_get_highlight_when_over ())
+	    hover_highlight)
 		gtk_widget_queue_draw (widget);
 
 	return FALSE;
@@ -670,6 +679,15 @@ button_widget_class_init (ButtonWidgetClass *klass)
 					     "The desired icon for the ButtonWidget",
 					     NULL,
 					     G_PARAM_READWRITE));
+
+	gtk_widget_class_install_style_property (
+			widget_class,
+			g_param_spec_boolean ("hover-highlight",
+					      "Highlight on hover",
+					      "Whether to highlight the button on mouse over",
+					      TRUE,
+					      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
 }
 
 GtkWidget *
diff --git a/gnome-panel/panel-config-global.c b/gnome-panel/panel-config-global.c
index 68b1416..8bce1f8 100644
--- a/gnome-panel/panel-config-global.c
+++ b/gnome-panel/panel-config-global.c
@@ -35,21 +35,12 @@
 
 typedef struct {
 	guint               tooltips_enabled : 1;
-	guint               highlight_when_over : 1;
 } GlobalConfig;
 
 static GlobalConfig global_config = { 0, };
 static gboolean global_config_initialised = FALSE;
 
 gboolean
-panel_global_config_get_highlight_when_over (void)
-{
-	g_assert (global_config_initialised == TRUE);
-
-	return global_config.highlight_when_over;
-}
-
-gboolean
 panel_global_config_get_tooltips_enabled (void)
 {
 	g_assert (global_config_initialised == TRUE);
@@ -74,10 +65,6 @@ panel_global_config_set_entry (GConfEntry *entry)
 	if (strcmp (key, "tooltips_enabled") == 0)
 		global_config.tooltips_enabled =
 				gconf_value_get_bool (value);
-
-	else if (strcmp (key, "highlight_launchers_on_mouseover") == 0)
-		global_config.highlight_when_over =
-			gconf_value_get_bool (value);
 }
 
 static void
diff --git a/gnome-panel/panel-config-global.h b/gnome-panel/panel-config-global.h
index fd72ebc..e20dc49 100644
--- a/gnome-panel/panel-config-global.h
+++ b/gnome-panel/panel-config-global.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
 
 void panel_global_config_load (void);
 
-gboolean panel_global_config_get_highlight_when_over  (void);
 gboolean panel_global_config_get_tooltips_enabled     (void);
 
 G_END_DECLS
diff --git a/gnome-panel/panel-global.schemas.in b/gnome-panel/panel-global.schemas.in
index cc6a18e..3691d33 100644
--- a/gnome-panel/panel-global.schemas.in
+++ b/gnome-panel/panel-global.schemas.in
@@ -183,10 +183,8 @@ Panel Global Config Schema File -  work in progress
         <type>bool</type>
         <default>true</default>
         <locale name="C">
-          <short>Highlight launchers on mouseover</short>
-          <long>If true, a launcher is highlighted when the user
-          moves the pointer over it.
-          </long>
+          <short>Deprecated</short>
+          <long></long>
         </locale>
       </schema>
 



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