Fix error in header window on retrieving a deleted message
[modest] / src / modest-ui-actions.c
index 9f9ffa7..6003b86 100644 (file)
@@ -50,6 +50,7 @@
 #include <tny-camel-pop-folder.h>
 #ifdef MODEST_TOOLKIT_HILDON2
 #include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-gtk.h>
 #include <modest-header-window.h>
 #endif
 
 #include "modest-account-mgr-helpers.h"
 #include "modest-mail-operation.h"
 #include "modest-text-utils.h"
-
-#ifdef MODEST_HAVE_EASYSETUP
-#ifdef MODEST_TOOLKIT_HILDON2
-#include "modest-easysetup-wizard-dialog.h"
-#else
-#include "easysetup/modest-easysetup-wizard-dialog.h"
-#endif
-#endif /* MODEST_HAVE_EASYSETUP */
-
 #include <modest-widget-memory.h>
 #include <tny-error.h>
 #include <tny-simple-list.h>
@@ -204,11 +196,11 @@ remote_folder_has_leave_on_server (TnyFolderStore *folder)
 gboolean
 modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
 {
-       gboolean result = FALSE;        
+       gboolean result = FALSE;
        GtkWindow *wizard;
        gint dialog_response;
 
-       /* there is no such wizard yet */       
+       /* there is no such wizard yet */
        wizard = GTK_WINDOW (modest_platform_get_account_settings_wizard ());
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), GTK_WINDOW (wizard), (GtkWindow *) win);
 
@@ -218,7 +210,7 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
        if (!win) 
                win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
                                                         TRUE);  /* create if not existent */
-       
+
        gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
 
        /* make sure the mainwindow is visible. We need to present the
@@ -232,7 +224,7 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
        gtk_window_present (GTK_WINDOW (win));
        gtk_window_present (GTK_WINDOW (wizard));
 #endif
-       
+
        dialog_response = gtk_dialog_run (GTK_DIALOG (wizard));
        gtk_widget_destroy (GTK_WIDGET (wizard));
        if (gtk_events_pending ())
@@ -308,6 +300,13 @@ get_selected_headers (ModestWindow *win)
 
                return list;
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+               GtkWidget *header_view;
+
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+               return modest_header_view_get_selected_headers (MODEST_HEADER_VIEW(header_view));
+#endif
        } else
                return NULL;
 }
@@ -388,6 +387,12 @@ modest_ui_actions_refresh_message_window_after_delete (ModestMsgViewWindow* win)
 void
 modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
 {
+       modest_ui_actions_on_edit_mode_delete_message (win);
+}
+
+gboolean
+modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win)
+{
        TnyList *header_list = NULL;
        TnyIterator *iter = NULL;
        TnyHeader *header = NULL;
@@ -396,8 +401,9 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
        gint response;
        ModestWindowMgr *mgr;
        GtkWidget *header_view = NULL;
+       gboolean retval = TRUE;
 
-       g_return_if_fail (MODEST_IS_WINDOW(win));
+       g_return_val_if_fail (MODEST_IS_WINDOW(win), FALSE);
        
        /* Check first if the header view has the focus */
        if (MODEST_IS_MAIN_WINDOW (win)) {
@@ -405,13 +411,13 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
                                                             MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
                if (!gtk_widget_is_focus (header_view))
-                       return;
+                       return FALSE;
        }
        
        /* Get the headers, either from the header view (if win is the main window),
         * or from the message view window: */
        header_list = get_selected_headers (win);
-       if (!header_list) return;
+       if (!header_list) return FALSE;
                        
        /* Check if any of the headers are already opened, or in the process of being opened */
        if (MODEST_IS_MAIN_WINDOW (win)) {
@@ -440,7 +446,7 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        
                        g_free (msg);
                        g_object_unref (header_list);
-                       return;
+                       return FALSE;
                }
        }
 
@@ -521,7 +527,7 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        /* Get main window */
                        mgr = modest_runtime_get_window_mgr ();
                        main_window = modest_window_mgr_get_main_window (mgr, FALSE); /* don't create */
-               } else {                        
+               } else if (MODEST_IS_MAIN_WINDOW (win)) {
                        /* Move cursor to next row */
                        main_window = win; 
 
@@ -553,12 +559,17 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                /* Free */
                g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL);
                g_list_free (sel_list);
