diff options
author | Álvaro Peña <alvaropg@gmail.com> | 2013-08-26 19:23:21 +0200 |
---|---|---|
committer | Álvaro Peña <alvaropg@gmail.com> | 2013-08-26 19:23:21 +0200 |
commit | 42749a92806d1077ad6f025a476327626b74af76 (patch) | |
tree | 3cba4515bbc38a8ea2a8cfc5f469dcd651fe4ee1 | |
parent | c7d3286d369bd4e0326b2d065643f86a2966cf93 (diff) | |
download | libgfbgraph-42749a92806d1077ad6f025a476327626b74af76.tar.gz |
photo: added a useful function to get the higher resolution image for a photo.
-rw-r--r-- | gfbgraph/gfbgraph-photo.c | 33 | ||||
-rw-r--r-- | gfbgraph/gfbgraph-photo.h | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gfbgraph/gfbgraph-photo.c b/gfbgraph/gfbgraph-photo.c index 1a26836..6b29841 100644 --- a/gfbgraph/gfbgraph-photo.c +++ b/gfbgraph/gfbgraph-photo.c @@ -52,6 +52,7 @@ struct _GFBGraphPhotoPrivate { guint width; guint height; GList *images; + GFBGraphPhotoImage *hires_image; }; static void gfbgraph_photo_init (GFBGraphPhoto *obj); @@ -513,3 +514,35 @@ gfbgraph_photo_get_images (GFBGraphPhoto *photo) return photo->priv->images; } +/** + * gfbgraph_photo_get_image_hires: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): a #GFBGraphPhotoImage with the higher resolution available of the photo + **/ +GFBGraphPhotoImage* +gfbgraph_photo_get_image_hires (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + if (photo->priv->hires_image == NULL) { + GList *images_list; + guint bigger_width; + GFBGraphPhotoImage *photo_image; + + bigger_width = 0; + images_list = photo->priv->images; + while (images_list) { + photo_image = (GFBGraphPhotoImage *) images_list->data; + if (photo_image->width > bigger_width) { + photo->priv->hires_image = photo_image; + bigger_width = photo_image->width; + } + + images_list = g_list_next (images_list); + } + } + + return photo->priv->hires_image; +} + diff --git a/gfbgraph/gfbgraph-photo.h b/gfbgraph/gfbgraph-photo.h index 1224d3a..73e474e 100644 --- a/gfbgraph/gfbgraph-photo.h +++ b/gfbgraph/gfbgraph-photo.h @@ -65,6 +65,7 @@ const gchar* gfbgraph_photo_get_default_source_uri (GFBGraphPhoto *photo) guint gfbgraph_photo_get_default_width (GFBGraphPhoto *photo); guint gfbgraph_photo_get_default_height (GFBGraphPhoto *photo); GList* gfbgraph_photo_get_images (GFBGraphPhoto *photo); +GFBGraphPhotoImage* gfbgraph_photo_get_image_hires (GFBGraphPhoto *photo); G_END_DECLS |