diff options
author | Benjamin Otte <otte@redhat.com> | 2018-03-16 04:29:42 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-03-16 06:04:45 +0100 |
commit | cbe40f5f46d8358ec944b00037d73482d2d6b4a2 (patch) | |
tree | eccce9d4a465291f86afafcd35d498f3a4ab4726 /tests | |
parent | 2935ef81286e8b70e1e03cf1eeca4666834c8490 (diff) | |
download | gtk+-cbe40f5f46d8358ec944b00037d73482d2d6b4a2.tar.gz |
image: Remove gtk_image_set_texture()
gtk_image_get_paintable() is a perfect replacement, so use that one.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/showrendernode.c | 2 | ||||
-rw-r--r-- | tests/testclipboard2.c | 2 | ||||
-rw-r--r-- | tests/testdnd2.c | 40 | ||||
-rw-r--r-- | tests/testimage.c | 18 |
4 files changed, 32 insertions, 30 deletions
diff --git a/tests/showrendernode.c b/tests/showrendernode.c index 298e0ec866..d4de840c50 100644 --- a/tests/showrendernode.c +++ b/tests/showrendernode.c @@ -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); diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c index 5bbe112183..86c0e5dc3f 100644 --- a/tests/testclipboard2.c +++ b/tests/testclipboard2.c @@ -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); } diff --git a/tests/testdnd2.c b/tests/testdnd2.c index 7fee35c7cc..f3916d4ee9 100644 --- a/tests/testdnd2.c +++ b/tests/testdnd2.c @@ -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); } diff --git a/tests/testimage.c b/tests/testimage.c index ffe3b69ee7..2b222f9547 100644 --- a/tests/testimage.c +++ b/tests/testimage.c @@ -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); |