PROP_CAPS_LOCK_WARNING,
PROP_PROGRESS_FRACTION,
PROP_PROGRESS_PULSE_STEP,
- PROP_SURFACE_PRIMARY,
- PROP_SURFACE_SECONDARY,
PROP_TEXTURE_PRIMARY,
PROP_TEXTURE_SECONDARY,
PROP_ICON_NAME_PRIMARY,
NULL,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- /**
- * GtkEntry:primary-icon-surface:
- *
- * A surface to use as the primary icon for the entry.
- *
- * Since: 2.16
- */
- entry_props[PROP_SURFACE_PRIMARY] =
- g_param_spec_boxed ("primary-icon-surface",
- P_("Primary surface"),
- P_("Primary surface for the entry"),
- CAIRO_GOBJECT_TYPE_SURFACE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
- /**
- * GtkEntry:secondary-icon-surface:
- *
- * An surface to use as the secondary icon for the entry.
- *
- * Since: 2.16
- */
- entry_props[PROP_SURFACE_SECONDARY] =
- g_param_spec_boxed ("secondary-icon-surface",
- P_("Secondary surface"),
- P_("Secondary surface for the entry"),
- CAIRO_GOBJECT_TYPE_SURFACE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
/**
* GtkEntry:primary-icon-texture:
*
gtk_entry_set_placeholder_text (entry, g_value_get_string (value));
break;
- case PROP_SURFACE_PRIMARY:
- gtk_entry_set_icon_from_surface (entry,
- GTK_ENTRY_ICON_PRIMARY,
- g_value_get_boxed (value));
- break;
-
- case PROP_SURFACE_SECONDARY:
- gtk_entry_set_icon_from_surface (entry,
- GTK_ENTRY_ICON_SECONDARY,
- g_value_get_boxed (value));
- break;
-
case PROP_TEXTURE_PRIMARY:
gtk_entry_set_icon_from_texture (entry,
GTK_ENTRY_ICON_PRIMARY,
g_value_set_string (value, gtk_entry_get_placeholder_text (entry));
break;
- case PROP_SURFACE_PRIMARY:
- g_value_set_boxed (value,
- gtk_entry_get_icon_surface (entry,
- GTK_ENTRY_ICON_PRIMARY));
- break;
-
- case PROP_SURFACE_SECONDARY:
- g_value_set_boxed (value,
- gtk_entry_get_icon_surface (entry,
- GTK_ENTRY_ICON_SECONDARY));
- break;
-
case PROP_TEXTURE_PRIMARY:
g_value_set_object (value,
gtk_entry_get_icon_texture (entry,
switch (storage_type)
{
- case GTK_IMAGE_SURFACE:
- g_object_notify_by_pspec (G_OBJECT (entry),
- entry_props[icon_pos == GTK_ENTRY_ICON_PRIMARY
- ? PROP_SURFACE_PRIMARY
- : PROP_SURFACE_SECONDARY]);
- break;
-
case GTK_IMAGE_TEXTURE:
g_object_notify_by_pspec (G_OBJECT (entry),
entry_props[icon_pos == GTK_ENTRY_ICON_PRIMARY
: PROP_GICON_SECONDARY]);
break;
+ case GTK_IMAGE_SURFACE:
case GTK_IMAGE_EMPTY:
default:
g_assert_not_reached ();
return entry->priv->xalign;
}
-/**
- * gtk_entry_set_icon_from_surface:
- * @entry: a #GtkEntry
- * @icon_pos: Icon position
- * @surface: (allow-none): An image #cairo_surface, or %NULL
- *
- * Sets the icon shown in the specified position using a image surface.
- *
- * If @surface is %NULL, no icon will be shown in the specified position.
- *
- * Since: 3.94
- */
-void
-gtk_entry_set_icon_from_surface (GtkEntry *entry,
- GtkEntryIconPosition icon_pos,
- cairo_surface_t *surface)
-{
- GtkEntryPrivate *priv;
- EntryIconInfo *icon_info;
-
- g_return_if_fail (GTK_IS_ENTRY (entry));
- g_return_if_fail (IS_VALID_ICON_POSITION (icon_pos));
-
- priv = entry->priv;
-
- if ((icon_info = priv->icons[icon_pos]) == NULL)
- icon_info = construct_icon_info (GTK_WIDGET (entry), icon_pos);
-
- g_object_freeze_notify (G_OBJECT (entry));
-
- if (surface)
- cairo_surface_reference (surface);
-
- if (surface)
- {
- gtk_image_set_from_surface (GTK_IMAGE (icon_info->widget), surface);
-
- if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
- {
- g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_SURFACE_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_SURFACE_SECONDARY]);
- g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_SECONDARY]);
- }
-
- cairo_surface_destroy (surface);
- }
- else
- gtk_entry_clear_icon (entry, icon_pos);
-
- if (gtk_widget_get_visible (GTK_WIDGET (entry)))
- gtk_widget_queue_resize (GTK_WIDGET (entry));
-
- g_object_thaw_notify (G_OBJECT (entry));
-}
-
/**
* gtk_entry_set_icon_from_texture:
* @entry: a #GtkEntry
return (!icon_info || !icon_info->nonactivatable);
}
-/**
- * gtk_entry_get_icon_surface:
- * @entry: A #GtkEntry
- * @icon_pos: Icon position
- *
- * Retrieves the image used for the icon.
- *
- * Unlike the other methods of setting and getting icon data, this
- * method will work regardless of whether the icon was set using a
- * #cairo_surface_t, a #GIcon or an icon name.
- *
- * Returns: (transfer none) (nullable): A #cairo_surface_t, or %NULL if no icon is
- * set for this position.
- *
- * Since: 3.94
- */
-cairo_surface_t *
-gtk_entry_get_icon_surface (GtkEntry *entry,
- GtkEntryIconPosition icon_pos)
-{
- GtkEntryPrivate *priv;
- EntryIconInfo *icon_info;
-
- g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
- g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL);
-
- priv = entry->priv;
-
- icon_info = priv->icons[icon_pos];
-
- if (!icon_info)
- return NULL;
-
- return gtk_image_get_surface (GTK_IMAGE (icon_info->widget));
-}
-
/**
* gtk_entry_get_icon_texture:
* @entry: A #GtkEntry
}
static void
-set_surface (GtkWidget *button,
+set_texture (GtkWidget *button,
GtkEntry *entry)
{
- GdkPixbuf *pixbuf;
- cairo_surface_t *surface;
+ GdkTexture *texture;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
- pixbuf = gdk_pixbuf_new_from_resource ("/org/gtk/libgtk/inspector/logo.png", NULL);
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, gtk_widget_get_window (button));
- g_object_unref (pixbuf);
-
- gtk_entry_set_icon_from_surface (entry, GTK_ENTRY_ICON_SECONDARY, surface);
- cairo_surface_destroy (surface);
+ texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/inspector/logo.png");
+ gtk_entry_set_icon_from_texture (entry, GTK_ENTRY_ICON_SECONDARY, texture);
+ g_object_unref (texture);
}
}
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button3), GTK_RADIO_BUTTON (button1));
g_signal_connect (button3, "toggled", G_CALLBACK (set_gicon), entry);
gtk_container_add (GTK_CONTAINER (box), button3);
- button4 = gtk_radio_button_new_with_label (NULL, "Surface");
+ button4 = gtk_radio_button_new_with_label (NULL, "Texture");
gtk_widget_set_valign (button4, GTK_ALIGN_START);
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button4), GTK_RADIO_BUTTON (button1));
- g_signal_connect (button4, "toggled", G_CALLBACK (set_surface), entry);
+ g_signal_connect (button4, "toggled", G_CALLBACK (set_texture), entry);
gtk_container_add (GTK_CONTAINER (box), button4);
label = gtk_label_new ("Emoji:");