summaryrefslogtreecommitdiff
path: root/gtk/gtkimage.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-01-30 16:24:39 +0100
committerBenjamin Otte <otte@redhat.com>2013-02-01 17:42:44 +0100
commitd1c642d1f54e5b3045ffdd7e5fb2b24bf3cb18ec (patch)
tree5b6ae8f81ce6d5fe04afb606b5388e3cc3e6c0e5 /gtk/gtkimage.c
parenta4749d4f3a45a7f2643f1d266f7c78b09ab1c81e (diff)
downloadgtk+-d1c642d1f54e5b3045ffdd7e5fb2b24bf3cb18ec.tar.gz
image: Make gtk_image_new_from_resource() load animations
Requires new gdk-pixbuf APIs to load animations from resources.
Diffstat (limited to 'gtk/gtkimage.c')
-rw-r--r--gtk/gtkimage.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 5b0ae66f98..d373b51b70 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -815,8 +815,7 @@ gtk_image_set_from_resource (GtkImage *image,
const gchar *resource_path)
{
GtkImagePrivate *priv;
- GdkPixbuf *pixbuf = NULL;
- GInputStream *stream;
+ GdkPixbufAnimation *animation;
g_return_if_fail (GTK_IS_IMAGE (image));
@@ -832,14 +831,9 @@ gtk_image_set_from_resource (GtkImage *image,
return;
}
- stream = g_resources_open_stream (resource_path, 0, NULL);
- if (stream != NULL)
- {
- pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
- g_object_unref (stream);
- }
+ animation = gdk_pixbuf_animation_new_from_resource (resource_path, NULL);
- if (pixbuf == NULL)
+ if (animation == NULL)
{
gtk_image_set_from_stock (image,
GTK_STOCK_MISSING_IMAGE,
@@ -850,11 +844,14 @@ gtk_image_set_from_resource (GtkImage *image,
priv->resource_path = g_strdup (resource_path);
- gtk_image_set_from_pixbuf (image, pixbuf);
+ if (gdk_pixbuf_animation_is_static_image (animation))
+ gtk_image_set_from_pixbuf (image, gdk_pixbuf_animation_get_static_image (animation));
+ else
+ gtk_image_set_from_animation (image, animation);
g_object_notify (G_OBJECT (image), "resource");
- g_object_unref (pixbuf);
+ g_object_unref (animation);
g_object_thaw_notify (G_OBJECT (image));
}