* select the inbox of the newly selected account; fixes NB#58667
[modest] / src / maemo / modest-main-window.c
index 6aaeb53..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 },
 };
 
 /************************************************************************/
@@ -455,9 +455,14 @@ on_sendqueue_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg,
 {
        if (err) {
                printf ("DEBUG: %s: err->code=%d, err->message=%s\n", __FUNCTION__, err->code, err->message);
+
+               if (err->code == TNY_ACCOUNT_ERROR_TRY_CONNECT_USER_CANCEL)
+                       /* Don't show waste the user's time by showing him a dialog telling him
+                        * that he has just cancelled something: */
+                       return;
        }
 
-       /* Get the account name: */
+       /* Get the server name: */
        const gchar* server_name = NULL;
        
        TnyCamelTransportAccount* server_account = tny_camel_send_queue_get_transport_account (
@@ -985,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));
 
@@ -995,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) {
@@ -1008,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);
@@ -1037,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 ();
@@ -1684,6 +1691,7 @@ _on_msg_count_changed (ModestHeaderView *header_view,
        }       
 }
 
+
 void 
 modest_main_window_set_contents_style (ModestMainWindow *self, 
                                       ModestMainWindowContentsStyle style)
@@ -1720,6 +1728,8 @@ modest_main_window_set_contents_style (ModestMainWindow *self,
        switch (priv->contents_style) {
        case MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS:
                wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->header_view));
+               modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
+                                                     TRUE);
                break;
        case MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS:
        {
@@ -1733,10 +1743,16 @@ modest_main_window_set_contents_style (ModestMainWindow *self,
                                         priv->details_widget);
                }
                g_object_unref (selected_folderstore);
+               modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
+                                                     FALSE);
+
+               
                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);
                break;
        default:
                g_return_if_reached ();
@@ -2049,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);