+               retval = TRUE;
+       } else {
+               retval = FALSE;
        }
 
        /* Free*/
        g_free(message);
        g_free(desc);
        g_object_unref (header_list);
+
+       return retval;
 }
 
 
@@ -634,6 +645,14 @@ modest_ui_actions_on_close_window (GtkAction *action, ModestWindow *win)
 }
 
 void
+modest_ui_actions_add_to_contacts (GtkAction *action, ModestWindow *win)
+{
+       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win));
+       
+       modest_msg_view_window_add_to_contacts (MODEST_MSG_VIEW_WINDOW (win));
+}
+
+void
 modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
 {
        GtkClipboard *clipboard = NULL;
@@ -653,19 +672,19 @@ modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
 }
 
 void
-modest_ui_actions_on_accounts (GtkAction *action, 
+modest_ui_actions_on_accounts (GtkAction *action,
                               ModestWindow *win)
 {
        /* This is currently only implemented for Maemo */
        if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) {
-               if (!modest_ui_actions_run_account_setup_wizard (win)) 
+               if (!modest_ui_actions_run_account_setup_wizard (win))
                        g_debug ("%s: wizard was already running", __FUNCTION__);
-               
+
                return;
        } else {
                /* Show the list of accounts */
                GtkWindow *account_win = GTK_WINDOW (modest_account_view_window_new ());
-               
+
                /* The accounts dialog must be modal */
                modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (account_win), (GtkWindow *) win);
                modest_utils_show_dialog_and_forget (GTK_WINDOW (win), GTK_DIALOG (account_win)); 
@@ -680,7 +699,7 @@ modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
         * possiblities.
         */
 #ifndef MODEST_TOOLKIT_GTK /* Defined in config.h */
-       
+
        /* Create the window if necessary: */
        GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
        modest_connection_specific_smtp_window_fill_with_connections (
@@ -715,10 +734,8 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        ModestTnyAccountStore *store = modest_runtime_get_account_store();
        GnomeVFSFileSize total_size, allowed_size;
 
-       /* we check for low-mem; in that case, show a warning, and don't allow
-        * composing a message with attachments
-        */
-       if (attachments && modest_platform_check_memory_low (win, TRUE))
+       /* we check for low-mem */
+       if (modest_platform_check_memory_low (win, TRUE))
                goto cleanup;
 
 #ifdef MODEST_TOOLKIT_HILDON2
@@ -939,11 +956,20 @@ get_info_from_header (TnyHeader *header, gboolean *is_draft)
                        if (TNY_IS_SEND_QUEUE (send_queue)) {
                                msg_id = modest_tny_send_queue_get_msg_id (header);
                                status = modest_tny_send_queue_get_msg_status(send_queue, msg_id);
+                               g_free (msg_id);
                                /* Only open messages in outbox with the editor if they are in Failed state */
                                if (status == MODEST_TNY_SEND_QUEUE_FAILED) {
                                        *is_draft = TRUE;
                                }
-                               g_free(msg_id);
+#ifdef MODEST_TOOLKIT_HILDON2
+                               else {
+                                       /* In Fremantle we can not
+                                          open any message from
+                                          outbox which is not in
+                                          failed state */
+                                       g_object_unref(traccount);
+                                }
+#endif
                        }
                        g_object_unref(traccount);
                } else {
@@ -1322,7 +1348,11 @@ open_msg_performer(gboolean canceled,
 
        if (show_open_draft) {
                helper->banner_info = g_slice_new (OpenMsgBannerInfo);
+#ifdef MODEST_TOOLKIT_HILDON2
+               helper->banner_info->message = g_strdup (_("mail_me_opening"));
+#else
                helper->banner_info->message = g_strdup (_("mail_ib_opening_draft_message"));
+#endif
                helper->banner_info->banner = NULL;
                helper->banner_info->idle_handler = g_timeout_add (500, open_msg_banner_idle, 
                                                                   helper->banner_info);
@@ -1910,21 +1940,27 @@ void
 modest_ui_actions_on_sort (GtkAction *action, 
                           ModestWindow *window)
 {
+       GtkWidget *header_view = NULL;
+
        g_return_if_fail (MODEST_IS_WINDOW(window));
 
        if (MODEST_IS_MAIN_WINDOW (window)) {
-               GtkWidget *header_view;
                header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
                                                                   MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               if (!header_view) {
-                       modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort"));
-
-                       return;
-               }
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (window)) {
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window)));
+#endif
+       }
 
-               /* Show sorting dialog */
-               modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);        
+       if (!header_view) {
+               modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort"));
+               
+               return;
        }
+
+       /* Show sorting dialog */
+       modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);        
 }
 
 static void
