[frogr] Improved comparison functions for groups and sets in FrogrPicture



commit b9e770bfc1d5177b6a475646559558650b57f9d6
Author: Mario Sanchez Prada <msanchez2 gnome org>
Date:   Thu Nov 8 13:25:05 2012 +0100

    Improved comparison functions for groups and sets in FrogrPicture

 src/frogr-picture.c |   29 ++++++++++++++---------------
 1 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/src/frogr-picture.c b/src/frogr-picture.c
index 3a0349f..12f1ecd 100644
--- a/src/frogr-picture.c
+++ b/src/frogr-picture.c
@@ -213,8 +213,8 @@ _compare_photosets (FrogrPhotoSet *photoset1, FrogrPhotoSet *photoset2)
 {
   const gchar *id1 = NULL;
   const gchar *id2 = NULL;
-  const gchar *title1 = NULL;
-  const gchar *title2 = NULL;
+  const gchar *local_id1 = NULL;
+  const gchar *local_id2 = NULL;
 
   g_return_val_if_fail (FROGR_IS_PHOTOSET (photoset1), 1);
   g_return_val_if_fail (FROGR_IS_PHOTOSET (photoset2), -1);
@@ -224,19 +224,18 @@ _compare_photosets (FrogrPhotoSet *photoset1, FrogrPhotoSet *photoset2)
 
   id1 = frogr_photoset_get_id (photoset1);
   id2 = frogr_photoset_get_id (photoset2);
-
   if (id1 != NULL && id2 != NULL)
     return g_strcmp0 (id1, id2);
 
-  title1 = frogr_photoset_get_title (photoset1);
-  if (title1 == NULL)
-    return 1;
+  local_id1 = frogr_photoset_get_local_id (photoset1);
+  local_id2 = frogr_photoset_get_local_id (photoset2);
+  if (local_id1 != NULL && local_id2 != NULL)
+    return g_strcmp0 (local_id1, local_id2);
 
-  title2 = frogr_photoset_get_title (photoset2);
-  if (title2 == NULL)
+  if (id1 != NULL)
+    return 1;
+  else
     return -1;
-
-  return g_utf8_collate (title1, title2);
 }
 
 static gint
@@ -252,14 +251,14 @@ _compare_groups (FrogrGroup *group1, FrogrGroup *group2)
     return 0;
 
   id1 = frogr_group_get_id (group1);
+  id2 = frogr_group_get_id (group2);
+  if (id1 != NULL && id2 != NULL)
+    return g_strcmp0 (id1, id2);
+
   if (id1 != NULL)
     return 1;
-
-  id2 = frogr_group_get_id (group2);
-  if (id2 != NULL)
+  else
     return -1;
-
-  return g_strcmp0 (id1, id2);
 }
 
 static JsonNode *



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