From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= Date: Fri, 30 Mar 2018 15:17:39 -0600 Subject: theme: load icons as Gtk does with fallback and RTL support Forwarded: yes, https://gitlab.gnome.org/GNOME/mutter/merge_requests/62 Applied-upstream: no --- src/ui/theme.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/ui/theme.c b/src/ui/theme.c index e84870f..c307113 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -860,14 +860,34 @@ meta_frame_layout_draw_with_style (MetaFrameLayout *layout, if (icon_name) { - GtkIconTheme *theme = gtk_icon_theme_get_default (); + g_autoptr (GIcon) icon = NULL; g_autoptr (GtkIconInfo) info = NULL; g_autoptr (GdkPixbuf) pixbuf = NULL; - - info = gtk_icon_theme_lookup_icon_for_scale (theme, icon_name, - layout->icon_size, scale, 0); - pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, NULL, NULL); - surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL); + GtkIconTheme *theme; + int flags; + + theme = gtk_icon_theme_get_default (); + + /* This can't be exactly like Gtk does as some -gtk-* css + * properties that are used for setting the loading flags + * are not accessible from here */ + flags = GTK_ICON_LOOKUP_USE_BUILTIN; + flags |= (meta_get_locale_direction () == META_LOCALE_DIRECTION_LTR) ? + GTK_ICON_LOOKUP_DIR_LTR : GTK_ICON_LOOKUP_DIR_RTL; + + icon = g_themed_icon_new_with_default_fallbacks (icon_name); + info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, + layout->icon_size, + scale, flags); + if (gtk_icon_info_is_symbolic (info)) + pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, + NULL, NULL); + else + pixbuf = gtk_icon_info_load_icon (info, NULL); + + if (pixbuf) + surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, + NULL); } if (surface)