@@ -2219,11 +2255,16 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
        
                if (folder_store)
                        g_object_unref (folder_store);
-       }       
+               /* Refresh the active account. Force the connection if needed
+                  and poke the status of all folders */
+               modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win);
+       } else {
+               const gchar *active_account;
+               active_account = modest_window_get_active_account (MODEST_WINDOW (win));
+
+               modest_ui_actions_do_send_receive (active_account, TRUE, TRUE, TRUE, win);
+       } 
        
-       /* Refresh the active account. Force the connection if needed
-          and poke the status of all folders */
-       modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win);
 }
 
 
@@ -2464,6 +2505,7 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                        modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
                                                       TNY_FOLDER (folder_store),
                                                       TRUE,
+                                                      MODEST_WINDOW (main_window),
                                                       folder_refreshed_cb,
                                                       main_window);
                        
@@ -2592,6 +2634,9 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op,
                      gpointer user_data)
 {
        ModestMsgEditWindow *edit_window;
+
+       /* TODO: in hildon 2 we have to dim and undim the header views while we're saving */
+#ifndef MODEST_TOOLKIT_HILDON2
        ModestMainWindow *win;
 
        /* FIXME. Make the header view sensitive again. This is a
@@ -2604,6 +2649,7 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op,
                        win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
                if (hdrview) gtk_widget_set_sensitive(hdrview, TRUE);
        }
+#endif
 
        edit_window = MODEST_MSG_EDIT_WINDOW (user_data);
 
@@ -3557,50 +3603,62 @@ password_dialog_check_field (GtkEditable *editable,
 }
 
 void
-modest_ui_actions_on_password_requested (TnyAccountStore *account_store, 
+modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                         const gchar* server_account_name,
                                         gchar **username,
-                                        gchar **password, 
-                                        gboolean *cancel, 
+                                        gchar **password,
+                                        gboolean *cancel,
                                         gboolean *remember,
                                         ModestMainWindow *main_window)
 {
        g_return_if_fail(server_account_name);
        gboolean completed = FALSE;
        PasswordDialogFields *fields = NULL;
-       
+
        /* Initalize output parameters: */
        if (cancel)
                *cancel = FALSE;
-               
+
        if (remember)
                *remember = TRUE;
-               
+
 #ifndef MODEST_TOOLKIT_GTK
        /* Maemo uses a different (awkward) button order,
         * It should probably just use gtk_alternative_dialog_button_order ().
         */
-       GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
-                                             NULL,
-                                             GTK_DIALOG_MODAL,
-                                             _("mcen_bd_dialog_ok"),
-                                             GTK_RESPONSE_ACCEPT,
-                                             _("mcen_bd_dialog_cancel"),
-                                             GTK_RESPONSE_REJECT,
-                                             NULL);
+#ifdef MODEST_TOOLKIT_HILDON2
+       GtkWidget *dialog =
+               gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
+                                            NULL,
+                                            GTK_DIALOG_MODAL,
+                                            _HL("wdgt_bd_done"),
+                                            GTK_RESPONSE_ACCEPT,
+                                            NULL);
 #else
