[gtk/image-loading: 3/5] icontheme: Implement gtk_icon_theme_lookup_by_gicon() for textures




commit 37a7c6780ace8ae719cd10bc46898bd23a2b0f04
Author: Benjamin Otte <otte redhat com>
Date:   Fri Sep 17 04:07:59 2021 +0200

    icontheme: Implement gtk_icon_theme_lookup_by_gicon() for textures
    
    More feature parity.
    
    Before this, it would have worked just as well - just going via a PNG
    bytes step inbetween.

 gtk/gtkicontheme.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index eaeb8e4063..1c2d83125c 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -4084,20 +4084,6 @@ gtk_icon_paintable_new_for_file (GFile *file,
   return icon;
 }
 
-static GtkIconPaintable *
-gtk_icon_paintable_new_for_pixbuf (GtkIconTheme *icon_theme,
-                                   GdkPixbuf    *pixbuf,
-                                   int           size,
-                                   int           scale)
-{
-  GtkIconPaintable *icon;
-
-  icon = icon_paintable_new (NULL, size, scale);
-  icon->texture = gdk_texture_new_for_pixbuf (pixbuf);
-
-  return icon;
-}
-
 /**
  * gtk_icon_theme_lookup_by_gicon:
  * @self: a `GtkIconTheme`
@@ -4135,11 +4121,15 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme       *self,
     gicon = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (gicon));
   g_assert (gicon); /* shut up gcc -Wnull-dereference */
 
-  if (GDK_IS_PIXBUF (gicon))
+  if (GDK_IS_TEXTURE (gicon))
     {
-      GdkPixbuf *pixbuf = GDK_PIXBUF (gicon);
-
-      icon = gtk_icon_paintable_new_for_pixbuf (self, pixbuf, size, scale);
+      icon = icon_paintable_new (NULL, size, scale);
+      icon->texture = g_object_ref (GDK_TEXTURE (icon));
+    }
+  else if (GDK_IS_PIXBUF (gicon))
+    {
+      icon = icon_paintable_new (NULL, size, scale);
+      icon->texture = gdk_texture_new_for_pixbuf (GDK_PIXBUF (icon));
     }
   else if (G_IS_FILE_ICON (gicon))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]