[Xfce4-commits] [xfce/xfce4-panel] 01/01: Add hover and selected effect to workspace switcher

noreply at xfce.org noreply at xfce.org
Wed Mar 8 00:09:14 CET 2017


This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository xfce/xfce4-panel.

commit 0c6a989fcf637322b72df4f6be160c39cd612b10
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Mar 8 00:07:53 2017 +0100

    Add hover and selected effect to workspace switcher
    
    As the hover and selected state are derived of the
    background color of the panel (which has no "selected"
    or "active" state we could take the color from) we
    still have to find a way to support dark and bright
    panels out of the box.
    FIXME: The current solution only works for bright themes
    like Adwaita.
---
 plugins/pager/pager.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 1c4ac7d..a64748c 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -57,6 +57,8 @@ static gboolean pager_plugin_scroll_event                 (GtkWidget         *wi
 static void     pager_plugin_screen_changed               (GtkWidget         *widget,
                                                            GdkScreen         *previous_screen);
 static void     pager_plugin_construct                    (XfcePanelPlugin   *panel_plugin);
+static void     pager_plugin_style_updated                (GtkWidget         *pager,
+                                                           gpointer           user_data);
 static void     pager_plugin_free_data                    (XfcePanelPlugin   *panel_plugin);
 static gboolean pager_plugin_size_changed                 (XfcePanelPlugin   *panel_plugin,
                                                            gint               size);
@@ -272,6 +274,41 @@ pager_plugin_set_property (GObject      *object,
 
 
 
+static void
+pager_plugin_style_updated (GtkWidget *pager,
+                            gpointer   user_data)
+{
+  GtkWidget               *toplevel = gtk_widget_get_toplevel (pager);
+  GtkStyleContext         *context;
+  GtkCssProvider          *provider;
+  GdkRGBA                 *bg_color;
+  gchar                   *css_string;
+  gchar                   *color_string;
+
+  g_return_if_fail (gtk_widget_is_toplevel (toplevel));
+
+  /* Get the background color of the panel to draw selected and hover states */
+  provider = gtk_css_provider_new ();
+  context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
+  gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
+                         GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
+                         &bg_color, NULL);
+  color_string = gdk_rgba_to_string(bg_color);
+  // FIXME: The shade value only works well visually for bright themes/panels
+  css_string = g_strdup_printf ("wnck-pager:selected { background: shade(%s, 0.7); }"
+                                "wnck-pager:hover { background: shade(%s, 0.9); }",
+                                color_string, color_string);
+  context = gtk_widget_get_style_context (pager);
+  gtk_css_provider_load_from_data (provider, css_string, -1, NULL);
+  gtk_style_context_add_provider (context,
+                               GTK_STYLE_PROVIDER (provider),
+                               GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  gdk_rgba_free (bg_color);
+  g_free (color_string);
+}
+
+
+
 static gboolean
 pager_plugin_scroll_event (GtkWidget      *widget,
                            GdkEventScroll *event)
@@ -424,6 +461,8 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
   g_signal_connect (G_OBJECT (plugin), "screen-changed",
       G_CALLBACK (pager_plugin_screen_changed), NULL);
   pager_plugin_screen_changed (GTK_WIDGET (plugin), NULL);
+  g_signal_connect (G_OBJECT (plugin->pager), "style-updated",
+      G_CALLBACK (pager_plugin_style_updated), NULL);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list