-       GtkWidget *dialog = gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
-                                             NULL,
-                                             GTK_DIALOG_MODAL,
-                                             GTK_STOCK_CANCEL,
-                                             GTK_RESPONSE_REJECT,
-                                             GTK_STOCK_OK,
-                                             GTK_RESPONSE_ACCEPT,
-                                             NULL);
-#endif /* !MODEST_TOOLKIT_GTK */
+       GtkWidget *dialog =
+               gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
+                                            NULL,
+                                            GTK_DIALOG_MODAL,
+                                            _("mcen_bd_dialog_ok"),
+                                            GTK_RESPONSE_ACCEPT,
+                                            _("mcen_bd_dialog_cancel"),
+                                            GTK_RESPONSE_REJECT,
+                                            NULL);
+#endif /* MODEST_TOOLKIT_HILDON2 */
+#else
+       GtkWidget *dialog = 
+               gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
+                                            NULL,
+                                            GTK_DIALOG_MODAL,
+                                            GTK_STOCK_CANCEL,
+                                            GTK_RESPONSE_REJECT,
+                                            GTK_STOCK_OK,
+                                            GTK_RESPONSE_ACCEPT,
+                                            NULL);
+#endif /* MODEST_TOOLKIT_GTK */
 
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), GTK_WINDOW (dialog), NULL);
-       
+
        gchar *server_name = modest_account_mgr_get_server_account_hostname (
                modest_runtime_get_account_mgr(), server_account_name);
        if (!server_name) {/* This happened once, though I don't know why. murrayc. */
@@ -3610,9 +3668,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                gtk_widget_destroy (dialog);
                return;
        }
-       
-       /* This causes a warning because the logical ID has no %s in it, 
-        * though the translation does, but there is not much we can do about that: */
+
        gchar *txt = g_strdup_printf (_("mail_ia_password_info"), server_name);
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt),
                            FALSE, FALSE, 0);
@@ -3623,7 +3679,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
        /* username: */
        gchar *initial_username = modest_account_mgr_get_server_account_username (
                modest_runtime_get_account_mgr(), server_account_name);
-       
+
        GtkWidget *entry_username = gtk_entry_new ();
        if (initial_username)
                gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
@@ -3642,48 +3698,48 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
 #ifndef MODEST_TOOLKIT_GTK
        /* Auto-capitalization is the default, so let's turn it off: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
-       
+
        /* Create a size group to be used by all captions.
         * Note that HildonCaption does not create a default size group if we do not specify one.
         * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
        GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-       
+
        GtkWidget *caption = hildon_caption_new (sizegroup, 
                _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (entry_username);
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, 
                FALSE, FALSE, MODEST_MARGIN_HALF);
        gtk_widget_show (caption);
-#else 
+#else
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
                            TRUE, FALSE, 0);
-#endif /* !MODEST_TOOLKIT_GTK */       
-                           
+#endif /* !MODEST_TOOLKIT_GTK */
+
        /* password: */
        GtkWidget *entry_password = gtk_entry_new ();
        gtk_entry_set_visibility (GTK_ENTRY(entry_password), FALSE);
        /* gtk_entry_set_invisible_char (GTK_ENTRY(entry_password), "*"); */
-       
+
 #ifndef MODEST_TOOLKIT_GTK
        /* Auto-capitalization is the default, so let's turn it off: */
-       hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password), 
+       hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password),
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-       
-       caption = hildon_caption_new (sizegroup, 
+
+       caption = hildon_caption_new (sizegroup,
                _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (entry_password);
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption, 
+       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), caption,
                FALSE, FALSE, MODEST_MARGIN_HALF);
        gtk_widget_show (caption);
        g_object_unref (sizegroup);
-#else 
+#else
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
                            TRUE, FALSE, 0);
-#endif /* !MODEST_TOOLKIT_GTK */       
+#endif /* !MODEST_TOOLKIT_GTK */
 
        if (initial_username != NULL)
                gtk_widget_grab_focus (GTK_WIDGET (entry_password));
-                               
+
 /* This is not in the Maemo UI spec:
        remember_pass_check = gtk_check_button_new_with_label (_("Remember password"));
        gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check,
@@ -3702,18 +3758,18 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
        gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
 
        while (!completed) {
-       
+
                if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
                        if (username) {
                                *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
-                               
+
                                /* Note that an empty field becomes the "" string */
                                if (*username && strlen (*username) > 0) {
                                        modest_account_mgr_set_server_account_username (modest_runtime_get_account_mgr(), 
                                                                                        server_account_name, 
                                                                                        *username);
                                        completed = TRUE;
-                               
+
                                        const gboolean username_was_changed = 
                                                (strcmp (*username, initial_username) != 0);
                                        if (username_was_changed) {
@@ -3722,16 +3778,17 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                        }
                                } else {
                                        g_free (*username);
+                                       *username = NULL;
                                        /* Show error */
                                        modest_platform_information_banner (GTK_WIDGET (dialog), NULL, 
                                                                            _("mcen_ib_username_pw_incorrect"));
                                        completed = FALSE;
                                }
                        }
