[Xfce4-commits] [panel-plugins/xfce4-battery-plugin] 01/04: Use a variable for color_str so that it can be free'ed properly.

noreply at xfce.org noreply at xfce.org
Wed Dec 28 21:25:56 CET 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-battery-plugin.

commit 7a655091d63c2414672e58289a84c409298fd2be
Author: Andre Miranda <andre42m at gmail.com>
Date:   Wed Dec 28 21:17:52 2016 +0100

    Use a variable for color_str so that it can be free'ed properly.
    
    Move declaration of *css var where it belongs while here.
    
    Adapted from https://github.com/andreldm/xfce4-battery-plugin/commit/a39aaa793d43a74701a81f02b0e954afba488aa4
---
 panel-plugin/battery.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/battery.c b/panel-plugin/battery.c
index bdcd831..e349fa1 100644
--- a/panel-plugin/battery.c
+++ b/panel-plugin/battery.c
@@ -273,6 +273,9 @@ update_apm_status(t_battmon *battmon)
     int time_remaining=0;
     gboolean acline;
     gchar buffer[128];
+#if GTK_CHECK_VERSION (3, 16, 0)
+    gchar *css, *color_str;
+#endif
 
     static int update_time = AVERAGING_CYCLE;
     static int sum_lcapacity = 0;
@@ -600,18 +603,19 @@ battmon.c:241: for each function it appears in.)
     }
 
 #if GTK_CHECK_VERSION (3, 16, 0)
+    color_str = gdk_rgba_to_string (color);
 #if GTK_CHECK_VERSION (3, 20, 0)
     gchar * cssminsizes = "min-width: 4px; min-height: 0px";
     if (gtk_orientable_get_orientation(GTK_ORIENTABLE(battmon->battstatus)) == GTK_ORIENTATION_HORIZONTAL)
         cssminsizes = "min-width: 0px; min-height: 4px";
-    gchar * css = g_strdup_printf("progressbar trough { %s } \
+    css = g_strdup_printf("progressbar trough { %s } \
                                    progressbar progress { %s ; \
                                                          background-color: %s; background-image: none; }",
                                  cssminsizes, cssminsizes,
 #else
-    gchar *css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }",
+    css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }",
 #endif
-                                 gdk_rgba_to_string(color));
+                                 color_str);
     GtkCssProvider *css_provider = gtk_css_provider_new ();
     gtk_css_provider_load_from_data (css_provider, css, strlen(css), NULL);
     gtk_style_context_add_provider (
@@ -619,6 +623,7 @@ battmon.c:241: for each function it appears in.)
         GTK_STYLE_PROVIDER (css_provider),
         GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     g_free(css);
+    g_free(color_str);
 #else
     gtk_widget_override_background_color (GTK_WIDGET (battmon->battstatus), GTK_STATE_FLAG_NORMAL, color);
 #endif

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


More information about the Xfce4-commits mailing list