[Xfce4-commits] [panel-plugins/xfce4-systemload-plugin] 10/16: Rework progressbar color handling

noreply at xfce.org noreply at xfce.org
Fri Apr 29 16:07:27 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-systemload-plugin.

commit ba194bb10c327e9276d6a53bb6da8e9cb8ac72eb
Author: Landry Breuil <landry at xfce.org>
Date:   Fri Apr 29 11:41:13 2016 +0200

    Rework progressbar color handling
    
    - Use a css provider with Gtk >= 3.16
    - Use gtk_widget_override_background_color/gtk_widget_override_color with Gtk < 3.16
---
 panel-plugin/systemload.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/systemload.c b/panel-plugin/systemload.c
index e0d53ad..bd3015a 100644
--- a/panel-plugin/systemload.c
+++ b/panel-plugin/systemload.c
@@ -436,15 +436,33 @@ setup_monitor(t_global_monitor *global)
         gtk_label_set_text(GTK_LABEL(global->monitor[count]->label),
                            global->monitor[count]->options.label_text);
 
-        gtk_widget_modify_bg(GTK_WIDGET(global->monitor[count]->status),
+#if GTK_CHECK_VERSION (3, 16, 0)
+        GtkCssProvider *css_provider;
+#if GTK_CHECK_VERSION (3, 20, 0)
+        gchar * css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }",
+#else
+        gchar * css = g_strdup_printf(".progressbar { background-color: %s; background-image: none; }",
+#endif
+                                      gdk_rgba_to_string(&global->monitor[count]->options.color));
+        /* 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 (global->monitor[count]->status))),
+            GTK_STYLE_PROVIDER (css_provider),
+            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+        g_free(css);
+#else
+        gtk_widget_override_background_color(GTK_WIDGET(global->monitor[count]->status),
                              GTK_STATE_PRELIGHT,
                              &global->monitor[count]->options.color);
-        gtk_widget_modify_bg(GTK_WIDGET(global->monitor[count]->status),
+        gtk_widget_override_background_color(GTK_WIDGET(global->monitor[count]->status),
                              GTK_STATE_SELECTED,
                              &global->monitor[count]->options.color);
-        gtk_widget_modify_base(GTK_WIDGET(global->monitor[count]->status),
+        gtk_widget_override_color(GTK_WIDGET(global->monitor[count]->status),
                                GTK_STATE_SELECTED,
                                &global->monitor[count]->options.color);
+#endif
 
         if(global->monitor[count]->options.enabled)
         {

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


More information about the Xfce4-commits mailing list