diff options
author | Benjamin Otte <otte@redhat.com> | 2013-01-30 15:31:21 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-01-30 15:31:21 +0100 |
commit | 1b4919298dd7692e71a642ddf959359b344fc805 (patch) | |
tree | b72fdbcbd5d95444c554e432bc31076d8f1f47c1 | |
parent | c1de9561aded7f032edb08dc55e184f4159b4686 (diff) | |
download | gdk-pixbuf-1b4919298dd7692e71a642ddf959359b344fc805.tar.gz |
API: Add gdk_pixbuf_animation_new_from_resource()
-rw-r--r-- | docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt | 1 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-animation.c | 41 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-animation.h | 2 |
3 files changed, 44 insertions, 0 deletions
diff --git a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt index a78b53b5f..97085d2f0 100644 --- a/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt +++ b/docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt @@ -129,6 +129,7 @@ gdk_pixbuf_fill GdkPixbufAnimation GdkPixbufAnimationIter gdk_pixbuf_animation_new_from_file +gdk_pixbuf_animation_new_from_resource gdk_pixbuf_animation_new_from_stream gdk_pixbuf_animation_new_from_stream_async gdk_pixbuf_animation_new_from_stream_finish 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) |