]> Pileus Git - ~andy/gtk/commitdiff
image: Make gtk_image_new_from_resource() load animations
authorBenjamin Otte <otte@redhat.com>
Wed, 30 Jan 2013 15:24:39 +0000 (16:24 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 1 Feb 2013 16:42:44 +0000 (17:42 +0100)
Requires new gdk-pixbuf APIs to load animations from resources.

configure.ac
gtk/gtkimage.c

index 6ccae17a904e72209eded23221074a954feaf5e2..6b9e4aca759a7ede95f6be32bcdf11e33acb1644 100644 (file)
@@ -46,7 +46,7 @@ m4_define([glib_required_version], [2.35.3])
 m4_define([pango_required_version], [1.32.4])
 m4_define([atk_required_version], [2.5.3])
 m4_define([cairo_required_version], [1.10.0])
-m4_define([gdk_pixbuf_required_version], [2.26.0])
+m4_define([gdk_pixbuf_required_version], [2.27.1])
 m4_define([introspection_required_version], [1.32.0])
 GLIB_REQUIRED_VERSION=glib_required_version
 PANGO_REQUIRED_VERSION=pango_required_version
index 5b0ae66f984de9b467f5d3673f986778181527ce..d373b51b709d81586f61af595b9504d836775b3e 100644 (file)
@@ -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));
 }