[frogr] Replaced 'direction' with 'reversed' for sorting pictures.



commit b024f16b07c01c12f5f23cb9191b4f57a238094d
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Mon Apr 25 22:19:38 2011 -0700

    Replaced 'direction' with 'reversed' for sorting pictures.

 src/frogr-config.c    |   24 ++++++++++--------------
 src/frogr-config.h    |   11 ++---------
 src/frogr-main-view.c |   38 +++++++++++---------------------------
 3 files changed, 23 insertions(+), 50 deletions(-)
---
diff --git a/src/frogr-config.c b/src/frogr-config.c
index 1efe603..01dd661 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -61,7 +61,7 @@ struct _FrogrConfigPrivate
   gboolean tags_autocompletion;
   gboolean remove_file_extensions;
   SortingCriteria mainview_sorting_criteria;
-  SortingDirection mainview_sorting_direction;
+  gboolean mainview_sorting_reversed;
   gboolean mainview_enable_tooltips;
 
   gboolean use_proxy;
@@ -365,13 +365,10 @@ _load_mainview_sorting_pictures_xml (FrogrConfig *self,
             priv->mainview_sorting_criteria = SORT_AS_LOADED;
         }
 
-      if (!xmlStrcmp (node->name, (const xmlChar*) "direction"))
+      if (!xmlStrcmp (node->name, (const xmlChar*) "reversed"))
         {
           content = xmlNodeGetContent (node);
-          if (!xmlStrcmp (content, (const xmlChar*) "1"))
-            priv->mainview_sorting_direction = SORT_DESCENDING;
-          else
-            priv->mainview_sorting_direction = SORT_ASCENDING;
+          priv->mainview_sorting_reversed = !xmlStrcmp (content, (const xmlChar*) "1");
         }
 
       if (content)
@@ -623,7 +620,7 @@ _save_settings (FrogrConfig *self)
 
   node = xmlNewNode (NULL, (const xmlChar*) "mainview-sorting-pictures");
   _xml_add_int_child (node, "criteria", priv->mainview_sorting_criteria);
-  _xml_add_int_child (node, "direction", priv->mainview_sorting_direction);
+  _xml_add_bool_child (node, "reversed", priv->mainview_sorting_reversed);
   xmlAddChild (root, node);
 
 
@@ -879,7 +876,7 @@ frogr_config_init (FrogrConfig *self)
   priv->tags_autocompletion = TRUE;
   priv->remove_file_extensions = TRUE;
   priv->mainview_sorting_criteria = SORT_AS_LOADED;
-  priv->mainview_sorting_direction = SORT_ASCENDING;
+  priv->mainview_sorting_reversed = FALSE;
   priv->mainview_enable_tooltips = TRUE;
   priv->use_proxy = FALSE;
   priv->proxy_host = NULL;
@@ -1217,22 +1214,21 @@ frogr_config_get_mainview_sorting_criteria (FrogrConfig *self)
 }
 
 void
-frogr_config_set_mainview_sorting_direction (FrogrConfig *self,
-                                            SortingDirection direction)
+frogr_config_set_mainview_sorting_reversed (FrogrConfig *self, gboolean reversed)
 {
   g_return_if_fail (FROGR_IS_CONFIG (self));
 
   FrogrConfigPrivate * priv = FROGR_CONFIG_GET_PRIVATE (self);
-  priv->mainview_sorting_direction = direction;
+  priv->mainview_sorting_reversed = reversed;
 }
 
-SortingDirection
-frogr_config_get_mainview_sorting_direction (FrogrConfig *self)
+gboolean
+frogr_config_get_mainview_sorting_reversed (FrogrConfig *self)
 {
   g_return_val_if_fail (FROGR_IS_CONFIG (self), SORT_AS_LOADED);
 
   FrogrConfigPrivate * priv = FROGR_CONFIG_GET_PRIVATE (self);
-  return priv->mainview_sorting_direction;
+  return priv->mainview_sorting_reversed;
 }
 
 void
diff --git a/src/frogr-config.h b/src/frogr-config.h
index aa84665..9825ae0 100644
--- a/src/frogr-config.h
+++ b/src/frogr-config.h
@@ -63,11 +63,6 @@ typedef enum {
   SORT_BY_DATE
 } SortingCriteria;
 
-typedef enum {
-  SORT_ASCENDING,
-  SORT_DESCENDING,
-} SortingDirection;
-
 FrogrConfig* frogr_config_get_instance (void);
 
 gboolean frogr_config_save_all (FrogrConfig *self);
