theme: load icons as Gtk does with fallback and RTL support
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Fri, 30 Mar 2018 21:17:39 +0000 (15:17 -0600)
committerSimon McVittie <smcv@debian.org>
Sun, 8 Jul 2018 10:32:56 +0000 (11:32 +0100)
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

index c88ae54070b3f58e08aca394eb5f78ab9c391d03..7a77078d84c822ac2ff034a5bc1673f2f024b3c2 100644 (file)
@@ -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)