summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-01-30 15:31:21 +0100
committerBenjamin Otte <otte@redhat.com>2013-01-30 15:31:21 +0100
commit1b4919298dd7692e71a642ddf959359b344fc805 (patch)
treeb72fdbcbd5d95444c554e432bc31076d8f1f47c1 /gdk-pixbuf
parentc1de9561aded7f032edb08dc55e184f4159b4686 (diff)
downloadgdk-pixbuf-1b4919298dd7692e71a642ddf959359b344fc805.tar.gz
API: Add gdk_pixbuf_animation_new_from_resource()
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/gdk-pixbuf-animation.c41
-rw-r--r--gdk-pixbuf/gdk-pixbuf-animation.h2
2 files changed, 43 insertions, 0 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c
index b3f9a646d..9831a1872 100644
--- a/gdk-pixbuf/gdk-pixbuf-animation.c
+++ b/gdk-pixbuf/gdk-pixbuf-animation.c
@@ -478,6 +478,47 @@ gdk_pixbuf_animation_new_from_stream_finish (GAsyncResult *async_result,
}
/**
+ * gdk_pixbuf_animation_new_from_resource:
+ * @resource_path: the path of the resource file
+ * @error: Return location for an error
+ *
+ * Creates a new pixbuf animation by loading an image from an resource.
+ *
+ * The file format is detected automatically. If %NULL is returned, then
+ * @error will be set.
+ *
+ * Return value: A newly-created animation, or %NULL if any of several error
+ * conditions occurred: the file could not be opened, the image format is
+ * not supported, there was not enough memory to allocate the image buffer,
+ * the stream contained invalid data, or the operation was cancelled.
+ *
+ * Since: 2.28
+ **/
+GdkPixbufAnimation *
+gdk_pixbuf_animation_new_from_resource (const char *resource_path,
+ GError **error)
+{
+ GInputStream *stream;
+ GdkPixbufAnimation *anim;
+ GdkPixbuf *pixbuf;
+
+ pixbuf = _gdk_pixbuf_new_from_resource_try_mmap (resource_path);
+ if (pixbuf) {
+ anim = gdk_pixbuf_non_anim_new (pixbuf);
+ g_object_unref (pixbuf);
+ return anim;
+ }
+
+ stream = g_resources_open_stream (resource_path, 0, error);
+ if (stream == NULL)
+ return NULL;
+
+ anim = gdk_pixbuf_animation_new_from_stream (stream, NULL, error);
+ g_object_unref (stream);
+ return anim;
+}
+
+/**
* gdk_pixbuf_animation_ref: (skip)
* @animation: An animation.
*
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.h b/gdk-pixbuf/gdk-pixbuf-animation.h
index 63d476ef7..3e6814631 100644
--- a/gdk-pixbuf/gdk-pixbuf-animation.h
+++ b/gdk-pixbuf/gdk-pixbuf-animation.h
@@ -81,6 +81,8 @@ void gdk_pixbuf_animation_new_from_stream_async (GInputStream *st
gpointer user_data);
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_stream_finish (GAsyncResult*async_result,
GError **error);
+GdkPixbufAnimation *gdk_pixbuf_animation_new_from_resource(const char *resource_path,
+ GError **error);
#ifndef GDK_PIXBUF_DISABLE_DEPRECATED
G_DEPRECATED_FOR(g_object_ref)