Skip to content

Commit eafef85

Browse files
committed
caja-sidebar-title: Fix: images broken in sidebar
Fixes #1004 (comment)
1 parent a797afc commit eafef85

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

Diff for: src/caja-sidebar-title.c

+30-5
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,35 @@ update_icon (CajaSidebarTitle *sidebar_title)
421421
}
422422
}
423423

424+
static void
425+
override_title_font (GtkWidget *widget,
426+
const gchar *font)
427+
{
428+
gchar *css;
429+
GtkCssProvider *provider;
430+
gchar *tempsize;
431+
432+
provider = gtk_css_provider_new ();
433+
tempsize = g_strdup (font);
434+
435+
g_strreverse (tempsize);
436+
g_strcanon (tempsize, "1234567890", '\0');
437+
g_strreverse (tempsize);
438+
439+
gchar tempfont [strlen (font)];
440+
strcpy (tempfont, font);
441+
tempfont [strlen (font) - strlen (tempsize)] = 0;
442+
443+
css = g_strdup_printf ("label { font-family: %s; font-size: %spt; }", tempfont, tempsize);
444+
gtk_css_provider_load_from_data (provider, css, -1, NULL);
445+
g_free (css);
446+
447+
gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
448+
GTK_STYLE_PROVIDER (provider),
449+
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
450+
g_object_unref (provider);
451+
}
452+
424453
static void
425454
update_title_font (CajaSidebarTitle *sidebar_title)
426455
{
@@ -480,11 +509,7 @@ update_title_font (CajaSidebarTitle *sidebar_title)
480509
pango_font_description_set_size (title_font, max_fit_font_size * PANGO_SCALE);
481510
pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD);
482511

483-
PangoAttrList *attrs = pango_attr_list_new ();
484-
PangoAttribute *font_desc_attr = pango_attr_font_desc_new (title_font);
485-
pango_attr_list_insert (attrs, font_desc_attr);
486-
gtk_label_set_attributes (GTK_LABEL (sidebar_title->details->title_label), attrs);
487-
pango_attr_list_unref (attrs);
512+
override_title_font (sidebar_title->details->title_label, pango_font_description_to_string (title_font));
488513

489514
pango_font_description_free (title_font);
490515
}

0 commit comments

Comments
 (0)