[Xfce4-commits] [panel-plugins/xfce4-cpufreq-plugin] 14/20: Use CSS font styling

noreply at xfce.org noreply at xfce.org
Sat May 6 21:01:15 CEST 2017


This is an automated email from the git hooks/post-receive script.

andre pushed a commit to branch master
in repository panel-plugins/xfce4-cpufreq-plugin.

commit 2da482a01e9063d137e04f6e5f595ba965030d2c
Author: Andre Miranda <andre42m at gmail.com>
Date:   Fri Nov 4 22:52:16 2016 -0300

    Use CSS font styling
---
 panel-plugin/xfce4-cpufreq-plugin.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index 708791d..96e1766 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -100,16 +100,34 @@ cpufreq_cpus_calc_max (void)
 void
 cpufreq_label_set_font (void)
 {
-	PangoFontDescription *desc = NULL;
+	gchar *css;
+	GtkCssProvider *provider;
+	PangoFontDescription *font;
 
 	if (G_UNLIKELY (cpuFreq->label == NULL))
 		return;
 
 	if (cpuFreq->options->fontname)
-		desc = pango_font_description_from_string (cpuFreq->options->fontname);
-
-	gtk_widget_modify_font (cpuFreq->label, desc);
-    pango_font_description_free (desc);
+	{
+		font = pango_font_description_from_string(cpuFreq->options->fontname);
+
+		css = g_strdup_printf("label { font-family: %s; font-size: %dpx; font-style: %s; font-weight: %s }",
+			pango_font_description_get_family (font),
+			pango_font_description_get_size (font) / PANGO_SCALE,
+			(pango_font_description_get_style(font) == PANGO_STYLE_ITALIC ||
+			pango_font_description_get_style(font) == PANGO_STYLE_OBLIQUE) ? "italic" : "normal",
+			(pango_font_description_get_weight(font) >= PANGO_WEIGHT_BOLD) ? "bold" : "normal");
+		pango_font_description_free (font);
+
+		provider = gtk_css_provider_new ();
+
+		gtk_css_provider_load_from_data (provider, css, -1, NULL);
+		gtk_style_context_add_provider (
+			GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (cpuFreq->label))),
+			GTK_STYLE_PROVIDER(provider),
+			GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+		g_free(css);
+	}
 }
 
 gboolean

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


More information about the Xfce4-commits mailing list