GtkTextIter start, end;
GdkTexture *texture;
GtkIconTheme *icon_theme;
+ GtkIconInfo *icon;
icon_theme = gtk_icon_theme_get_default ();
- texture = GDK_TEXTURE (gtk_icon_theme_load_icon (icon_theme,
- "gtk3-demo",
- 32,
- GTK_ICON_LOOKUP_GENERIC_FALLBACK,
- NULL));
+ icon = gtk_icon_theme_lookup_icon (icon_theme,
+ "gtk3-demo",
+ 32,
+ GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+ texture = gtk_icon_info_download_texture (icon, NULL);
+ g_object_unref (icon);
g_assert (texture);
/* get start of buffer; each insertion will revalidate the
if (pixbuf == NULL)
{
GtkIconTheme *theme;
- GdkPaintable *texture;
+ GtkIconInfo *icon;
+ GdkTexture *texture;
g_warning ("Could not load image '%s': %s",
string, tmp_error->message);
/* fall back to a missing image */
theme = gtk_icon_theme_get_default ();
- texture = gtk_icon_theme_load_icon (theme,
- "image-missing",
- 16,
- GTK_ICON_LOOKUP_USE_BUILTIN,
- NULL);
- pixbuf = gdk_pixbuf_get_from_texture (GDK_TEXTURE (texture));
+
+ icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16,
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+ texture = gtk_icon_info_download_texture (icon, NULL);
+ pixbuf = gdk_pixbuf_get_from_texture (texture);
+ g_object_unref (icon);
g_object_unref (texture);
}
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (mount_operation->priv->dialog)),
GTK_CSS_PROPERTY_ICON_THEME));
info = gtk_icon_theme_lookup_icon (theme, "application-x-executable", 24, 0);
- texture = GDK_TEXTURE (gtk_icon_info_load_icon (info, NULL));
+ texture = gtk_icon_info_download_texture (info, NULL);
g_object_unref (info);
}
0);
if (info)
{
- GdkPaintable *paintable = gtk_icon_info_load_icon (info, NULL);
- if (paintable && GDK_IS_TEXTURE (paintable))
- list = g_list_insert_sorted (list, GDK_TEXTURE (paintable), (GCompareFunc) icon_size_compare);
+ GdkTexture *texture = gtk_icon_info_download_texture (info, NULL);
+ if (texture)
+ list = g_list_insert_sorted (list, texture, (GCompareFunc) icon_size_compare);
g_object_unref (info);
}
0xc9, 'g', 'a', 'l', 'i', 't', 0xe9, ',', ' ',
'F', 'r', 'a', 't', 'e', 'r', 'n', 'i', 't', 0xe9, 0 };
GtkWidget *box;
+ GtkIconInfo *icon;
+ GdkTexture *texture;
GValue value = G_VALUE_INIT;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
"Empty");
g_value_init (&value, GDK_TYPE_PIXBUF);
- g_value_take_object (&value, gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "utilities-terminal",
- 48, 0, NULL));
+ icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+ "utilities-terminal",
+ 48, 0);
+ texture = gtk_icon_info_download_texture (icon, NULL);
+ g_value_take_object (&value, gdk_pixbuf_get_from_texture (texture));
+ g_object_unref (texture);
+ g_object_unref (icon);
add_provider_button (box,
gdk_content_provider_new_for_value (&value),
clipboard,
#include <unistd.h>
#include <gtk/gtk.h>
-static GdkPaintable *
-get_image_paintable (GtkImage *image,
- int *out_size)
+static GdkTexture *
+get_image_texture (GtkImage *image,
+ int *out_size)
{
GtkIconTheme *icon_theme;
const char *icon_name;
int width = 48;
GdkPaintable *paintable;
+ GdkTexture *texture = NULL;
GtkIconInfo *icon_info;
switch (gtk_image_get_storage_type (image))
{
case GTK_IMAGE_PAINTABLE:
paintable = gtk_image_get_paintable (image);
- *out_size = gdk_paintable_get_intrinsic_width (paintable);
- return g_object_ref (paintable);
+ if (GDK_IS_TEXTURE (paintable))
+ {
+ *out_size = gdk_paintable_get_intrinsic_width (paintable);
+ texture = g_object_ref (GDK_TEXTURE (paintable));
+ }
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)));
*out_size = width;
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, width, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- paintable = gtk_icon_info_load_icon (icon_info, NULL);
+ if (icon_info)
+ texture = gtk_icon_info_download_texture (icon_info, NULL);
g_object_unref (icon_info);
- return paintable;
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
- return NULL;
}
+
+ return texture;
}
enum {
GtkSelectionData *selection_data,
gpointer data)
{
- GdkPaintable *paintable;
+ GdkTexture *texture;
const gchar *name;
int size;
if (gtk_selection_data_targets_include_image (selection_data, TRUE))
{
- 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);
+ texture = get_image_texture (GTK_IMAGE (data), &size);
+ if (texture)
+ {
+ gtk_selection_data_set_texture (selection_data, texture);
+ g_object_unref (texture);
+ }
}
else if (gtk_selection_data_targets_include_text (selection_data))
{
const char *icon_name,
int hotspot)
{
- GdkPaintable *paintable;
+ GtkIconInfo *icon;
int hot_x, hot_y;
int size = 48;
- paintable = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- icon_name, size, 0, NULL);
+ icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+ icon_name, size, 0);
switch (hotspot)
{
default:
hot_y = size;
break;
}
- gtk_drag_source_set_icon (source, paintable, hot_x, hot_y);
- g_object_unref (paintable);
+ gtk_drag_source_set_icon (source, GDK_PAINTABLE (icon), hot_x, hot_y);
+ g_object_unref (icon);
}
static GBytes *
else if (strcmp (mimetype, "image/png") == 0)
{
int size;
- GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (image), &size);
- if (GDK_IS_TEXTURE (paintable))
+ GdkTexture *texture = get_image_texture (GTK_IMAGE (image), &size);
+ if (texture)
{
char *name = g_strdup ("drag-data-XXXXXX");
int fd;
fd = g_mkstemp (name);
close (fd);
- gdk_texture_save_to_png (GDK_TEXTURE (paintable), name);
+ gdk_texture_save_to_png (texture, name);
+ g_object_unref (texture);
g_file_get_contents (name, &data, &size, NULL);
g_free (name);
return g_bytes_new_take (data, size);
}
-
- g_clear_object (&paintable);
}
return NULL;
}
GdkTexture *texture;
GError *error = NULL;
- texture = GDK_TEXTURE (gtk_icon_info_load_icon (info, &error));
+ texture = gtk_icon_info_download_texture (info, &error);
g_assert_no_error (error);
g_assert_cmpint (gdk_texture_get_width (texture), ==, pixbuf_size);
g_object_unref (texture);