[Xfce4-commits] [panel-plugins/xfce4-diskperf-plugin] 02/03: Rework css provider initialization
noreply at xfce.org
noreply at xfce.org
Sun Feb 19 11:29:18 CET 2017
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 ebab6361fee99b57a605453d2f4e66b05d36c67b
Author: Landry Breuil <landry at xfce.org>
Date: Sun Feb 19 11:24:06 2017 +0100
Rework css provider initialization
Create the provider only once at progressbar creation
Separately set the size and colors
---
panel-plugin/main.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index 303801e..7785648 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -321,25 +321,15 @@ static int SetSingleBarColor (struct diskperf_t *p_poPlugin, int p_iBar)
pwBar = poMonitor->aoPerfBar[p_iBar].pwBar;
#if GTK_CHECK_VERSION (3, 16, 0)
- GtkCssProvider *css_provider;
#if GTK_CHECK_VERSION (3, 20, 0)
- gchar * cssorient = (gtk_orientable_get_orientation(GTK_ORIENTABLE(*pwBar)) == GTK_ORIENTATION_VERTICAL ? "width" : "height");
- gchar * css = g_strdup_printf("progressbar trough { min-%s: 4px } \
- progressbar progress { min-%s: 4px ;\
- background-color: %s; background-image: none; }",
- cssorient, cssorient,
+ 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; }",
+ gchar * css = g_strdup_printf(".progressbar progress { background-color: %s; background-image: none; }",
#endif
gdk_rgba_to_string(&poConf->aoColor[p_iBar]));
/* Setup Gtk style */
- DBG("setting css to %s", css);
- 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);
+ DBG("setting css to %s for bar %d", css, p_iBar);
+ gtk_css_provider_load_from_data (g_object_get_data(G_OBJECT(*pwBar),"css_provider"), css, strlen(css), NULL);
g_free(css);
#else
gtk_widget_override_background_color(GTK_WIDGET(*pwBar),
@@ -398,6 +388,9 @@ static int CreateMonitorBars (struct diskperf_t *p_poPlugin,
GtkOrientation p_iOrientation)
/* Create the panel progressive bars */
{
+#if GTK_CHECK_VERSION (3, 16, 0)
+ GtkCssProvider *css_provider;
+#endif
struct diskperf_t *poPlugin = p_poPlugin;
struct param_t *poConf = &(poPlugin->oConf.oParam);
struct monitor_t *poMonitor = &(poPlugin->oMonitor);
@@ -423,6 +416,28 @@ static int CreateMonitorBars (struct diskperf_t *p_poPlugin,
gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR(*pwBar),
(p_iOrientation ==
GTK_ORIENTATION_HORIZONTAL));
+#if GTK_CHECK_VERSION (3, 16, 0)
+ css_provider = gtk_css_provider_new ();
+#if GTK_CHECK_VERSION (3, 20, 0)
+ gtk_css_provider_load_from_data (css_provider, "\
+ progressbar.horizontal trough { min-height: 4px; }\
+ progressbar.horizontal progress { min-height: 4px; }\
+ progressbar.vertical trough { min-width: 4px; }\
+ progressbar.vertical progress { min-width: 4px; }",
+#else
+ gtk_css_provider_load_from_data (css_provider, "\
+ .progressbar.horizontal trough { min-height: 4px; }\
+ .progressbar.horizontal progress { min-height: 4px; }\
+ .progressbar.vertical trough { min-width: 4px; }\
+ .progressbar.vertical progress { min-width: 4px; }",
+#endif
+ -1, 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_object_set_data(G_OBJECT(*pwBar), "css_provider", css_provider);
+#endif
if ((i == 1) && poConf->fRW_DataCombined)
gtk_widget_hide (GTK_WIDGET (*pwBar));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list