diff options
author | Richard Hughes <richard@hughsie.com> | 2014-05-13 16:42:31 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2014-05-13 16:42:31 +0100 |
commit | 2def4da5f807f3e9466c1d3f9d676bc3de4a4106 (patch) | |
tree | 7418a1a29c9d058f15002fa566dcaf706bc347dc /libappstream-glib/as-image.c | |
parent | ff2ce74ffcb02cef920d87a89dd079bb0875fedc (diff) | |
download | appstream-glib-2def4da5f807f3e9466c1d3f9d676bc3de4a4106.tar.gz |
Add as_image_set_pixbuf()
This allows us to store image data in the object directly.
Diffstat (limited to 'libappstream-glib/as-image.c')
-rw-r--r-- | libappstream-glib/as-image.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c index e18eee7..3642e8f 100644 --- a/libappstream-glib/as-image.c +++ b/libappstream-glib/as-image.c @@ -45,6 +45,7 @@ struct _AsImagePrivate gchar *url; guint width; guint height; + GdkPixbuf *pixbuf; }; G_DEFINE_TYPE_WITH_PRIVATE (AsImage, as_image, G_TYPE_OBJECT) @@ -60,6 +61,8 @@ as_image_finalize (GObject *object) AsImage *image = AS_IMAGE (object); AsImagePrivate *priv = GET_PRIVATE (image); + if (priv->pixbuf != NULL) + g_object_unref (priv->pixbuf); g_free (priv->url); G_OBJECT_CLASS (as_image_parent_class)->finalize (object); @@ -193,6 +196,23 @@ as_image_get_kind (AsImage *image) } /** + * as_image_get_pixbuf: + * @image: a #AsImage instance. + * + * Gets the image pixbuf if set. + * + * Returns: (transfer none): the #GdkPixbuf, or %NULL + * + * Since: 0.1.6 + **/ +GdkPixbuf * +as_image_get_pixbuf (AsImage *image) +{ + AsImagePrivate *priv = GET_PRIVATE (image); + return priv->pixbuf; +} + +/** * as_image_set_url: * @image: a #AsImage instance. * @url: the URL. @@ -259,6 +279,24 @@ as_image_set_kind (AsImage *image, AsImageKind kind) } /** + * as_image_set_pixbuf: + * @image: a #AsImage instance. + * @pixbuf: the #GdkPixbuf + * + * Sets the image pixbuf. + * + * Since: 0.1.6 + **/ +void +as_image_set_pixbuf (AsImage *image, GdkPixbuf *pixbuf) +{ + AsImagePrivate *priv = GET_PRIVATE (image); + if (priv->pixbuf != NULL) + g_object_unref (priv->pixbuf); + priv->pixbuf = g_object_ref (pixbuf); +} + +/** * as_image_node_insert: (skip) * @image: a #AsImage instance. * @parent: the parent #GNode to use.. |