mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 02:10:10 +00:00
image: Remove gtk_image_set_texture()
gtk_image_get_paintable() is a perfect replacement, so use that one.
This commit is contained in:
parent
2935ef8128
commit
cbe40f5f46
@ -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);
|
||||
}
|
||||
|
||||
|
@ -677,7 +677,7 @@
|
||||
<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>
|
||||
@ -734,7 +734,7 @@
|
||||
<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>
|
||||
@ -791,7 +791,7 @@
|
||||
<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>
|
||||
@ -861,7 +861,7 @@
|
||||
<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>
|
||||
@ -918,7 +918,7 @@
|
||||
<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>
|
||||
@ -975,7 +975,7 @@
|
||||
<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>
|
||||
@ -1032,7 +1032,7 @@
|
||||
<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>
|
||||
@ -1089,7 +1089,7 @@
|
||||
<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>
|
||||
@ -1159,7 +1159,7 @@
|
||||
<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>
|
||||
@ -1216,7 +1216,7 @@
|
||||
<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>
|
||||
@ -1273,7 +1273,7 @@
|
||||
<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>
|
||||
@ -1330,7 +1330,7 @@
|
||||
<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>
|
||||
@ -1400,7 +1400,7 @@
|
||||
<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>
|
||||
@ -1457,7 +1457,7 @@
|
||||
<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>
|
||||
@ -1514,7 +1514,7 @@
|
||||
<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>
|
||||
@ -1571,7 +1571,7 @@
|
||||
<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>
|
||||
@ -1628,7 +1628,7 @@
|
||||
<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>
|
||||
@ -1685,7 +1685,7 @@
|
||||
<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>
|
||||
@ -1742,7 +1742,7 @@
|
||||
<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>
|
||||
@ -1812,7 +1812,7 @@
|
||||
<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>
|
||||
@ -1869,7 +1869,7 @@
|
||||
<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>
|
||||
@ -1926,7 +1926,7 @@
|
||||
<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>
|
||||
@ -1983,7 +1983,7 @@
|
||||
<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>
|
||||
@ -2040,7 +2040,7 @@
|
||||
<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>
|
||||
@ -2097,7 +2097,7 @@
|
||||
<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>
|
||||
@ -2154,7 +2154,7 @@
|
||||
<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>
|
||||
@ -2211,7 +2211,7 @@
|
||||
<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>
|
||||
@ -2268,7 +2268,7 @@
|
||||
<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>
|
||||
@ -2325,7 +2325,7 @@
|
||||
<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>
|
||||
@ -2382,7 +2382,7 @@
|
||||
<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>
|
||||
@ -2439,7 +2439,7 @@
|
||||
<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>
|
||||
@ -2496,7 +2496,7 @@
|
||||
<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>
|
||||
@ -2553,7 +2553,7 @@
|
||||
<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>
|
||||
@ -2610,7 +2610,7 @@
|
||||
<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>
|
||||
@ -2680,7 +2680,7 @@
|
||||
<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>
|
||||
@ -2737,7 +2737,7 @@
|
||||
<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>
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
111
gtk/gtkimage.c
111
gtk/gtkimage.c
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user