forked from AuroraMiddleware/gtk
icontheme: Return textures from load_icon{,_for_scale}
This commit is contained in:
parent
37f8e6aabd
commit
f3099afcc5
@ -128,18 +128,16 @@ insert_text (GtkTextBuffer *buffer)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
GtkTextIter start, end;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GtkIconTheme *icon_theme;
|
||||
|
||||
icon_theme = gtk_icon_theme_get_default ();
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme,
|
||||
"gtk3-demo",
|
||||
32,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
|
||||
NULL);
|
||||
g_assert (pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
texture = GDK_TEXTURE (gtk_icon_theme_load_icon (icon_theme,
|
||||
"gtk3-demo",
|
||||
32,
|
||||
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
|
||||
NULL));
|
||||
g_assert (texture);
|
||||
|
||||
/* get start of buffer; each insertion will revalidate the
|
||||
* iterator to point to just after the inserted text.
|
||||
@ -379,7 +377,6 @@ insert_text (GtkTextBuffer *buffer)
|
||||
gtk_text_buffer_get_bounds (buffer, &start, &end);
|
||||
gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,6 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
||||
* gdk_pixbuf_get_rowstride (pixbuf),
|
||||
g_object_unref,
|
||||
g_object_ref (pixbuf));
|
||||
|
||||
texture = gdk_memory_texture_new (gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
gdk_pixbuf_get_has_alpha (pixbuf)
|
||||
|
@ -2156,6 +2156,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
if (pixbuf == NULL)
|
||||
{
|
||||
GtkIconTheme *theme;
|
||||
GdkPaintable *texture;
|
||||
|
||||
g_warning ("Could not load image '%s': %s",
|
||||
string, tmp_error->message);
|
||||
@ -2163,11 +2164,13 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
|
||||
/* fall back to a missing image */
|
||||
theme = gtk_icon_theme_get_default ();
|
||||
pixbuf = gtk_icon_theme_load_icon (theme,
|
||||
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));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
if (pixbuf)
|
||||
|
@ -2264,7 +2264,7 @@ gtk_icon_theme_error_quark (void)
|
||||
* you must not modify the icon. Use g_object_unref() to release
|
||||
* your reference to the icon. %NULL if the icon isn’t found.
|
||||
*/
|
||||
GdkPixbuf *
|
||||
GdkPaintable *
|
||||
gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
@ -2311,7 +2311,7 @@ gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
|
||||
* you must not modify the icon. Use g_object_unref() to release
|
||||
* your reference to the icon. %NULL if the icon isn’t found.
|
||||
*/
|
||||
GdkPixbuf *
|
||||
GdkPaintable *
|
||||
gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
@ -2320,7 +2320,7 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
GError **error)
|
||||
{
|
||||
GtkIconInfo *icon_info;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
|
||||
g_return_val_if_fail (icon_name != NULL, NULL);
|
||||
@ -2338,11 +2338,11 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixbuf = gtk_icon_info_load_icon (icon_info, error);
|
||||
texture = gtk_icon_info_load_texture (icon_info, error);
|
||||
g_prefix_error (error, "Failed to load %s: ", icon_info->filename);
|
||||
g_object_unref (icon_info);
|
||||
|
||||
return pixbuf;
|
||||
return GDK_PAINTABLE (texture);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,13 +169,13 @@ GtkIconInfo * gtk_icon_theme_choose_icon_for_scale (GtkIconTheme
|
||||
gint scale,
|
||||
GtkIconLookupFlags flags);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPixbuf * gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
GtkIconLookupFlags flags,
|
||||
GError **error);
|
||||
GdkPaintable *gtk_icon_theme_load_icon (GtkIconTheme *icon_theme,
|
||||
const char *icon_name,
|
||||
int size,
|
||||
GtkIconLookupFlags flags,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkPixbuf * gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
GdkPaintable *gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
|
||||
const gchar *icon_name,
|
||||
gint size,
|
||||
gint scale,
|
||||
|
@ -93,7 +93,7 @@ main (int argc, char *argv[])
|
||||
if (strcmp (argv[1], "display") == 0)
|
||||
{
|
||||
GError *error;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPaintable *paintable;
|
||||
GtkWidget *window, *image;
|
||||
|
||||
if (argc < 4)
|
||||
@ -110,8 +110,8 @@ main (int argc, char *argv[])
|
||||
scale = atoi (argv[5]);
|
||||
|
||||
error = NULL;
|
||||
pixbuf = gtk_icon_theme_load_icon_for_scale (icon_theme, argv[3], size, scale, flags, &error);
|
||||
if (!pixbuf)
|
||||
paintable = gtk_icon_theme_load_icon_for_scale (icon_theme, argv[3], size, scale, flags, &error);
|
||||
if (!paintable)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
return 1;
|
||||
@ -119,8 +119,8 @@ main (int argc, char *argv[])
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
image = gtk_image_new ();
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (image), paintable);
|
||||
g_object_unref (paintable);
|
||||
gtk_container_add (GTK_CONTAINER (window), image);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
gtk_widget_show (window);
|
||||
|
Loading…
Reference in New Issue
Block a user