entry: Make icons a paintable
authorBenjamin Otte <otte@redhat.com>
Fri, 16 Mar 2018 02:32:05 +0000 (03:32 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 16 Mar 2018 05:04:44 +0000 (06:04 +0100)
docs/reference/gtk/gtk4-sections.txt
gtk/gtkentry.c
gtk/gtkentry.h
tests/testentryicons.c

index f1a23656d7319d9e6167767f257468fe3a9e4589..ac5712e37c567840f15ac1feb64ee2ae559f7316 100644 (file)
@@ -912,11 +912,11 @@ gtk_entry_reset_im_context
 gtk_entry_set_tabs
 gtk_entry_get_tabs
 GtkEntryIconPosition
-gtk_entry_set_icon_from_texture
+gtk_entry_set_icon_from_paintable
 gtk_entry_set_icon_from_icon_name
 gtk_entry_set_icon_from_gicon
 gtk_entry_get_icon_storage_type
-gtk_entry_get_icon_texture
+gtk_entry_get_icon_paintable
 gtk_entry_get_icon_name
 gtk_entry_get_icon_gicon
 gtk_entry_set_icon_activatable
index 1275820484fd9adc2aff5ef63dd68360d4d0324a..04562afbf24ff9cbf1d5ce104b38d577f2649396 100644 (file)
  * icons can be activatable by clicking, can be set up as drag source and
  * can have tooltips. To add an icon, use gtk_entry_set_icon_from_gicon() or
  * one of the various other functions that set an icon from an icon name or a
- * texture. To trigger an action when the user clicks an icon,
+ * paintable. To trigger an action when the user clicks an icon,
  * connect to the #GtkEntry::icon-press signal. To allow DND operations
  * from an icon, use gtk_entry_set_icon_drag_source(). To set a tooltip on
  * an icon, use gtk_entry_set_icon_tooltip_text() or the corresponding function
@@ -345,8 +345,8 @@ enum {
   PROP_CAPS_LOCK_WARNING,
   PROP_PROGRESS_FRACTION,
   PROP_PROGRESS_PULSE_STEP,
-  PROP_TEXTURE_PRIMARY,
-  PROP_TEXTURE_SECONDARY,
+  PROP_PAINTABLE_PRIMARY,
+  PROP_PAINTABLE_SECONDARY,
   PROP_ICON_NAME_PRIMARY,
   PROP_ICON_NAME_SECONDARY,
   PROP_GICON_PRIMARY,
@@ -1063,27 +1063,27 @@ gtk_entry_class_init (GtkEntryClass *class)
                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
    /**
-   * GtkEntry:primary-icon-texture:
+   * GtkEntry:primary-icon-paintable:
    *
-   * A #GdkTexture to use as the primary icon for the entry.
+   * A #GdkPaintable to use as the primary icon for the entry.
    */
-  entry_props[PROP_TEXTURE_PRIMARY] =
-      g_param_spec_object ("primary-icon-texture",
-                           P_("Primary texture"),
-                           P_("Primary texture for the entry"),
-                           GDK_TYPE_TEXTURE,
+  entry_props[PROP_PAINTABLE_PRIMARY] =
+      g_param_spec_object ("primary-icon-paintable",
+                           P_("Primary paintable"),
+                           P_("Primary paintable for the entry"),
+                           GDK_TYPE_PAINTABLE,
                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
   /**
-   * GtkEntry:secondary-icon-texture:
+   * GtkEntry:secondary-icon-paintable:
    *
-   * A #GtkTexture to use as the secondary icon for the entry.
+   * A #GdkPaintable to use as the secondary icon for the entry.
    */
-  entry_props[PROP_TEXTURE_SECONDARY] =
-      g_param_spec_object ("secondary-icon-texture",
-                           P_("Secondary texture"),
-                           P_("Secondary texture for the entry"),
-                           GDK_TYPE_TEXTURE,
+  entry_props[PROP_PAINTABLE_SECONDARY] =
+      g_param_spec_object ("secondary-icon-paintable",
+                           P_("Secondary paintable"),
+                           P_("Secondary paintable for the entry"),
+                           GDK_TYPE_PAINTABLE,
                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
   /**
@@ -2056,16 +2056,16 @@ gtk_entry_set_property (GObject         *object,
       gtk_entry_set_placeholder_text (entry, g_value_get_string (value));
       break;
 
-    case PROP_TEXTURE_PRIMARY:
-      gtk_entry_set_icon_from_texture (entry,
-                                       GTK_ENTRY_ICON_PRIMARY,
-                                       g_value_get_object (value));
+    case PROP_PAINTABLE_PRIMARY:
+      gtk_entry_set_icon_from_paintable (entry,
+                                         GTK_ENTRY_ICON_PRIMARY,
+                                         g_value_get_object (value));
       break;
 
-    case PROP_TEXTURE_SECONDARY:
-      gtk_entry_set_icon_from_texture (entry,
-                                       GTK_ENTRY_ICON_SECONDARY,
-                                       g_value_get_object (value));
+    case PROP_PAINTABLE_SECONDARY:
+      gtk_entry_set_icon_from_paintable (entry,
+                                         GTK_ENTRY_ICON_SECONDARY,
+                                         g_value_get_object (value));
       break;
 
     case PROP_ICON_NAME_PRIMARY:
@@ -2299,16 +2299,16 @@ gtk_entry_get_property (GObject         *object,
       g_value_set_string (value, gtk_entry_get_placeholder_text (entry));
       break;
 
-    case PROP_TEXTURE_PRIMARY:
+    case PROP_PAINTABLE_PRIMARY:
       g_value_set_object (value,
-                          gtk_entry_get_icon_texture (entry,
-                                                      GTK_ENTRY_ICON_PRIMARY));
+                          gtk_entry_get_icon_paintable (entry,
+                                                        GTK_ENTRY_ICON_PRIMARY));
       break;
 
-    case PROP_TEXTURE_SECONDARY:
+    case PROP_PAINTABLE_SECONDARY:
       g_value_set_object (value,
-                          gtk_entry_get_icon_texture (entry,
-                                                      GTK_ENTRY_ICON_SECONDARY));
+                          gtk_entry_get_icon_paintable (entry,
+                                                        GTK_ENTRY_ICON_SECONDARY));
       break;
 
     case PROP_ICON_NAME_PRIMARY:
@@ -2698,9 +2698,9 @@ gtk_entry_dispose (GObject *object)
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
   GdkKeymap *keymap;
 
-  gtk_entry_set_icon_from_texture (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
+  gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
   gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
-  gtk_entry_set_icon_from_texture (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
+  gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
   gtk_entry_set_icon_tooltip_markup (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
   gtk_entry_set_completion (entry, NULL);
 
@@ -6534,11 +6534,11 @@ gtk_entry_clear_icon (GtkEntry             *entry,
 
   switch (storage_type)
     {
-    case GTK_IMAGE_TEXTURE:
+    case GTK_IMAGE_PAINTABLE:
       g_object_notify_by_pspec (G_OBJECT (entry),
                                 entry_props[icon_pos == GTK_ENTRY_ICON_PRIMARY
-                                            ? PROP_TEXTURE_PRIMARY
-                                            : PROP_TEXTURE_SECONDARY]);
+                                            ? PROP_PAINTABLE_PRIMARY
+                                            : PROP_PAINTABLE_SECONDARY]);
       break;
 
     case GTK_IMAGE_ICON_NAME:
@@ -6556,7 +6556,7 @@ gtk_entry_clear_icon (GtkEntry             *entry,
       break;
 
     case GTK_IMAGE_SURFACE:
-    case GTK_IMAGE_PAINTABLE:
+    case GTK_IMAGE_TEXTURE:
     case GTK_IMAGE_EMPTY:
     default:
       g_assert_not_reached ();
@@ -7380,19 +7380,19 @@ gtk_entry_get_alignment (GtkEntry *entry)
 }
 
 /**
- * gtk_entry_set_icon_from_texture:
+ * gtk_entry_set_icon_from_paintable:
  * @entry: a #GtkEntry
  * @icon_pos: Icon position
- * @texture: (allow-none): A #GdkTexture, or %NULL
+ * @paintable: (allow-none): A #GdkPaintable, or %NULL
  *
- * Sets the icon shown in the specified position using a #GdkTexture
+ * Sets the icon shown in the specified position using a #GdkPaintable
  *
- * If @texture is %NULL, no icon will be shown in the specified position.
+ * If @paintable is %NULL, no icon will be shown in the specified position.
  */
 void
-gtk_entry_set_icon_from_texture (GtkEntry             *entry,
+gtk_entry_set_icon_from_paintable (GtkEntry             *entry,
                                  GtkEntryIconPosition  icon_pos,
-                                 GdkTexture           *texture)
+                                 GdkPaintable           *paintable)
 {
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
   EntryIconInfo *icon_info;
@@ -7405,24 +7405,24 @@ gtk_entry_set_icon_from_texture (GtkEntry             *entry,
 
   g_object_freeze_notify (G_OBJECT (entry));
 
-  if (texture)
+  if (paintable)
     {
-      g_object_ref (texture);
+      g_object_ref (paintable);
 
-      gtk_image_set_from_texture (GTK_IMAGE (icon_info->widget), texture);
+      gtk_image_set_from_paintable (GTK_IMAGE (icon_info->widget), paintable);
 
       if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
         {
-          g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_TEXTURE_PRIMARY]);
+          g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_PAINTABLE_PRIMARY]);
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_PRIMARY]);
         }
       else
         {
-          g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_TEXTURE_SECONDARY]);
+          g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_PAINTABLE_SECONDARY]);
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_SECONDARY]);
         }
 
