summaryrefslogtreecommitdiff
path: root/applets/wncklet
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-05-31 10:40:50 -0400
committerraveit65 <[email protected]>2018-06-06 14:16:14 +0200
commit2d3406f482a341805f9827b95e4b588feb0218ce (patch)
treeb7bb43e1597be634ba14bd8846464351d0208b99 /applets/wncklet
parent07eb4181d15ed9622aec95a37822f777fa7dd0ca (diff)
downloadmate-panel-2d3406f482a341805f9827b95e4b588feb0218ce.tar.bz2
mate-panel-2d3406f482a341805f9827b95e4b588feb0218ce.tar.xz
workspace-switcher: provide themed fallback color
When a theme does not specify a color for the highlighted workspace, we can look it up from the current theme and provide that as a fallback color. Fixes #807
Diffstat (limited to 'applets/wncklet')
-rw-r--r--applets/wncklet/workspace-switcher.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
index 2a13cebe..914653ac 100644
--- a/applets/wncklet/workspace-switcher.c
+++ b/applets/wncklet/workspace-switcher.c
@@ -248,6 +248,27 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac
type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
}
+static void applet_style_updated (MatePanelApplet *applet, GtkStyleContext *context)
+{
+ GtkCssProvider *provider;
+ GdkRGBA color;
+
+ provider = gtk_css_provider_new ();
+
+ /* Provide a fallback color for the highlighted workspace based on the current theme */
+ gtk_style_context_lookup_color (context, "theme_selected_bg_color", &color);
+ gchar *bg_css = g_strconcat (".wnck-pager:selected {\n"
+ " background-color:", gdk_rgba_to_string (&color), ";\n"
+ "}", NULL);
+ gtk_css_provider_load_from_data (provider, bg_css, -1, NULL);
+ g_free (bg_css);
+
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
+ g_object_unref (provider);
+}
+
/* Replacement for the default scroll handler that also cares about the wrapping property.
* Alternative: Add behaviour to libwnck (to the WnckPager widget).
*/
@@ -493,7 +514,6 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet)
PagerData* pager;
GtkActionGroup* action_group;
gboolean display_names;
- GtkCssProvider *provider;
pager = g_new0(PagerData, 1);
@@ -546,16 +566,6 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet)
context = gtk_widget_get_style_context (pager->pager);
gtk_style_context_add_class (context, "wnck-pager");
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- ".wnck-pager:selected {\n"
- "background-color: #4A90D9; }",
- -1, NULL);
- gtk_style_context_add_provider (context,
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
- g_object_unref (provider);
-
g_signal_connect(G_OBJECT(pager->pager), "destroy", G_CALLBACK(destroy_pager), pager);
/* overwrite default WnckPager widget scroll-event */
@@ -567,6 +577,7 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet)
g_signal_connect(G_OBJECT(pager->applet), "unrealize", G_CALLBACK(applet_unrealized), pager);
g_signal_connect(G_OBJECT(pager->applet), "change_orient", G_CALLBACK(applet_change_orient), pager);
g_signal_connect(G_OBJECT(pager->applet), "change_background", G_CALLBACK(applet_change_background), pager);
+ g_signal_connect(G_OBJECT(pager->applet), "style-updated", G_CALLBACK(applet_style_updated), context);
gtk_widget_show(pager->pager);
gtk_widget_show(pager->applet);