[frogr] Simplified frogr_picture_set_photosets|groups()



commit f99ce3547c7ed207082140339758c6cb705085c6
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Sat Aug 27 15:38:07 2011 +0200

    Simplified frogr_picture_set_photosets|groups()

 src/frogr-picture.c |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index 3de0136..32496b4 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -1058,9 +1058,6 @@ frogr_picture_get_photosets (FrogrPicture *self)
 void
 frogr_picture_set_photosets (FrogrPicture *self, GSList *photosets)
 {
-  GSList *new_list = NULL;
-  GSList *item = NULL;
-  FrogrPhotoSet *photoset = NULL;
   FrogrPicturePrivate *priv = NULL;
 
   g_return_if_fail(FROGR_IS_PICTURE(self));
@@ -1070,15 +1067,13 @@ frogr_picture_set_photosets (FrogrPicture *self, GSList *photosets)
   /* First remove all the previous sets list */
   g_slist_foreach (priv->photosets, (GFunc) g_object_unref, NULL);
   g_slist_free (priv->photosets);
-  priv->photosets = NULL;
 
-  for (item = photosets; item; item = g_slist_next (item))
+  priv->photosets = NULL;
+  if (photosets)
     {
-      photoset = FROGR_PHOTOSET (item->data);
-      new_list = g_slist_append (new_list, g_object_ref (photoset));
+      priv->photosets = g_slist_copy (photosets);
+      g_slist_foreach (priv->photosets, (GFunc) g_object_ref, NULL);
     }
-
-  priv->photosets = new_list;
 }
 
 void
@@ -1133,9 +1128,6 @@ frogr_picture_get_groups (FrogrPicture *self)
 void
 frogr_picture_set_groups (FrogrPicture *self, GSList *groups)
 {
-  GSList *new_list = NULL;
-  GSList *item = NULL;
-  FrogrGroup *group = NULL;
   FrogrPicturePrivate *priv = NULL;
 
   g_return_if_fail(FROGR_IS_PICTURE(self));
@@ -1145,15 +1137,13 @@ frogr_picture_set_groups (FrogrPicture *self, GSList *groups)
   /* First remove all the previous groups list */
   g_slist_foreach (priv->groups, (GFunc) g_object_unref, NULL);
   g_slist_free (priv->groups);
-  priv->groups = NULL;
 
-  for (item = groups; item; item = g_slist_next (item))
+  priv->groups = NULL;
+  if (groups)
     {
-      group = FROGR_GROUP (item->data);
-      new_list = g_slist_append (new_list, g_object_ref (group));
+      priv->groups = g_slist_copy (groups);
+      g_slist_foreach (priv->groups, (GFunc) g_object_ref, NULL);
     }
-
-  priv->groups = new_list;
 }
 
 void



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