-                       
+
                        if (password) {
                                *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
-                       
+
                                /* We do not save the password in the configuration, 
                                 * because this function is only called for passwords that should 
                                 * not be remembered:
@@ -3739,17 +3796,19 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                 modest_runtime_get_account_mgr(), server_account_name, 
                                 *password);
                                 */
-                       }                       
+                       }
                        if (cancel)
-                               *cancel   = FALSE;                      
+                               *cancel   = FALSE;
                } else {
+#ifndef MODEST_TOOLKIT_HILDON2
                        /* Set parent to NULL or the banner will disappear with its parent dialog */
                        modest_platform_information_banner(NULL, NULL, _("mail_ib_login_cancelled"));
+#endif
                        completed = TRUE;
                        if (username)
-                               *username = NULL;                       
+                               *username = NULL;
                        if (password)
-                               *password = NULL;                       
+                               *password = NULL;
                        if (cancel)
                                *cancel   = TRUE;
                }
@@ -4465,6 +4524,7 @@ create_move_to_dialog_on_new_folder(GtkWidget *button, gpointer user_data)
                                         GTK_WIDGET (user_data));
 }
 
+#ifndef MODEST_TOOLKIT_HILDON2
 /*
  * This function is used to track changes in the selection of the
  * folder view that is inside the "move to" dialog to enable/disable
@@ -4615,6 +4675,18 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
        /* Set sensitivity of the NEW button */
        gtk_widget_set_sensitive (new_button, new_sensitive);
 }
+#endif
+
+#ifdef MODEST_TOOLKIT_HILDON2
+static void
+on_move_to_dialog_folder_activated (GtkTreeView       *tree_view,
+                                   GtkTreePath       *path,
+                                   GtkTreeViewColumn *column,
+                                   gpointer           user_data)
+{
+       gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_ACCEPT);
+}
+#endif
 
 
 #define MODEST_MOVE_TO_DIALOG_FOLDER_VIEW "move-to-dialog-folder-view"
@@ -4636,8 +4708,9 @@ create_move_to_dialog (GtkWindow *win,
        GtkWidget *pannable;
 #else
        GtkWidget *scroll;
+       GtkWidget *ok_button;
 #endif
-       GtkWidget *new_button, *ok_button;
+       GtkWidget *new_button;
 
        dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
                                              GTK_WINDOW (win),
@@ -4645,15 +4718,19 @@ create_move_to_dialog (GtkWindow *win,
                                              NULL);
 
 #ifndef MODEST_TOOLKIT_GTK
+#ifndef MODEST_TOOLKIT_HILDON2
        ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("mcen_bd_dialog_ok"), GTK_RESPONSE_ACCEPT);
+#endif
        /* We do this manually so GTK+ does not associate a response ID for
         * the button. */
        new_button = gtk_button_new_from_stock (_("mcen_bd_new"));
        gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->action_area), new_button, FALSE, FALSE, 0);
-       gtk_widget_show (new_button);
-#ifndef MODEST_TOOLKIT_HILDON2
+#ifdef MODEST_TOOLKIT_HILDON2
+       hildon_gtk_widget_set_theme_size (new_button, HILDON_SIZE_FINGER_HEIGHT);
+#else
        gtk_dialog_add_button (GTK_DIALOG (dialog), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_REJECT);
 #endif
+       gtk_widget_show (new_button);
 #else
        /* We do this manually so GTK+ does not associate a response ID for
         * the button. */
@@ -4665,7 +4742,10 @@ create_move_to_dialog (GtkWindow *win,
        gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 24);
 #endif
+
+#ifndef MODEST_TOOLKIT_HILDON2
        g_object_set_data (G_OBJECT (dialog), MOVE_FOLDER_OK_BUTTON, ok_button);
