From eafef859551698a62714177adfedb04672b2c030 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Mon, 18 Jun 2018 19:55:54 +0200 Subject: caja-sidebar-title: Fix: images broken in sidebar Fixes https://github.com/mate-desktop/caja/pull/1004#issuecomment-398140812 --- src/caja-sidebar-title.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index 1907b370..e13c8549 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -421,6 +421,35 @@ update_icon (CajaSidebarTitle *sidebar_title) } } +static void +override_title_font (GtkWidget *widget, + const gchar *font) +{ + gchar *css; + GtkCssProvider *provider; + gchar *tempsize; + + provider = gtk_css_provider_new (); + tempsize = g_strdup (font); + + g_strreverse (tempsize); + g_strcanon (tempsize, "1234567890", '\0'); + g_strreverse (tempsize); + + gchar tempfont [strlen (font)]; + strcpy (tempfont, font); + tempfont [strlen (font) - strlen (tempsize)] = 0; + + css = g_strdup_printf ("label { font-family: %s; font-size: %spt; }", tempfont, tempsize); + gtk_css_provider_load_from_data (provider, css, -1, NULL); + g_free (css); + + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); +} + static void update_title_font (CajaSidebarTitle *sidebar_title) { @@ -480,11 +509,7 @@ update_title_font (CajaSidebarTitle *sidebar_title) pango_font_description_set_size (title_font, max_fit_font_size * PANGO_SCALE); pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD); - PangoAttrList *attrs = pango_attr_list_new (); - PangoAttribute *font_desc_attr = pango_attr_font_desc_new (title_font); - pango_attr_list_insert (attrs, font_desc_attr); - gtk_label_set_attributes (GTK_LABEL (sidebar_title->details->title_label), attrs); - pango_attr_list_unref (attrs); + override_title_font (sidebar_title->details->title_label, pango_font_description_to_string (title_font)); pango_font_description_free (title_font); } -- cgit v1.2.1