Convert trivial users of icon theme loading to use info as paintable
authorAlexander Larsson <alexl@redhat.com>
Mon, 27 Jan 2020 14:40:58 +0000 (15:40 +0100)
committerAlexander Larsson <alexl@redhat.com>
Wed, 29 Jan 2020 18:06:16 +0000 (19:06 +0100)
demos/gtk-demo/clipboard.c
demos/icon-browser/iconbrowserwin.c
gtk/gtkcalendar.c
gtk/gtkdragsource.c
gtk/gtkwindow.c
tests/testicontheme.c

index c8e5323bab43c167ef030d4bb81177fcb3f5f647..6f817750d75bc939666bc62d2262404193d4bc8e 100644 (file)
@@ -110,7 +110,7 @@ get_image_paintable (GtkImage *image)
       icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
       if (icon_info == NULL)
         return NULL;
-      return gtk_icon_info_load_icon (icon_info, NULL);
+      return GDK_PAINTABLE (icon_info);
     default:
       g_warning ("Image storage type %d not handled",
                  gtk_image_get_storage_type (image));
index d31a635b4b5b3a1bbd6c13c5902e588b3e35f177..7532831573ca5cdd980eee50cb32a60436d103b5 100644 (file)
@@ -363,7 +363,7 @@ get_image_paintable (GtkImage *image)
                                               GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
       if (icon_info == NULL)
         return NULL;
-      return gtk_icon_info_load_icon (icon_info, NULL);
+      return GDK_PAINTABLE (icon_info);
     default:
       g_warning ("Image storage type %d not handled",
                  gtk_image_get_storage_type (image));
index 4a3e8f3b0a17650d883a7acc0458e0bb6313dda3..494a72fda85c480903e82e10903799e492d05f45 100644 (file)
@@ -2585,7 +2585,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
   GdkDevice *device;
   GdkDrag *drag;
   GtkIconTheme *theme;
-  GdkPaintable *paintable;
+  GtkIconInfo *icon;
   GdkSurface *surface;
 
   if (!priv->in_drag)
@@ -2604,9 +2604,9 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
   drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y);
 
   theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
-  paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
-  gtk_drag_icon_set_from_paintable (drag, paintable, 0, 0);
-  g_clear_object (&paintable);
+  icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0);
+  gtk_drag_icon_set_from_paintable (drag, GDK_PAINTABLE (icon), 0, 0);
+  g_clear_object (&icon);
 
   g_object_unref (content);
   g_object_unref (drag);
index 3ef11dc7e69b0aaf11df77d9ce19e094b1946be0..6bf730401cdd55d00f4e0c85a2740e5dcbb25229 100644 (file)
@@ -484,9 +484,9 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
   if (!source->paintable)
     {
       GtkIconTheme *theme;
+
       theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
-      source->paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
+      source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0));
       source->hot_x = 0;
       source->hot_y = 0;
     }
index a396f9e9911fcf93561fbece0f39c49c1f369357..8846f57820cf74cf8119b594cd80a419844300ae 100644 (file)
@@ -4102,7 +4102,6 @@ gtk_window_get_icon_for_size (GtkWindow *window,
 {
   const char *name;
   GtkIconInfo *info;
-  GdkPaintable *paintable;
 
   name = gtk_window_get_icon_name (window);
 
@@ -4117,10 +4116,7 @@ gtk_window_get_icon_for_size (GtkWindow *window,
   if (info == NULL)
     return NULL;
 
-  paintable = gtk_icon_info_load_icon (info, NULL);
-  g_object_unref (info);
-
-  return paintable;
+  return GDK_PAINTABLE (info);
 }
 
 static void
index 8b3d4628642d33f17e7f531845d06a8d73b88720..c6211be8e07453848617bb6af17f05651dcc7c69 100644 (file)
@@ -90,8 +90,7 @@ main (int argc, char *argv[])
 
   if (strcmp (argv[1], "display") == 0)
     {
-      GError *error;
-      GdkPaintable *paintable;
+      GtkIconInfo *icon;
       GtkWidget *window, *image;
 
       if (argc < 4)
@@ -107,22 +106,21 @@ main (int argc, char *argv[])
       if (argc >= 6)
        scale = atoi (argv[5]);
 
-      error = NULL;
-      paintable = gtk_icon_theme_load_icon_for_scale (icon_theme, argv[3], size, scale, flags, &error);
-      if (!paintable)
+      icon = gtk_icon_theme_lookup_icon_for_scale (icon_theme, argv[3], size, scale, flags);
+      if (!icon)
         {
-          g_print ("%s\n", error->message);
+          g_print ("Icon '%s' not found\n", argv[3]);
           return 1;
         }
 
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       image = gtk_image_new ();
-      gtk_image_set_from_paintable (GTK_IMAGE (image), paintable);
-      g_object_unref (paintable);
+      gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (icon));
+      g_object_unref (icon);
       gtk_container_add (GTK_CONTAINER (window), image);
       g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
       gtk_widget_show (window);
-      
+
       gtk_main ();
     }
   else if (strcmp (argv[1], "display-async") == 0)
@@ -199,16 +197,10 @@ main (int argc, char *argv[])
 
       if (icon_info)
        {
-          GdkTexture *texture;
+          GdkPaintable *paintable = GDK_PAINTABLE (icon_info);
 
           g_print ("Base size: %d, Scale: %d\n", gtk_icon_info_get_base_size (icon_info), gtk_icon_info_get_base_scale (icon_info));
-
-          texture = GDK_TEXTURE (gtk_icon_info_load_icon (icon_info, NULL));
-          if (texture != NULL)
-            {
-              g_print ("texture size: %dx%d\n", gdk_texture_get_width (texture), gdk_texture_get_height (texture));
-              g_object_unref (texture);
-            }
+          g_print ("texture size: %dx%d\n", gdk_paintable_get_intrinsic_width (paintable), gdk_paintable_get_intrinsic_height (paintable));
 
          g_object_unref (icon_info);
        }