[Xfce4-commits] [panel-plugins/xfce4-diskperf-plugin] 16/16: Set the progressbar color via a css provider if Gtk > 3.16. Handle fallback.
noreply at xfce.org
noreply at xfce.org
Thu Apr 28 18:10:16 CEST 2016
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository panel-plugins/xfce4-diskperf-plugin.
commit eef8fc5729d4aa26fd74676c005de65f618f76fe
Author: Landry Breuil <landry at xfce.org>
Date: Thu Apr 28 18:08:59 2016 +0200
Set the progressbar color via a css provider if Gtk > 3.16. Handle fallback.
---
panel-plugin/main.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index ab8fa28..7c3f0c1 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -326,15 +326,28 @@ static int SetSingleBarColor (struct diskperf_t *p_poPlugin, int p_iBar)
Widget_t *pwBar;
pwBar = poMonitor->aoPerfBar[p_iBar].pwBar;
- gtk_widget_modify_bg(GTK_WIDGET(*pwBar),
+#if GTK_CHECK_VERSION (3, 16, 0)
+ GtkCssProvider *css_provider;
+ gchar * css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }", gdk_rgba_to_string(&poConf->aoColor[p_iBar]));
+ /* Setup Gtk style */
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
+ gtk_style_context_add_provider (
+ GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (*pwBar))),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_free(css);
+#else
+ gtk_widget_override_background_color(GTK_WIDGET(*pwBar),
GTK_STATE_PRELIGHT,
&poConf->aoColor[p_iBar]);
- gtk_widget_modify_bg(GTK_WIDGET(*pwBar),
+ gtk_widget_override_background_color(GTK_WIDGET(*pwBar),
GTK_STATE_SELECTED,
&poConf->aoColor[p_iBar]);
- gtk_widget_modify_base(GTK_WIDGET(*pwBar),
+ gtk_widget_override_color(GTK_WIDGET(*pwBar),
GTK_STATE_SELECTED,
&poConf->aoColor[p_iBar]);
+#endif
return (0);
} /* SetSingleBarColor() */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list