X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-main-window.c;h=69fc7d4f355a61eead653553ab8de4f8f177d5c6;hp=918cc3e280fce47a82f3a6c5dd907b43163d8d85;hb=4dc1719b3df5a026a74679d7ba6c7dc1fa05ae4d;hpb=ca53005e07a4ff4db6764465b9c3f35e0b97a49a diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 918cc3e..69fc7d4 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "modest-hildon-includes.h" #include "modest-defs.h" @@ -1147,14 +1146,6 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data) gtk_widget_show_all(GTK_WIDGET(self)); modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self)); } else { - GSList *accounts; - GtkAction *send_receive_all; - ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (self); - accounts = modest_account_mgr_account_names (modest_runtime_get_account_mgr (), TRUE); - send_receive_all = gtk_ui_manager_get_action (parent_priv->ui_manager, - "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu"); - gtk_action_set_visible (send_receive_all, g_slist_length (accounts) > 0); - modest_account_mgr_free_account_names (accounts); update_menus (MODEST_MAIN_WINDOW (self)); } @@ -1372,7 +1363,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 +1387,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,14 +1420,40 @@ 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) + if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) { gtk_widget_grab_focus (GTK_WIDGET (priv->header_view)); - else - gtk_widget_grab_focus (GTK_WIDGET (priv->contents_widget)); + } else { + if (priv->style == MODEST_MAIN_WINDOW_STYLE_SPLIT) + gtk_widget_grab_focus (GTK_WIDGET (priv->folder_view)); + else + gtk_widget_grab_focus (GTK_WIDGET (priv->contents_widget)); + } + + /* Check dimming rules */ + modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (self)); + modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self)); /* Show changes */ gtk_widget_show_all (GTK_WIDGET (priv->main_vbox)); @@ -1720,8 +1744,45 @@ on_inner_widgets_key_pressed (GtkWidget *widget, } } } - } else if (MODEST_IS_FOLDER_VIEW (widget) && event->keyval == GDK_Right) + } else if (MODEST_IS_FOLDER_VIEW (widget) && (event->keyval == GDK_Right || event->keyval == GDK_Left)) { +#if GTK_CHECK_VERSION(2, 8, 0) /* TODO: gtk_tree_view_get_visible_range() is only available in GTK+ 2.8 */ + GtkTreePath *selected_path = NULL; + GtkTreePath *start_path = NULL; + GtkTreePath *end_path = NULL; + GList *selected; + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view)); + selected = gtk_tree_selection_get_selected_rows (selection, NULL); + if (selected != NULL) { + selected_path = (GtkTreePath *) selected->data; + if (gtk_tree_view_get_visible_range (GTK_TREE_VIEW (priv->header_view), + &start_path, + &end_path)) { + + if ((gtk_tree_path_compare (start_path, selected_path) != -1) || + (gtk_tree_path_compare (end_path, selected_path) != 1)) { + + /* Scroll to first path */ + gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (priv->header_view), + selected_path, + NULL, + TRUE, + 0.5, + 0.0); + } + } + if (start_path) + gtk_tree_path_free (start_path); + if (end_path) + gtk_tree_path_free (end_path); + g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL); + g_list_free (selected); + } +#endif /* GTK_CHECK_VERSION */ + /* fix scroll */ gtk_widget_grab_focus (GTK_WIDGET (priv->header_view)); + } return FALSE; } @@ -2144,6 +2205,8 @@ modest_main_window_set_contents_style (ModestMainWindow *self, wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->header_view)); modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget), TRUE); + if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE) + gtk_widget_grab_focus (GTK_WIDGET (priv->header_view)); break; case MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS: { @@ -2163,12 +2226,16 @@ modest_main_window_set_contents_style (ModestMainWindow *self, modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget), FALSE); } + if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE) + gtk_widget_grab_focus (GTK_WIDGET (priv->details_widget)); break; } case MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY: wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->empty_view)); modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget), FALSE); + if (priv->style == MODEST_MAIN_WINDOW_STYLE_SIMPLE) + gtk_widget_grab_focus (GTK_WIDGET (priv->empty_view)); break; default: g_return_if_reached (); @@ -2832,6 +2899,17 @@ modest_main_window_on_msg_view_window_msg_changed (ModestMsgViewWindow *view_win return TRUE; } +static void +updating_banner_destroyed (gpointer data, + GObject *where_the_object_was) +{ + ModestMainWindowPrivate *priv = NULL; + + priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data); + + priv->updating_banner = NULL; +} + static gboolean show_updating_banner (gpointer user_data) { @@ -2846,6 +2924,13 @@ show_updating_banner (gpointer user_data) priv->updating_banner = modest_platform_animation_banner (GTK_WIDGET (user_data), NULL, _CS ("ckdg_pb_updating")); + + /* We need this because banners in Maemo could be + destroyed by dialogs so we need to properly update + our reference to it */ + g_object_weak_ref (G_OBJECT (priv->updating_banner), + updating_banner_destroyed, + user_data); gdk_threads_leave (); } @@ -2971,6 +3056,17 @@ on_window_destroy (GtkObject *widget, remove_banners (MODEST_MAIN_WINDOW (widget)); } +static void +retrieving_banner_destroyed (gpointer data, + GObject *where_the_object_was) +{ + ModestMainWindowPrivate *priv = NULL; + + priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data); + + priv->retrieving_banner = NULL; +} + static gboolean show_retrieving_banner (gpointer user_data) { @@ -2985,6 +3081,13 @@ show_retrieving_banner (gpointer user_data) priv->retrieving_banner = modest_platform_animation_banner (GTK_WIDGET (user_data), NULL, _("mcen_ib_getting_items")); + + /* We need this because banners in Maemo could be + destroyed by dialogs so we need to properly update + our reference to it */ + g_object_weak_ref (G_OBJECT (priv->retrieving_banner), + retrieving_banner_destroyed, + user_data); gdk_threads_leave (); }