summaryrefslogtreecommitdiff
path: root/mateweather
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-07-08 14:56:11 +0200
committerlukefromdc <[email protected]>2018-07-17 00:01:30 -0400
commita15746b9e73355c16750bd95c4a6ddc73e26d1ac (patch)
tree855409c2b8c194ee7e91338be8013f442b2c8288 /mateweather
parent881233e8e6b6f0d70fd6a2dcd4235afe94c9b659 (diff)
downloadmate-applets-a15746b9e73355c16750bd95c4a6ddc73e26d1ac.tar.bz2
mate-applets-a15746b9e73355c16750bd95c4a6ddc73e26d1ac.tar.xz
mateweather-dialog.c: avoid deprecated 'gtk_widget_override_font'
Diffstat (limited to 'mateweather')
-rw-r--r--mateweather/mateweather-dialog.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/mateweather/mateweather-dialog.c b/mateweather/mateweather-dialog.c
index 8bdfc2e0..0c4ee3c9 100644
--- a/mateweather/mateweather-dialog.c
+++ b/mateweather/mateweather-dialog.c
@@ -506,6 +506,51 @@ static PangoFontDescription* get_system_monospace_font(void)
return desc;
}
+static void
+override_widget_font (GtkWidget *widget,
+ PangoFontDescription *font)
+{
+ static gboolean provider_added = FALSE;
+ GtkCssProvider *provider;
+ gchar *css;
+ gchar *family;
+ gchar *weight;
+ const gchar *style;
+ gchar *size;
+
+ family = g_strdup_printf ("font-family: %s;", pango_font_description_get_family (font));
+
+ weight = g_strdup_printf ("font-weight: %d;", pango_font_description_get_weight (font));
+
+ if (pango_font_description_get_style (font) == PANGO_STYLE_NORMAL)
+ style = "font-style: normal;";
+ else if (pango_font_description_get_style (font) == PANGO_STYLE_ITALIC)
+ style = "font-style: italic;";
+ else
+ style = "font-style: oblique;";
+
+ size = g_strdup_printf ("font-size: %d%s;",
+ pango_font_description_get_size (font) / PANGO_SCALE,
+ pango_font_description_get_size_is_absolute (font) ? "px" : "pt");
+
+ provider = gtk_css_provider_get_default ();
+
+ css = g_strdup_printf ("textview { %s %s %s %s }", family, weight, style, size);
+ gtk_css_provider_load_from_data (provider, css, -1, NULL);
+
+ if (!provider_added) {
+ gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ provider_added = TRUE;
+ }
+
+ g_free (css);
+ g_free (family);
+ g_free (weight);
+ g_free (size);
+}
+
void mateweather_dialog_update(MateWeatherDialog* dialog)
{
MateWeatherDialogPrivate *priv;
@@ -546,7 +591,7 @@ void mateweather_dialog_update(MateWeatherDialog* dialog)
if (gw_applet->mateweather_pref.location->zone_valid) {
font_desc = get_system_monospace_font ();
if (font_desc) {
- gtk_widget_override_font (priv->forecast_text, font_desc);
+ override_widget_font (priv->forecast_text, font_desc);
pango_font_description_free (font_desc);
}