+#endif
        g_object_set_data (G_OBJECT (dialog), MOVE_FOLDER_NEW_BUTTON, new_button);
 
        /* Create scrolled window */
@@ -4685,6 +4765,13 @@ create_move_to_dialog (GtkWindow *win,
        /* Create folder view */
        *tree_view = modest_platform_create_folder_view (NULL);
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       /* We return OK on activation */
+       g_signal_connect (*tree_view,
+                         "row-activated",
+                         G_CALLBACK (on_move_to_dialog_folder_activated),
+                         dialog);
+#else
        /* Track changes in the selection to
         * disable the OK button whenever "Move to" is not possible
         * disbale NEW button whenever New is not possible */
@@ -4692,6 +4779,7 @@ create_move_to_dialog (GtkWindow *win,
                          "folder_selection_changed",
                          G_CALLBACK (on_move_to_dialog_folder_selection_changed),
                          win);
+#endif
 
        /* Listen to clicks on New button */
        g_signal_connect (G_OBJECT (new_button), 
@@ -4699,6 +4787,11 @@ create_move_to_dialog (GtkWindow *win,
                          G_CALLBACK(create_move_to_dialog_on_new_folder), 
                          *tree_view);
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (*tree_view),
+                                          MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT);
+#endif
+
        /* It could happen that we're trying to move a message from a
           window (msg window for example) after the main window was
           closed, so we can not just get the model of the folder
@@ -5009,7 +5102,7 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op,
                if (response == GTK_RESPONSE_OK) {
                        GtkWidget *info;
                        info =
-                               modest_platform_animation_banner (GTK_WIDGET (win), NULL, _("mcen_ib_removing_attachment"));
+                               modest_platform_animation_banner (GTK_WIDGET (win), NULL, _("mcen_me_inbox_remove_attachments"));
                        iter = tny_list_create_iterator (parts);
                        while (!tny_iterator_is_done (iter)) {
                                TnyMimePart *part;
@@ -5486,29 +5579,38 @@ modest_ui_actions_transfer_messages_helper (GtkWindow *win,
  * ModestMsgViewWindow
  */
 static void 
-modest_ui_actions_on_msg_view_window_move_to (GtkAction *action, 
-                                             TnyFolderStore *dst_folder,
-                                             ModestMsgViewWindow *win)
+modest_ui_actions_on_window_move_to (GtkAction *action, 
+                                    TnyFolderStore *dst_folder,
+                                    ModestWindow *win)
 {
        TnyList *headers = NULL;
-       TnyHeader *header = NULL;
        TnyFolder *src_folder = NULL;
 
        g_return_if_fail (TNY_IS_FOLDER (dst_folder));
 
        /* Create header list */
-       header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
-       src_folder = TNY_FOLDER (tny_header_get_folder(header));
-       headers = tny_simple_list_new ();
-       tny_list_append (headers, G_OBJECT (header));
+       headers = get_selected_headers (MODEST_WINDOW (win));
+
+       if (tny_list_get_length (headers) > 0) {
+               TnyHeader *header = NULL;
+               TnyIterator *iter;
+
+               iter = tny_list_create_iterator (headers);
+               header = (TnyHeader *) tny_iterator_get_current (iter);
+               src_folder = tny_header_get_folder (header);
+
+               g_object_unref (header);
+               g_object_unref (iter);
+
+               /* Transfer the messages */
+               modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), src_folder, headers, 
+                                                           TNY_FOLDER (dst_folder));
+       }
 
-       /* Transfer the messages */
-       modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), src_folder, headers, 
-                                                   TNY_FOLDER (dst_folder));
 
        /* Frees */
-       g_object_unref (src_folder);
-       g_object_unref (header);
+       if (src_folder)
+               g_object_unref (src_folder);
        g_object_unref (headers);
 }
 
@@ -5521,8 +5623,7 @@ modest_ui_actions_on_move_to (GtkAction *action,
        TnyFolderStore *dst_folder = NULL;
        ModestMainWindow *main_window;
 
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW (win) ||
-                         MODEST_IS_MSG_VIEW_WINDOW (win));
+       g_return_if_fail (MODEST_IS_WINDOW (win));
 
        /* Get the main window if exists */
        if (MODEST_IS_MAIN_WINDOW (win))
