Skip to content
Permalink
Browse files

mateweather-dialog.c: avoid deprecated 'gtk_widget_override_font'

  • Loading branch information...
sc0w authored and lukefromdc committed Jul 8, 2018
1 parent 881233e commit a15746b9e73355c16750bd95c4a6ddc73e26d1ac
Showing with 46 additions and 1 deletion.
  1. +46 −1 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);
}

0 comments on commit a15746b

Please sign in to comment.
You can’t perform that action at this time.