[Xfce4-commits] [panel-plugins/xfce4-datetime-plugin] 01/02: Fix font styling with Gtk 3.22.

noreply at xfce.org noreply at xfce.org
Tue Nov 1 15:33:39 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-datetime-plugin.

commit f6106a207ef984c32db11175a8baa0736ac79ceb
Author: Landry Breuil <landry at xfce.org>
Date:   Tue Nov 1 15:30:44 2016 +0100

    Fix font styling with Gtk 3.22.
    
    In 3.22, using 'font:' in a GtkCssProvider is deprecated, so you need to transform
    the fancy font name into a PangoFontDescription object, and use its various
    attributes to set font-family, font-style, font-size and font-weight.. sigh.
---
 panel-plugin/datetime.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/panel-plugin/datetime.c b/panel-plugin/datetime.c
index ecdd9c3..1722dd1 100644
--- a/panel-plugin/datetime.c
+++ b/panel-plugin/datetime.c
@@ -349,6 +349,19 @@ static void datetime_update_date_font(t_datetime *datetime)
     GtkCssProvider *css_provider;
     gchar * css;
 #if GTK_CHECK_VERSION (3, 20, 0)
+  PangoFontDescription *font;
+  font = pango_font_description_from_string(datetime->date_font);
+  if (G_LIKELY (font))
+  {
+    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);
+  }
+  else
     css = g_strdup_printf("label { font: %s; }",
 #else
     css = g_strdup_printf(".label { font: %s; }",
@@ -381,6 +394,19 @@ static void datetime_update_time_font(t_datetime *datetime)
     GtkCssProvider *css_provider;
     gchar * css;
 #if GTK_CHECK_VERSION (3, 20, 0)
+  PangoFontDescription *font;
+  font = pango_font_description_from_string(datetime->time_font);
+  if (G_LIKELY (font))
+  {
+    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);
+  }
+  else
     css = g_strdup_printf("label { font: %s; }",
 #else
     css = g_strdup_printf(".label { font: %s; }",

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


More information about the Xfce4-commits mailing list