* src/widgets/modest-header-view.c:
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 20 Jun 2007 15:42:31 +0000 (15:42 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 20 Jun 2007 15:42:31 +0000 (15:42 +0000)
        * Fix sort by priority, as it wasn't comparing the
          fields values properly.
* src/maemo/modest-platform.c:
        * Fix recovering the sort status from header view to
          create the sort dialog.
        * Save the new widget status on finishing the sort
          (fixes NB#58628).
* src/modest-widget-memory.c:
        * Fix the recovering of sort status from header view.

pmo-trunk-r2341

src/maemo/modest-platform.c
src/modest-widget-memory.c
src/widgets/modest-header-view.c

index 1d7d5ac..01a8f96 100644 (file)
@@ -603,6 +603,7 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
        GtkSortType current_sort_type;
        gint attachments_sort_id;
        gint priority_sort_id;
+       GtkTreeSortable *sortable;
        
        /* Get header window */
        if (MODEST_IS_MAIN_WINDOW (parent_window)) {
@@ -612,7 +613,7 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
        if (!header_view) return;
 
        /* Add sorting keys */
-       cols = modest_header_view_get_columns (header_view);    
+       cols = modest_header_view_get_columns (header_view);
        if (cols == NULL) return;
        int sort_model_ids[6];
        int sort_ids[6];
@@ -661,8 +662,9 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
        sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY;
        priority_sort_id = sort_key;
 
+       sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
        /* Launch dialogs */
-       if (!gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view))),
+       if (!gtk_tree_sortable_get_sort_column_id (sortable,
                                                   &current_sort_colid, &current_sort_type)) {
                hildon_sort_dialog_set_sort_key (dialog, default_key);
                hildon_sort_dialog_set_sort_order (dialog, GTK_SORT_DESCENDING);
@@ -703,8 +705,11 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
                }
 
                modest_header_view_sort_by_column_id (header_view, sort_model_ids[sort_key], sort_type);
-               gtk_tree_sortable_sort_column_changed (GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view))));
+               gtk_tree_sortable_sort_column_changed (sortable);
        }
+
+       modest_widget_memory_save (modest_runtime_get_conf (),
+                                  G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
        
        /* free */
        g_list_free(cols);      
index e96c8b2..be9c42a 100644 (file)
@@ -437,7 +437,9 @@ restore_settings_header_view (ModestConf *conf, ModestHeaderView *header_view,
        }
 
        if (sort_colid >= 0) {
-               GtkTreeModel *sortable = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
+         GtkTreeModel *sortable = 
+                 gtk_tree_model_filter_get_model (
+                         GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view))));
                if (sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN)
                        modest_header_view_sort_by_column_id (header_view, 0, sort_type);
                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sortable),
index 6c01978..776d15e 100644 (file)
@@ -1127,6 +1127,16 @@ _modest_header_view_change_selection (GtkTreeSelection *selection,
        on_selection_changed (selection, user_data);
 }
 
+static gint compare_priorities (TnyHeaderFlags p1, TnyHeaderFlags p2)
+{
+       p1 = p1 & TNY_HEADER_FLAG_PRIORITY;
+       p2 = p2 & TNY_HEADER_FLAG_PRIORITY;
+       if (p1 == 0) 
+               p1 = TNY_HEADER_FLAG_LOW_PRIORITY + 1;
+       if (p2 == 0) 
+               p2 = TNY_HEADER_FLAG_LOW_PRIORITY + 1;
+       return p1 - p2;
+}
 
 static gint
 cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
@@ -1164,10 +1174,7 @@ cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,
 
                /* This is for making priority values respect the intuitive sort relationship 
                 * as HIGH is 11, LOW is 01, and we put NORMAL AS 10 (2) */
-               if (val1 == 0) val1 = 2;
-               if (val2 == 0) val2 = 2;
-
-               cmp =  (val1 & TNY_HEADER_FLAG_PRIORITY) - (val2 & TNY_HEADER_FLAG_PRIORITY);
+               cmp =  compare_priorities (val1, val2);
 
                return cmp ? cmp : t1 - t2;