* Fixes NB#87039, do not loose selection when pressing Ctrl+T
authorSergio Villar Senin <svillar@igalia.com>
Mon, 21 Jul 2008 16:09:30 +0000 (16:09 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 21 Jul 2008 16:09:30 +0000 (16:09 +0000)
pmo-trunk-r5079

src/maemo/modest-main-window.c

index 918cc3e..201130e 100644 (file)
@@ -1372,7 +1372,9 @@ modest_main_window_set_style (ModestMainWindow *self,
        ModestWindowPrivate *parent_priv;
        GtkAction *action;
        gboolean active;
        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);
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
 
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
@@ -1394,6 +1396,11 @@ modest_main_window_set_style (ModestMainWindow *self,
               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, 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:
        priv->style = style;
        switch (style) {
        case MODEST_MAIN_WINDOW_STYLE_SIMPLE:
@@ -1422,9 +1429,27 @@ modest_main_window_set_style (ModestMainWindow *self,
 
                break;
        default:
 
                break;
        default:
+               g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+               g_list_free (rows);
                g_return_if_reached ();
        }
 
                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));
        /* 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));