From: Sergio Villar Senin Date: Mon, 21 Jul 2008 16:09:30 +0000 (+0000) Subject: * Fixes NB#87039, do not loose selection when pressing Ctrl+T X-Git-Tag: git_migration_finished~1262 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=9c2b3abbccf751601d221ded6e3cea379174e2e2 * Fixes NB#87039, do not loose selection when pressing Ctrl+T pmo-trunk-r5079 --- diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 918cc3e..201130e 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -1372,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); @@ -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); } + /* 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: @@ -1422,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));