image: Remove gtk_image_set_texture()
authorBenjamin Otte <otte@redhat.com>
Fri, 16 Mar 2018 03:29:42 +0000 (04:29 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 16 Mar 2018 05:04:45 +0000 (06:04 +0100)
gtk_image_get_paintable() is a perfect replacement, so use that one.

14 files changed:
demos/gtk-demo/clipboard.c
demos/gtk-demo/cursors.ui
demos/gtk-demo/main.c
gtk/gtkaboutdialog.c
gtk/gtkbuilder.c
gtk/gtkdnd.c
gtk/gtkheaderbar.c
gtk/gtkimage.c
gtk/gtkimage.h
gtk/inspector/recorder.c
tests/showrendernode.c
tests/testclipboard2.c
tests/testdnd2.c
tests/testimage.c

index 5196b316fe63b90d0dd299d969360d74c9638080..73a8d4ed6f29accab17b49cae223d9004d17fe0a 100644 (file)
@@ -93,8 +93,8 @@ paste_button_clicked (GtkWidget *button,
   gdk_clipboard_read_text_async (clipboard, NULL, paste_received, entry);
 }
 
-static GdkTexture *
-get_image_texture (GtkImage *image)
+static GdkPaintable *
+get_image_paintable (GtkImage *image)
 {
   const gchar *icon_name;
   GtkIconTheme *icon_theme;
@@ -102,15 +102,15 @@ get_image_texture (GtkImage *image)
 
   switch (gtk_image_get_storage_type (image))
     {
-    case GTK_IMAGE_TEXTURE:
-      return g_object_ref (gtk_image_get_texture (image));
+    case GTK_IMAGE_PAINTABLE:
+      return g_object_ref (gtk_image_get_paintable (image));
     case GTK_IMAGE_ICON_NAME:
       icon_name = gtk_image_get_icon_name (image);
       icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (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_texture (icon_info);
+      return GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info));
     default:
       g_warning ("Image storage type %d not handled",
                  gtk_image_get_storage_type (image));
@@ -123,13 +123,13 @@ drag_begin (GtkWidget      *widget,
             GdkDragContext *context,
             gpointer        data)
 {
-  GdkTexture *texture;
+  GdkPaintable *paintable;
 
-  texture = get_image_texture (GTK_IMAGE (widget));
-  if (texture)
+  paintable = get_image_paintable (GTK_IMAGE (widget));
+  if (paintable)
     {
-      gtk_drag_set_icon_paintable (context, GDK_PAINTABLE (texture), -2, -2);
-      g_object_unref (texture);
+      gtk_drag_set_icon_paintable (context, paintable, -2, -2);
+      g_object_unref (paintable);
     }
 }
 
@@ -141,11 +141,11 @@ drag_data_get (GtkWidget        *widget,
                guint             time,
                gpointer          data)
 {
-  GdkTexture *texture;
+  GdkPaintable *paintable;
 
-  texture = get_image_texture (GTK_IMAGE (widget));
-  if (texture)
-    gtk_selection_data_set_texture (selection_data, texture);
+  paintable = get_image_paintable (GTK_IMAGE (widget));
+  if (GDK_IS_TEXTURE (paintable))
+    gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
 }
 
 static void
@@ -160,7 +160,7 @@ drag_data_received (GtkWidget        *widget,
       GdkTexture *texture;
 
       texture = gtk_selection_data_get_texture (selection_data);
-      gtk_image_set_from_texture (GTK_IMAGE (data), texture);
+      gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
       g_object_unref (texture);
     }
 }
@@ -170,16 +170,16 @@ copy_image (GtkMenuItem *item,
             gpointer     data)
 {
   GdkClipboard *clipboard;
-  GdkTexture *texture;
+  GdkPaintable *paintable;
 
   clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
-  texture = get_image_texture (GTK_IMAGE (data));
+  paintable = get_image_paintable (GTK_IMAGE (data));
 
-  if (texture)
-    {
-      gdk_clipboard_set_texture (clipboard, texture);
-      g_object_unref (texture);
-    }
+  if (GDK_IS_TEXTURE (paintable))
+    gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
+
+  if (paintable)
+    g_object_unref (paintable);
 }
 
 static void
@@ -193,7 +193,7 @@ paste_image_received (GObject      *source,
   if (texture == NULL)
     return;
     
-  gtk_image_set_from_texture (GTK_IMAGE (data), texture);
+  gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
   g_object_unref (texture);
 }
 
index 9a78fa436f5f278b468afd1322472b4140fa4896..8077c4c4c34b7194cda76fd8a529edb7e30950f9 100644 (file)
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/default_cursor.png</property>
+                                <property name="paintable">resource:///cursors/default_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/none_cursor.png</property>
+                                <property name="paintable">resource:///cursors/none_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/gtk_logo_cursor.png</property>
+                                <property name="paintable">resource:///cursors/gtk_logo_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/context_menu_cursor.png</property>
+                                <property name="paintable">resource:///cursors/context_menu_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/help_cursor.png</property>
+                                <property name="paintable">resource:///cursors/help_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/pointer_cursor.png</property>
+                                <property name="paintable">resource:///cursors/pointer_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/progress_cursor.png</property>
+                                <property name="paintable">resource:///cursors/progress_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/wait_cursor.png</property>
+                                <property name="paintable">resource:///cursors/wait_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/cell_cursor.png</property>
+                                <property name="paintable">resource:///cursors/cell_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/crosshair_cursor.png</property>
+                                <property name="paintable">resource:///cursors/crosshair_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/text_cursor.png</property>
+                                <property name="paintable">resource:///cursors/text_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/vertical_text_cursor.png</property>
+                                <property name="paintable">resource:///cursors/vertical_text_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/alias_cursor.png</property>
+                                <property name="paintable">resource:///cursors/alias_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/copy_cursor.png</property>
+                                <property name="paintable">resource:///cursors/copy_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/move_cursor.png</property>
+                                <property name="paintable">resource:///cursors/move_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/no_drop_cursor.png</property>
+                                <property name="paintable">resource:///cursors/no_drop_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/not_allowed_cursor.png</property>
+                                <property name="paintable">resource:///cursors/not_allowed_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/grab_cursor.png</property>
+                                <property name="paintable">resource:///cursors/grab_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/grabbing_cursor.png</property>
+                                <property name="paintable">resource:///cursors/grabbing_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/all_scroll_cursor.png</property>
+                                <property name="paintable">resource:///cursors/all_scroll_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/col_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/col_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/row_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/row_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/n_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/n_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/e_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/e_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/s_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/s_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/w_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/w_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/ne_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/ne_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/nw_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/nw_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/sw_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/sw_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/se_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/se_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/ew_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/ew_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/ns_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/ns_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/nesw_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/nesw_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/nwse_resize_cursor.png</property>
+                                <property name="paintable">resource:///cursors/nwse_resize_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/zoom_in_cursor.png</property>
+                                <property name="paintable">resource:///cursors/zoom_in_cursor.png</property>
                               </object>
                             </child>
                             <child>
                             <property name="spacing">10</property>
                             <child>
                               <object class="GtkImage">
-                                <property name="texture">resource:///cursors/zoom_out_cursor.png</property>
+                                <property name="paintable">resource:///cursors/zoom_out_cursor.png</property>
                               </object>
                             </child>
                             <child>
index 95798c7c2f7a377c4f96305f4cdffbdb5238c6a9..bf009ab46fe1f129a23c93a0f0afb9f7465d04b9 100644 (file)
@@ -555,7 +555,7 @@ add_data_tab (const gchar *demoname)
       resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
 
       widget = gtk_image_new_from_resource (resource_name);
-      if (gtk_image_get_texture (GTK_IMAGE (widget)) == NULL)
+      if (gtk_image_get_paintable (GTK_IMAGE (widget)) == NULL)
         {
           GBytes *bytes;
 
index 03a17325b78cd5eeefc01c1d2438bf3e00836f81..03e7208713aa051fe93201cbd331b916491c2457 100644 (file)
@@ -1878,7 +1878,7 @@ gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
     }
   else if ((icons = gtk_window_get_default_icon_list ()))
     {
-      gtk_image_set_from_texture (GTK_IMAGE (priv->logo_image), icons->data);
+      gtk_image_set_from_paintable (GTK_IMAGE (priv->logo_image), icons->data);
       g_list_free (icons);
     }
   else
index c492da1e4e29cb65b106052ac264539eaedbad64..98bde1216137dfac196bfb5c6b89ff2359680d31 100644 (file)
@@ -529,6 +529,7 @@ gtk_builder_get_parameters (GtkBuilder         *builder,
       if (G_IS_PARAM_SPEC_OBJECT (prop->pspec) &&
           (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF) &&
           (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_TEXTURE) &&
+          (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PAINTABLE) &&
           (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
         {
           GObject *object = g_hash_table_lookup (builder->priv->objects,
@@ -2050,6 +2051,7 @@ gtk_builder_value_from_string_type (GtkBuilder   *builder,
     case G_TYPE_OBJECT:
     case G_TYPE_INTERFACE:
       if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF) ||
+          G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE) || 
           G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE))
         {
           gchar *filename;
@@ -2102,7 +2104,8 @@ gtk_builder_value_from_string_type (GtkBuilder   *builder,
 
           if (pixbuf)
             {
-              if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE))
+              if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE) ||
+                  G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE))
                 {
                   GdkTexture *texture = gdk_texture_new_for_pixbuf (pixbuf);
                   g_value_set_object (value, texture);
index 3eb081687b58ec7ad2e2fa130042dc742d7e58c9..ffaf0847ff3d751d80a74de2fe5f4d74e62407fc 100644 (file)
@@ -1205,7 +1205,7 @@ gtk_drag_set_icon_surface (GdkDragContext  *context,
   cairo_surface_set_device_offset (surface, 0, 0);
 
   texture = gdk_texture_new_for_surface (surface);
-  widget = gtk_image_new_from_texture (texture);
+  widget = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
   g_object_unref (texture);
 
   gtk_drag_set_icon_widget_internal (context, widget, (int)hot_x, (int)hot_y, TRUE);
index 0a67447961586327ffff53767075def670c3e7e9..a919fc82358ef7fd6ba72260fcd8723659cae8d8 100644 (file)
@@ -228,7 +228,8 @@ _gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
 
   if (texture)
     {
-      gtk_image_set_from_texture (GTK_IMAGE (priv->titlebar_icon), texture);
+      gtk_image_set_from_paintable (GTK_IMAGE (priv->titlebar_icon),
+                                    GDK_PAINTABLE (texture));
       g_object_unref (texture);
       gtk_widget_show (priv->titlebar_icon);
 
index 8a8a8235f565657d08aefba9cd0422c6c51dad13..f56ea2b1e0d0afb66f26940d0998b45dd7d1bde4 100644 (file)
@@ -62,7 +62,7 @@
  * If you want to handle errors in loading the file yourself,
  * for example by displaying an error message, then load the image with
  * gdk_texture_new_from_file(), then create the #GtkImage with
- * gtk_image_new_from_texture().
+ * gtk_image_new_from_paintable().
  *
  * Sometimes an application will want to avoid depending on external data
  * files, such as image files. See the documentation of #GResource for details.
@@ -123,7 +123,6 @@ enum
 {
   PROP_0,
   PROP_PAINTABLE,
-  PROP_TEXTURE,
   PROP_FILE,
   PROP_ICON_SIZE,
   PROP_PIXEL_SIZE,
@@ -167,13 +166,6 @@ gtk_image_class_init (GtkImageClass *class)
                            GDK_TYPE_PAINTABLE,
                            GTK_PARAM_READWRITE);
 
-  image_props[PROP_TEXTURE] =
-      g_param_spec_object ("texture",
-                           P_("Texture"),
-                           P_("A GdkTexture to display"),
-                           GDK_TYPE_TEXTURE,
-                           GTK_PARAM_READWRITE);
-
   image_props[PROP_FILE] =
       g_param_spec_string ("file",
                            P_("Filename"),
@@ -340,9 +332,6 @@ gtk_image_set_property (GObject      *object,
     case PROP_PAINTABLE:
       gtk_image_set_from_paintable (image, g_value_get_object (value));
       break;
-    case PROP_TEXTURE:
-      gtk_image_set_from_texture (image, g_value_get_object (value));
-      break;
     case PROP_FILE:
       gtk_image_set_from_file (image, g_value_get_string (value));
       break;
@@ -395,9 +384,6 @@ gtk_image_get_property (GObject     *object,
     case PROP_PAINTABLE:
       g_value_set_object (value, _gtk_icon_helper_peek_paintable (priv->icon_helper));
       break;
-    case PROP_TEXTURE:
-      g_value_set_object (value, _gtk_icon_helper_peek_texture (priv->icon_helper));
-      break;
     case PROP_FILE:
       g_value_set_string (value, priv->filename);
       break;
@@ -553,33 +539,6 @@ gtk_image_new_from_paintable (GdkPaintable *paintable)
   return GTK_WIDGET (image);  
 }
 
-/**
- * gtk_image_new_from_texture:
- * @texture: (allow-none): a #GdkTexture, or %NULL
- *
- * Creates a new #GtkImage displaying @texture.
- * The #GtkImage does not assume a reference to the
- * texture; you still need to unref it if you own references.
- * #GtkImage will add its own reference rather than adopting yours.
- *
- * Note that this function just creates an #GtkImage from the texture. The
- * #GtkImage created will not react to state changes. Should you want that, 
- * you should use gtk_image_new_from_icon_name().
- * 
- * Returns: a new #GtkImage
- **/
-GtkWidget*
-gtk_image_new_from_texture (GdkTexture *texture)
-{
-  GtkImage *image;
-
-  image = g_object_new (GTK_TYPE_IMAGE, NULL);
-
-  gtk_image_set_from_texture (image, texture);
-
-  return GTK_WIDGET (image);  
-}
-
 /**
  * gtk_image_new_from_icon_name:
  * @icon_name: (nullable): an icon name or %NULL
@@ -878,9 +837,8 @@ gtk_image_set_from_resource (GtkImage    *image,
  *
  * See gtk_image_new_from_pixbuf() for details.
  *
- * Note: This is a helper for gtk_image_set_from_texture(), and you can't
- * get back the exact pixbuf once this is called, only a texture.
- *
+ * Note: This is a helper for gtk_image_set_from_paintable(), and you can't
+ * get back the exact pixbuf once this is called, only a paintable.
  **/
 void
 gtk_image_set_from_pixbuf (GtkImage  *image,
@@ -896,7 +854,7 @@ gtk_image_set_from_pixbuf (GtkImage  *image,
   else
     texture = NULL;
 
-  gtk_image_set_from_texture (image, texture);
+  gtk_image_set_from_paintable (image, GDK_PAINTABLE (texture));
 
   if (texture)
     g_object_unref (texture);
@@ -1028,40 +986,6 @@ gtk_image_set_from_paintable (GtkImage     *image,
   g_object_thaw_notify (G_OBJECT (image));
 }
 
-/**
- * gtk_image_set_from_texture:
- * @image: a #GtkImage
- * @texture: (nullable): a #GdkTexture or %NULL
- *
- * See gtk_image_new_from_texture() for details.
- **/
-void
-gtk_image_set_from_texture (GtkImage   *image,
-                           GdkTexture *texture)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  g_return_if_fail (GTK_IS_IMAGE (image));
-  g_return_if_fail (texture == NULL || GDK_IS_TEXTURE (texture));
-
-  g_object_freeze_notify (G_OBJECT (image));
-
-  if (texture)
-    g_object_ref (texture);
-
-  gtk_image_clear (image);
-
-  if (texture)
-    {
-      _gtk_icon_helper_set_texture (priv->icon_helper, texture);
-      g_object_unref (texture);
-    }
-
-  g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_TEXTURE]);
-  
-  g_object_thaw_notify (G_OBJECT (image));
-}
-
 /**
  * gtk_image_get_storage_type:
  * @image: a #GtkImage
@@ -1105,29 +1029,6 @@ gtk_image_get_paintable (GtkImage *image)
   return _gtk_icon_helper_peek_paintable (priv->icon_helper);
 }
 
-/**
- * gtk_image_get_texture:
- * @image: a #GtkImage
- *
- * Gets the image #GdkTexture being displayed by the #GtkImage.
- * The storage type of the image must be %GTK_IMAGE_EMPTY or
- * %GTK_IMAGE_TEXTURE (see gtk_image_get_storage_type()).
- * The caller of this function does not own a reference to the
- * returned texture.
- * 
- * Returns: (nullable) (transfer none): the displayed texture, or %NULL if
- *   the image is empty
- **/
-GdkTexture *
-gtk_image_get_texture (GtkImage *image)
-{
-  GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-
-  g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
-
-  return _gtk_icon_helper_peek_texture (priv->icon_helper);
-}
-
 /**
  * gtk_image_get_icon_name:
  * @image: a #GtkImage
@@ -1301,12 +1202,10 @@ gtk_image_notify_for_storage_type (GtkImage     *image,
     case GTK_IMAGE_GICON:
       g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_GICON]);
       break;
-    case GTK_IMAGE_TEXTURE:
-      g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_TEXTURE]);
-      break;
     case GTK_IMAGE_PAINTABLE:
       g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_PAINTABLE]);
       break;
+    case GTK_IMAGE_TEXTURE:
     case GTK_IMAGE_EMPTY:
     default:
       break;
index 6d5a8309b0db3c1364a8e21fbf0981f0f9edca41..f6f3db12a03394aa494de0fe41f3d562e3ac5e9d 100644 (file)
@@ -111,8 +111,6 @@ GtkWidget* gtk_image_new_from_resource  (const gchar     *resource_path);
 GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
 GDK_AVAILABLE_IN_ALL
-GtkWidget* gtk_image_new_from_texture   (GdkTexture      *texture);
-GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_image_new_from_paintable (GdkPaintable    *paintable);
 GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name);
@@ -131,9 +129,6 @@ GDK_AVAILABLE_IN_ALL
 void gtk_image_set_from_pixbuf    (GtkImage        *image,
                                    GdkPixbuf       *pixbuf);
 GDK_AVAILABLE_IN_ALL
-void gtk_image_set_from_texture   (GtkImage        *image,
-                                   GdkTexture      *texture);
-GDK_AVAILABLE_IN_ALL
 void gtk_image_set_from_paintable (GtkImage        *image,
                                    GdkPaintable    *paintable);
 GDK_AVAILABLE_IN_ALL
@@ -158,8 +153,6 @@ void gtk_image_set_can_shrink     (GtkImage        *image,
 GDK_AVAILABLE_IN_ALL
 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
 
-GDK_AVAILABLE_IN_ALL
-GdkTexture *gtk_image_get_texture  (GtkImage       *image);
 GDK_AVAILABLE_IN_ALL
 GdkPaintable *gtk_image_get_paintable (GtkImage       *image);
 
index f55c2cd6a21b02476ef51862af89f7a5770646c0..9ea5ff93a22ef0d3c11283f1665fc5776d0333c2 100644 (file)
@@ -884,7 +884,7 @@ node_property_activated (GtkTreeView *tv,
   popover = gtk_popover_new (GTK_WIDGET (tv));
   gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
 
-  image = gtk_image_new_from_texture (texture);
+  image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
   g_object_set (image, "margin", 20, NULL);
   gtk_container_add (GTK_CONTAINER (popover), image);
   gtk_popover_popup (GTK_POPOVER (popover));
index 298e0ec866e8e65efce18f5094b1127cad9bf70d..d4de840c5073e970e9bdaf4812d8a85af74df641 100644 (file)
@@ -197,7 +197,7 @@ main (int argc, char **argv)
       GdkWindow *gdk_window = gdk_window_new_toplevel (gdk_display_get_default(), 10 , 10);
       GskRenderer *renderer = gsk_renderer_new_for_window (gdk_window);
       GdkTexture *texture = gsk_renderer_render_texture (renderer, GTK_NODE_VIEW (nodeview)->node, NULL);
-      GtkWidget *image = gtk_image_new_from_texture (texture);
+      GtkWidget *image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
 
       gtk_container_add (GTK_CONTAINER (box), nodeview);
       gtk_container_add (GTK_CONTAINER (box), image);
index 5bbe112183de615edad95b9d02021dd470312a4b..86c0e5dc3f3904068d6995200a399b9c761c9cc1 100644 (file)
@@ -48,7 +48,7 @@ texture_loaded_cb (GObject      *clipboard,
       return;
     }
 
-  gtk_image_set_from_texture (data, texture);
+  gtk_image_set_from_paintable (data, GDK_PAINTABLE (texture));
   g_object_unref (texture);
 }
 
index 7fee35c7cc549722675aad4ca07ee84f5404acf1..f3916d4ee99de87b550d97361720935d5a7287a1 100644 (file)
@@ -1,13 +1,13 @@
 #include <gtk/gtk.h>
 
-static GdkTexture *
-get_image_texture (GtkImage *image,
-                   int      *out_size)
+static GdkPaintable *
+get_image_paintable (GtkImage *image,
+                    int      *out_size)
 {
   GtkIconTheme *icon_theme;
   const char *icon_name;
   int width = 48;
-  GdkTexture *texture;
+  GdkPaintable *paintable;
   GtkIconInfo *icon_info;
 
   switch (gtk_image_get_storage_type (image))
@@ -21,9 +21,9 @@ get_image_texture (GtkImage *image,
       icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
       *out_size = width;
       icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, width, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
-      texture = gtk_icon_info_load_texture (icon_info);
+      paintable = GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info));
       g_object_unref (icon_info);
-      return texture;
+      return paintable;
     default:
       g_warning ("Image storage type %d not handled",
                  gtk_image_get_storage_type (image));
@@ -42,12 +42,12 @@ image_drag_begin (GtkWidget      *widget,
                   GdkDragContext *context,
                   gpointer        data)
 {
-  GdkTexture *texture;
+  GdkPaintable *paintable;
   gint hotspot;
   gint hot_x, hot_y;
   gint size;
 
-  texture = get_image_texture (GTK_IMAGE (data), &size);
+  paintable = get_image_paintable (GTK_IMAGE (data), &size);
   hotspot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (data), "hotspot"));
   switch (hotspot)
     {
@@ -65,8 +65,8 @@ image_drag_begin (GtkWidget      *widget,
       hot_y = size;
       break;
     }
-  gtk_drag_set_icon_paintable (context, GDK_PAINTABLE (texture), hot_x, hot_y);
-  g_object_unref (texture);
+  gtk_drag_set_icon_paintable (context, paintable, hot_x, hot_y);
+  g_object_unref (paintable);
 }
 
 static void
@@ -93,7 +93,7 @@ window_drag_begin (GtkWidget      *widget,
                    GdkDragContext *context,
                    gpointer        data)
 {
-  GdkTexture *texture;
+  GdkPaintable *paintable;
   GtkWidget *image;
   int hotspot;
   int size;
@@ -104,9 +104,9 @@ window_drag_begin (GtkWidget      *widget,
   if (image == NULL)
     {
       g_print ("creating new drag widget\n");
-      texture = get_image_texture (GTK_IMAGE (data), &size);
-      image = gtk_image_new_from_texture (texture);
-      g_object_unref (texture);
+      paintable = get_image_paintable (GTK_IMAGE (data), &size);
+      image = gtk_image_new_from_paintable (paintable);
+      g_object_unref (paintable);
       g_object_ref (image);
       g_object_set_data (G_OBJECT (widget), "drag widget", image);
       g_signal_connect (image, "destroy", G_CALLBACK (drag_widget_destroyed), widget);
@@ -158,15 +158,17 @@ image_drag_data_get (GtkWidget        *widget,
                      guint             time,
                      gpointer          data)
 {
-  GdkTexture *texture;
+  GdkPaintable *paintable;
   const gchar *name;
   int size;
 
   if (gtk_selection_data_targets_include_image (selection_data, TRUE))
     {
-      texture = get_image_texture (GTK_IMAGE (data), &size);
-      gtk_selection_data_set_texture (selection_data, texture);
-      g_object_unref (texture);
+      paintable = get_image_paintable (GTK_IMAGE (data), &size);
+      if (GDK_IS_TEXTURE (paintable))
+        gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
+      if (paintable)
+        g_object_unref (paintable);
     }
   else if (gtk_selection_data_targets_include_text (selection_data))
     {
@@ -199,7 +201,7 @@ image_drag_data_received (GtkWidget        *widget,
       GdkTexture *texture;
 
       texture = gtk_selection_data_get_texture (selection_data);
-      gtk_image_set_from_texture (GTK_IMAGE (data), texture);
+      gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
 
       g_object_unref (texture);
     }
index ffe3b69ee7c7a2cdc8983991575a963ddd4c8402..2b222f9547a14de5c66c300771816c34700d5834 100644 (file)
@@ -24,10 +24,10 @@ drag_begin (GtkWidget      *widget,
            gpointer        data)
 {
   GtkWidget *image = GTK_WIDGET (data);
-  GdkTexture *texture;
+  GdkPaintable *paintable;
 
-  texture = gtk_image_get_texture (GTK_IMAGE (image));
-  gtk_drag_set_icon_paintable (context, GDK_PAINTABLE (texture), -2, -2);
+  paintable = gtk_image_get_paintable (GTK_IMAGE (image));
+  gtk_drag_set_icon_paintable (context, paintable, -2, -2);
 }
 
 void  
@@ -38,11 +38,11 @@ drag_data_get  (GtkWidget        *widget,
                gpointer          data)
 {
   GtkWidget *image = GTK_WIDGET (data);
-  GdkTexture *texture;
+  GdkPaintable *paintable;
 
-  texture = gtk_image_get_texture (GTK_IMAGE (image));
-  gtk_selection_data_set_texture (selection_data, texture);
-  g_object_unref (texture);
+  paintable = gtk_image_get_paintable (GTK_IMAGE (image));
+  if (GDK_IS_TEXTURE (paintable))
+    gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
 }
 
 static void
@@ -60,7 +60,7 @@ drag_data_received (GtkWidget        *widget,
     return;
 
   texture = gtk_selection_data_get_texture (selection_data);
-  gtk_image_set_from_texture (GTK_IMAGE (image), texture);
+  gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
 
   g_object_unref (texture);
 }
@@ -113,7 +113,7 @@ main (int argc, char **argv)
   icon_info = gtk_icon_theme_lookup_icon_for_scale (theme, icon_name, 48, gtk_widget_get_scale_factor (window), GTK_ICON_LOOKUP_GENERIC_FALLBACK);
   texture = gtk_icon_info_load_texture (icon_info);
   g_object_unref (icon_info);
-  image = gtk_image_new_from_texture (texture);
+  image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
   g_object_unref (texture);
   gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);