* Fixes NB#87039, do not loose selection when pressing Ctrl+T
[modest] / src / maemo / modest-main-window.c
index 4bfc990..201130e 100644 (file)
@@ -539,8 +539,9 @@ static gint
 compare_display_names (ModestAccountSettings *a,
                       ModestAccountSettings *b)
 {
-       return strcmp (modest_account_settings_get_display_name (a),
-                      modest_account_settings_get_display_name (b));
+       return g_utf8_collate (modest_account_settings_get_display_name (a),
+                              modest_account_settings_get_display_name (b));
+
 }
 
 /* We use this function to prevent the send&receive CSM to be shown
@@ -701,7 +702,7 @@ update_menus (ModestMainWindow* self)
                        /* Add ui from account data. We allow 2^9-1 account
                           changes in a single execution because we're
                           downcasting the guint to a guint8 in order to use a
-                          GByteArray. It should be enough. */
+                          GByteArray. It should be enough :-) */
                        item_name = g_strconcat (account_name, "Menu", NULL);
                        merge_id = (guint8) gtk_ui_manager_new_merge_id (parent_priv->ui_manager);
                        priv->merge_ids = g_byte_array_append (priv->merge_ids, &merge_id, 1);
@@ -760,7 +761,8 @@ update_menus (ModestMainWindow* self)
                                item = gtk_menu_item_new ();
                                gtk_container_add (GTK_CONTAINER (item), label);
 
-                               gtk_menu_shell_prepend (GTK_MENU_SHELL (priv->accounts_popup), GTK_WIDGET (item));
+                               gtk_menu_shell_prepend (GTK_MENU_SHELL (priv->accounts_popup), 
+                                                       GTK_WIDGET (item));
                                g_signal_connect_data (G_OBJECT (item), 
                                                       "activate", 
                                                       G_CALLBACK (on_send_receive_csm_activated),
@@ -1370,7 +1372,9 @@ modest_main_window_set_style (ModestMainWindow *self,
        ModestWindowPrivate *parent_priv;
        GtkAction *action;
        gboolean active;
-
+       GtkTreeSelection *sel;
+       GList *rows, *list;
+       
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
 
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
@@ -1392,6 +1396,11 @@ modest_main_window_set_style (ModestMainWindow *self,
               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
        }
 
+       /* We need to store the selection because it's lost when the
+         widget is reparented */
+       sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+       rows = gtk_tree_selection_get_selected_rows (sel, NULL);
+
        priv->style = style;
        switch (style) {
        case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
@@ -1420,9 +1429,27 @@ modest_main_window_set_style (ModestMainWindow *self,
 
                break;
        default:
+               g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+               g_list_free (rows);
                g_return_if_reached ();
        }
 
+       /* Reselect the previously selected folders. We disable the
+          dimming rules execution during that time because there is
+          no need to work out it again and it could take a lot of
+          time if all the headers are selected */
+       list = rows;
+       modest_window_disable_dimming (MODEST_WINDOW (self));
+       while (list) {
+               gtk_tree_selection_select_path (sel, (GtkTreePath *) list->data);
+               list = g_list_next (list);
+       }
+       modest_window_enable_dimming (MODEST_WINDOW (self));
+
+       /* Free */
+       g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+       g_list_free (rows);
+
        /* Let header view grab the focus if it's being shown */
        if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
                gtk_widget_grab_focus (GTK_WIDGET (priv->header_view));