@@ -130,11 +125,9 @@ void frogr_config_set_mainview_sorting_criteria (FrogrConfig *self,
 
 SortingCriteria frogr_config_get_mainview_sorting_criteria (FrogrConfig *self);
 
+void frogr_config_set_mainview_sorting_reversed (FrogrConfig *self, gboolean reversed);
 
-void frogr_config_set_mainview_sorting_direction (FrogrConfig *self,
-                                                  SortingDirection direction);
-
-SortingDirection frogr_config_get_mainview_sorting_direction (FrogrConfig *self);
+gboolean frogr_config_get_mainview_sorting_reversed (FrogrConfig *self);
 
 void frogr_config_set_use_proxy (FrogrConfig *self, gboolean value);
 
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index dac574b..51a6234 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -71,7 +71,7 @@ typedef struct _FrogrMainViewPrivate {
 
   FrogrConfig *config;
   SortingCriteria sorting_criteria;
-  SortingDirection sorting_direction;
+  gboolean sorting_reversed;
   gboolean tooltips_enabled;
 
   GtkWindow *window;
@@ -188,7 +188,7 @@ static void _edit_selected_pictures (FrogrMainView *self);
 static void _remove_selected_pictures (FrogrMainView *self);
 static void _load_pictures (FrogrMainView *self, GSList *fileuris);
 static void _upload_pictures (FrogrMainView *self);
-static void _reorder_pictures (FrogrMainView *self, SortingCriteria criteria, SortingDirection direction);
+static void _reorder_pictures (FrogrMainView *self, SortingCriteria criteria, gboolean reversed);
 
 static void _progress_dialog_response (GtkDialog *dialog,
                                        gint response_id,
@@ -438,7 +438,7 @@ _populate_menu_bar (FrogrMainView *self)
                     self);
   priv->sort_reversed_menu_item = menu_item;
 
-  if (priv->sorting_direction == SORT_DESCENDING)
+  if (priv->sorting_reversed)
     gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
 
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
@@ -863,9 +863,8 @@ _on_check_menu_item_toggled (GtkCheckMenuItem *item, gpointer self)
     }
   else if (GTK_WIDGET (item) == priv->sort_reversed_menu_item)
     {
-      SortingDirection direction = checked ? SORT_DESCENDING : SORT_ASCENDING;
-      _reorder_pictures (mainview, priv->sorting_criteria, direction);
-      frogr_config_set_mainview_sorting_direction (priv->config, direction);
+      _reorder_pictures (mainview, priv->sorting_criteria, checked);
+      frogr_config_set_mainview_sorting_reversed (priv->config, checked);
     }
   else if (checked)
     {
@@ -878,7 +877,7 @@ _on_check_menu_item_toggled (GtkCheckMenuItem *item, gpointer self)
       else if (GTK_WIDGET (item) == priv->sort_by_date_menu_item)
         criteria = SORT_BY_DATE;
 
-      _reorder_pictures (mainview, criteria, priv->sorting_direction);
+      _reorder_pictures (mainview, criteria, priv->sorting_reversed);
       frogr_config_set_mainview_sorting_criteria (priv->config, criteria);
     }
 
@@ -1285,14 +1284,13 @@ _upload_pictures (FrogrMainView *self)
 }
 
 static void
-_reorder_pictures (FrogrMainView *self, SortingCriteria criteria, SortingDirection direction)
+_reorder_pictures (FrogrMainView *self, SortingCriteria criteria, gboolean reversed)
 {
   FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
   gchar *property_name = NULL;
-  gboolean ascending = FALSE;
 
   priv->sorting_criteria = criteria;
-  priv->sorting_direction = direction;
+  priv->sorting_reversed = reversed;
 
   if (!_n_pictures (self))
     return;
@@ -1317,23 +1315,9 @@ _reorder_pictures (FrogrMainView *self, SortingCriteria criteria, SortingDirecti
       g_assert_not_reached ();
     }
 
-  switch (direction)
-    {
-    case SORT_ASCENDING:
-      ascending = TRUE;
-      break;
-
-    case SORT_DESCENDING:
-      ascending = FALSE;
-      break;
-
-    default:
-      g_assert_not_reached ();
-    }
-
   if (property_name)
     {
-      frogr_main_view_model_reorder_pictures (priv->model, property_name, !ascending);
+      frogr_main_view_model_reorder_pictures (priv->model, property_name, reversed);
       g_free (property_name);
     }
 }
@@ -1791,9 +1775,9 @@ frogr_main_view_init (FrogrMainView *self)
   upload_button = GTK_WIDGET (gtk_builder_get_object (builder, "upload_button"));
   priv->upload_button = upload_button;
 
-  /* Initialize sorting criteria and direction */
+  /* Initialize sorting criteria and reverse */
   priv->sorting_criteria = frogr_config_get_mainview_sorting_criteria (priv->config);
-  priv->sorting_direction = frogr_config_get_mainview_sorting_direction (priv->config);
+  priv->sorting_reversed = frogr_config_get_mainview_sorting_reversed (priv->config);
 
   /* Read value for 'tooltips enabled' */
   priv->tooltips_enabled = frogr_config_get_mainview_enable_tooltips (priv->config);



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