From 19a9cb1d72fe648cb4ea497dfa91d2e6d1e5da81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 30 Mar 2018 15:17:39 -0600 Subject: [PATCH] theme: load icons as Gtk does with fallback and RTL support Forwarded: yes, https://gitlab.gnome.org/GNOME/mutter/merge_requests/62 Gbp-Pq: Name theme-load-icons-as-Gtk-does-with-fallback-and-RTL-suppor.patch --- src/ui/theme.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/ui/theme.c b/src/ui/theme.c index c88ae54..7a77078 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -878,14 +878,34 @@ meta_frame_layout_draw_with_style (MetaFrameLayout *layout, if (icon_name) { - GtkIconTheme *theme = gtk_icon_theme_get_default (); - GtkIconInfo *info; - GdkPixbuf *pixbuf; - - 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); + g_autoptr (GIcon) icon = NULL; + g_autoptr (GtkIconInfo) info = NULL; + g_autoptr (GdkPixbuf) pixbuf = 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) -- 2.30.2