[Xfce4-commits] [panel-plugins/xfce4-battery-plugin] 03/04: Create a single GtkCssProvider in setup_battmon() (#12975)
noreply at xfce.org
noreply at xfce.org
Wed Dec 28 21:25:58 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 f02a6cd4f85a83a4ad4f7dcb7b520d73a8917732
Author: Andre Miranda <andre42m at gmail.com>
Date: Wed Dec 28 21:23:00 2016 +0100
Create a single GtkCssProvider in setup_battmon() (#12975)
Only call gtk_css_provider_load_from_data() with it, instead of creating an
instance at every update_apm_status() and leaking it..
---
panel-plugin/battery.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/panel-plugin/battery.c b/panel-plugin/battery.c
index 6eada02..957745b 100644
--- a/panel-plugin/battery.c
+++ b/panel-plugin/battery.c
@@ -103,7 +103,10 @@ typedef struct
GtkLabel *rtime;
GtkLabel *acfan;
GtkLabel *temp;
- GtkWidget *image;
+ GtkWidget *image;
+#if GTK_CHECK_VERSION (3, 16, 0)
+ GtkCssProvider *css_provider;
+#endif
} t_battmon;
typedef struct
@@ -616,12 +619,7 @@ battmon.c:241: for each function it appears in.)
css = g_strdup_printf("progressbar progress { background-color: %s; background-image: none; }",
#endif
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 (
- GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (battmon->battstatus))),
- GTK_STYLE_PROVIDER (css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_css_provider_load_from_data (battmon->css_provider, css, strlen(css), NULL);
g_free(css);
g_free(color_str);
#else
@@ -689,6 +687,14 @@ static void setup_battmon(t_battmon *battmon)
gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(battmon->battstatus),
(xfce_panel_plugin_get_orientation(battmon->plugin) == GTK_ORIENTATION_HORIZONTAL));
+#if GTK_CHECK_VERSION (3, 16, 0)
+ battmon->css_provider = gtk_css_provider_new();
+ gtk_style_context_add_provider(
+ GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (battmon->battstatus))),
+ GTK_STYLE_PROVIDER (battmon->css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
+
battmon->label = (GtkLabel *)gtk_label_new(_("Battery"));
gtk_box_pack_start(GTK_BOX(battmon->ebox),GTK_WIDGET(battmon->label),FALSE, FALSE, 2);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list