From: Marco Trevisan (TreviƱo) Date: Fri, 30 Mar 2018 21:17:39 +0000 (-0600) Subject: theme: load icons as Gtk does with fallback and RTL support X-Git-Tag: archive/raspbian/3.28.1-2+rpi1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fbc7babe8eb8aaea7b18c8d38ec856294a9d6a52;p=mutter.git 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 --- 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)