[libgfbgraph] photo: added a useful function to get the higher resolution image for a photo.



commit 42749a92806d1077ad6f025a476327626b74af76
Author: Álvaro Peña <alvaropg gmail com>
Date:   Mon Aug 26 19:23:21 2013 +0200

    photo: added a useful function to get the higher resolution image for a photo.

 gfbgraph/gfbgraph-photo.c |   33 +++++++++++++++++++++++++++++++++
 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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]