@@ -5558,9 +5659,9 @@ modest_ui_actions_on_move_to (GtkAction *action,
                                dst_folder,
                                MODEST_MAIN_WINDOW (win));
        } else {
-               modest_ui_actions_on_msg_view_window_move_to (action,
-                               dst_folder,
-                               MODEST_MSG_VIEW_WINDOW (win));
+               modest_ui_actions_on_window_move_to (action,
+                                                    dst_folder,
+                                                    MODEST_WINDOW (win));
        }
 
        if (dst_folder)
@@ -5674,6 +5775,8 @@ void
 modest_ui_actions_on_help (GtkAction *action, 
                           GtkWindow *win)
 {
+       /* Help app is not available at all in fremantle */
+#ifndef MODEST_TOOLKIT_HILDON2
        const gchar *help_id;
 
        g_return_if_fail (win && GTK_IS_WINDOW(win));
@@ -5682,12 +5785,16 @@ modest_ui_actions_on_help (GtkAction *action,
 
         if (help_id)
                 modest_platform_show_help (GTK_WINDOW (win), help_id);
+#endif
 }
 
 void 
 modest_ui_actions_on_csm_help (GtkAction *action, 
                               GtkWindow *win)
 {
+       /* Help app is not available at all in fremantle */
+#ifndef MODEST_TOOLKIT_HILDON2
+
        const gchar* help_id = NULL;
        GtkWidget *folder_view;
        TnyFolderStore *folder_store;
@@ -5710,6 +5817,7 @@ modest_ui_actions_on_csm_help (GtkAction *action,
                 modest_platform_show_help (GTK_WINDOW (win), help_id);
        else
                modest_ui_actions_on_help (action, win);
+#endif
 }
 
 static void     
@@ -6147,6 +6255,24 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
                folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
                g_object_unref (iter);
                g_object_unref (headers);
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+               GtkWidget *header_view;
+               TnyList* headers = NULL;
+               TnyIterator *iter;
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+               headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
+               if (!headers || tny_list_get_length (headers) == 0) {
+                       if (headers)
+                               g_object_unref (headers);
+                       return NULL;
+               }
+               iter = tny_list_create_iterator (headers);
+               header = TNY_HEADER (tny_iterator_get_current (iter));
+               folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
+               g_object_unref (iter);
+               g_object_unref (headers);
+#endif
        } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
                folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
@@ -6173,3 +6299,49 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
 
        return msg;
 }
+
+gboolean
+modest_ui_actions_on_delete_account (GtkWindow *parent_window,
+                                    const gchar *account_name,
+                                    const gchar *account_title)
+{
+       ModestAccountMgr *account_mgr;
+       gchar *txt = NULL;
+       gint response;
+       ModestProtocol *protocol;
+       gboolean removed = FALSE;
+
+       g_return_val_if_fail (account_name, FALSE);
+       g_return_val_if_fail (account_title, FALSE);
+
+       account_mgr = modest_runtime_get_account_mgr();
+
+       /* The warning text depends on the account type: */
+       protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+                                                                 modest_account_mgr_get_store_protocol (account_mgr,
+                                                                                                        account_name));
+       txt = modest_protocol_get_translation (protocol,
+                                              MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX,
+                                              account_title);
+       if (txt == NULL)
+               txt = g_strdup_printf (_("emev_nc_delete_mailbox"), account_title);
+
+       response = modest_platform_run_confirmation_dialog (parent_window, txt);
+       g_free (txt);
+       txt = NULL;
+
+       if (response == GTK_RESPONSE_OK) {
+               /* Remove account. If it succeeds then it also removes
+                  the account from the ModestAccountView: */
+               gboolean is_default = FALSE;
+               gchar *default_account_name = modest_account_mgr_get_default_account (account_mgr);
+               if (default_account_name && (strcmp (default_account_name, account_name) == 0))
+                       is_default = TRUE;
+               g_free (default_account_name);
+
+               removed = modest_account_mgr_remove_account (account_mgr, account_name);
+               if (!removed)
+                       g_warning ("%s: modest_account_mgr_remove_account() failed.\n", __FUNCTION__);
+       }
+       return removed;
+}