-      g_object_unref (texture);
+      g_object_unref (paintable);
     }
   else
     gtk_entry_clear_icon (entry, icon_pos);
@@ -7601,20 +7601,20 @@ gtk_entry_get_icon_activatable (GtkEntry             *entry,
 }
 
 /**
- * gtk_entry_get_icon_texture:
+ * gtk_entry_get_icon_paintable:
  * @entry: A #GtkEntry
  * @icon_pos: Icon position
  *
- * Retrieves the #GdkTexture used for the icon.
+ * Retrieves the #GdkPaintable used for the icon.
  *
- * If no #GdkTexture was used for the icon, %NULL is returned.
+ * If no #GdkPaintable was used for the icon, %NULL is returned.
  *
- * Returns: (transfer none) (nullable): A #GdkTexture, or %NULL if no icon is
- *     set for this position or the icon set is not a #GdkTexture.
+ * Returns: (transfer none) (nullable): A #GdkPaintable, or %NULL if no icon is
+ *     set for this position or the icon set is not a #GdkPaintable.
  */
-GdkTexture *
-gtk_entry_get_icon_texture (GtkEntry             *entry,
-                            GtkEntryIconPosition  icon_pos)
+GdkPaintable *
+gtk_entry_get_icon_paintable (GtkEntry             *entry,
+                              GtkEntryIconPosition  icon_pos)
 {
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
   EntryIconInfo *icon_info;
@@ -7627,7 +7627,7 @@ gtk_entry_get_icon_texture (GtkEntry             *entry,
   if (!icon_info)
     return NULL;
 
-  return gtk_image_get_texture (GTK_IMAGE (icon_info->widget));
+  return gtk_image_get_paintable (GTK_IMAGE (icon_info->widget));
 }
 
 /**
@@ -7637,7 +7637,7 @@ gtk_entry_get_icon_texture (GtkEntry             *entry,
  *
  * Retrieves the #GIcon used for the icon, or %NULL if there is
  * no icon or if the icon was set by some other method (e.g., by
- * texture or icon name).
+ * paintable or icon name).
  *
  * Returns: (transfer none) (nullable): A #GIcon, or %NULL if no icon is set
  *     or if the icon is not a #GIcon
@@ -7667,7 +7667,7 @@ gtk_entry_get_icon_gicon (GtkEntry             *entry,
  *
  * Retrieves the icon name used for the icon, or %NULL if there is
  * no icon or if the icon was set by some other method (e.g., by
- * texture or gicon).
+ * paintable or gicon).
  *
  * Returns: (nullable): An icon name, or %NULL if no icon is set or if the icon
  *          wasn’t set from an icon name
index a3397e60e5d552110e8856aeb8d800b34174b3fd..b44c00a5ac9be4a64f7b544925a52172cfa92c0e 100644 (file)
@@ -272,9 +272,9 @@ void           gtk_entry_set_placeholder_text    (GtkEntry             *entry,
 /* Setting and managing icons
  */
 GDK_AVAILABLE_IN_ALL
-void           gtk_entry_set_icon_from_texture           (GtkEntry             *entry,
+void           gtk_entry_set_icon_from_paintable         (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos,
-                                                         GdkTexture           *texture);
+                                                         GdkPaintable         *paintable);
 GDK_AVAILABLE_IN_ALL
 void           gtk_entry_set_icon_from_icon_name         (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos,
@@ -287,7 +287,7 @@ GDK_AVAILABLE_IN_ALL
 GtkImageType   gtk_entry_get_icon_storage_type           (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos);
 GDK_AVAILABLE_IN_ALL
-GdkTexture *   gtk_entry_get_icon_texture                (GtkEntry             *entry,
+GdkPaintable * gtk_entry_get_icon_paintable              (GtkEntry             *entry,
                                                          GtkEntryIconPosition  icon_pos);
 GDK_AVAILABLE_IN_ALL
 const gchar* gtk_entry_get_icon_name                     (GtkEntry             *entry,
index 59d4d3eec6866aee95120324d4f63831371196b1..48e6df2c5c2179ee45915ca78acbcda0bde21ce4 100644 (file)
@@ -87,7 +87,7 @@ set_texture (GtkWidget *button,
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
     {
       texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/inspector/logo.png");
-      gtk_entry_set_icon_from_texture (entry, GTK_ENTRY_ICON_SECONDARY, texture);
+      gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, GDK_PAINTABLE (texture));
       g_object_unref (texture);
     }
 }