* select the inbox of the newly selected account; fixes NB#58667
[modest] / src / maemo / modest-main-window.c
index 1dd000b..459df2b 100644 (file)
@@ -254,7 +254,7 @@ static const GtkActionEntry modest_header_view_action_entries [] = {
 };
 
 static const GtkToggleActionEntry modest_main_window_toggle_action_entries [] = {
-       { "ToolbarToggleView", MODEST_STOCK_SPLIT_VIEW, N_("gqn_toolb_rss_fldonoff"), "<CTRL>t", NULL, G_CALLBACK (modest_ui_actions_toggle_folders_view), FALSE },
+       { "ToggleFolders",     MODEST_STOCK_SPLIT_VIEW, N_("mcen_me_inbox_hidefolders"), "<CTRL>t", NULL, G_CALLBACK (modest_ui_actions_toggle_folders_view), TRUE },
 };
 
 /************************************************************************/
@@ -462,7 +462,7 @@ on_sendqueue_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg,
                        return;
        }
 
-       /* Get the account name: */
+       /* Get the server name: */
        const gchar* server_name = NULL;
        
        TnyCamelTransportAccount* server_account = tny_camel_send_queue_get_transport_account (
@@ -990,6 +990,7 @@ modest_main_window_set_style (ModestMainWindow *self,
        ModestMainWindowPrivate *priv;
        ModestWindowPrivate *parent_priv;
        GtkAction *action;
+       gboolean active;
 
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
 
@@ -1000,8 +1001,17 @@ modest_main_window_set_style (ModestMainWindow *self,
        if (priv->style == style)
                return;
 
-       /* Get toggle button */
-       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarToggleView");
+       /* Get toggle button and update the state if needed. This will
+         happen only when the set_style is not invoked from the UI,
+         for example when it's called from widget memory */
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToggleFolders");
+       active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+       if ((active && style == MODEST_MAIN_WINDOW_STYLE_SIMPLE) ||
+          (!active && style == MODEST_MAIN_WINDOW_STYLE_SPLIT)) {
+              g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
+              gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), !active);
+              g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
+       }
 
        priv->style = style;
        switch (style) {
@@ -1013,10 +1023,6 @@ modest_main_window_set_style (ModestMainWindow *self,
                /* Reparent the contents widget to the main vbox */
                gtk_widget_reparent (priv->contents_widget, priv->main_vbox);
 
-               g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
-
                if (modest_header_view_has_selected_headers (MODEST_HEADER_VIEW (priv->header_view))) {
                        TnyList *selection = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (priv->header_view));
                        TnyIterator *iterator = tny_list_create_iterator (selection);
@@ -1042,10 +1048,6 @@ modest_main_window_set_style (ModestMainWindow *self,
                gtk_paned_add2 (GTK_PANED (priv->main_paned), priv->contents_widget);
                gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
 
-               g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
-               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
-               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
-
                break;
        default:
                g_return_if_reached ();
@@ -2063,6 +2065,8 @@ on_show_account_action_activated  (GtkAction *action,
                                                                             acc_data->store_account->account_name);
                modest_window_set_active_account (MODEST_WINDOW (self), acc_data->account_name);
        }
+       
+       modest_folder_view_select_first_inbox_or_local (priv->folder_view);
 
        /* Free */
        modest_account_mgr_free_account_data (mgr, acc_data);