Replace hildon-common-strings with proper translation strings in gtk
[modest] / src / modest-ui-actions.c
index f3fb660..06fce17 100644 (file)
 #include <tny-camel-folder.h>
 #include <tny-camel-imap-folder.h>
 #include <tny-camel-pop-folder.h>
+#include <widgets/modest-header-window.h>
+#include <widgets/modest-folder-window.h>
+#include <widgets/modest-accounts-window.h>
 #ifdef MODEST_TOOLKIT_HILDON2
-#include <modest-accounts-window.h>
-#include <hildon/hildon-pannable-area.h>
 #include <hildon/hildon-gtk.h>
-#include <modest-header-window.h>
-#include <modest-folder-window.h>
 #include <modest-maemo-utils.h>
 #endif
-
-#ifdef MODEST_PLATFORM_MAEMO
-#include "maemo/modest-osso-state-saving.h"
-#endif /* MODEST_PLATFORM_MAEMO */
-#ifndef MODEST_TOOLKIT_GTK
-#include "maemo/modest-hildon-includes.h"
-#include "maemo/modest-connection-specific-smtp-window.h"
-#endif /* !MODEST_TOOLKIT_GTK */
-#include <modest-utils.h>
-
+#include "modest-utils.h"
+#include "widgets/modest-connection-specific-smtp-window.h"
 #include "widgets/modest-ui-constants.h"
 #include <widgets/modest-main-window.h>
 #include <widgets/modest-msg-view-window.h>
@@ -85,6 +76,7 @@
 #include <tny-msg-view.h>
 #include <tny-device.h>
 #include <tny-merge-folder.h>
+#include <widgets/modest-toolkit-utils.h>
 
 #include <gtkhtml/gtkhtml.h>
 
@@ -155,13 +147,6 @@ static void     reply_forward_cb       (ModestMailOperation *mail_op,
 
 static void     reply_forward          (ReplyForwardAction action, ModestWindow *win);
 
-static void     folder_refreshed_cb    (ModestMailOperation *mail_op,
-                                       TnyFolder *folder,
-                                       gpointer user_data);
-
-static void     on_send_receive_finished (ModestMailOperation  *mail_op,
-                                         gpointer user_data);
-
 static gint header_list_count_uncached_msgs (TnyList *header_list);
 
 static gboolean connect_to_get_msg (ModestWindow *win,
@@ -176,16 +161,10 @@ static void     do_create_folder (GtkWindow *window,
 
 static TnyAccount *get_account_from_folder_store (TnyFolderStore *folder_store);
 
-static void modest_ui_actions_on_main_window_move_to (GtkAction *action,
-                                                     GtkWidget *folder_view,
-                                                     TnyFolderStore *dst_folder,
-                                                     ModestMainWindow *win);
-#ifdef MODEST_TOOLKIT_HILDON2
 static void modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view,
                                                        TnyFolderStore *dst_folder,
                                                        TnyList *selection,
                                                        GtkWindow *win);
-#endif
 
 static void modest_ui_actions_on_window_move_to (GtkAction *action,
                                                 TnyList *list_to_move,
@@ -226,14 +205,6 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
        wizard = GTK_WINDOW (modest_platform_get_account_settings_wizard ());
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), GTK_WINDOW (wizard), (GtkWindow *) win);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       /* always present a main window in the background
-        * we do it here, so we cannot end up with two wizards (as this
-        * function might be called in modest_window_mgr_get_main_window as well */
-       if (!win)
-               win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
-                                                        TRUE);  /* create if not existent */
-#else
        if (!win) {
                GList *window_list;
                ModestWindowMgr *mgr;
@@ -254,7 +225,6 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
                        g_list_free (window_list);
                }
        }
-#endif
 
        if (win)
                gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
@@ -264,12 +234,6 @@ modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
           in order to get the widgets properly drawn (MainWindow main
           paned won't be in its right position and the dialog will be
           missplaced */
-#ifndef MODEST_TOOLKIT_HILDON2
-       gtk_widget_show_all (GTK_WIDGET (win));
-       gtk_widget_show_all (GTK_WIDGET (wizard));
-       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));
@@ -325,14 +289,7 @@ modest_ui_actions_on_about (GtkAction *action, ModestWindow *win)
 static TnyList *
 get_selected_headers (ModestWindow *win)
 {
-       if (MODEST_IS_MAIN_WINDOW(win)) {
-               GtkWidget *header_view;
-
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               return modest_header_view_get_selected_headers (MODEST_HEADER_VIEW(header_view));
-
-       } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
+       if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                /* for MsgViewWindows, we simply return a list with one element */
                TnyHeader *header;
                TnyList *list = NULL;
@@ -345,45 +302,14 @@ 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;
-}
-
-static GtkTreeRowReference *
-get_next_after_selected_headers (ModestHeaderView *header_view)
-{
-       GtkTreeSelection *sel;
-       GList *selected_rows, *node;
-       GtkTreePath *path;
-       GtkTreeRowReference *result;
-       GtkTreeModel *model;
-
-       model = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
-       sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
-       selected_rows = gtk_tree_selection_get_selected_rows (sel, NULL);
-
-       if (selected_rows == NULL)
+       } else {
                return NULL;
-
-       node = g_list_last (selected_rows);
-       path = gtk_tree_path_copy ((GtkTreePath *) node->data);
-       gtk_tree_path_next (path);
-
-       result = gtk_tree_row_reference_new (model, path);
-
-       gtk_tree_path_free (path);
-       g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
-       g_list_free (selected_rows);
-
-       return result;
+       }
 }
 
 static void
@@ -446,55 +372,16 @@ modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win)
        gchar *desc = NULL;
        gint response;
        ModestWindowMgr *mgr;
-       GtkWidget *header_view = NULL;
        gboolean retval = TRUE;
 
        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)) {
-               header_view =
-                       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 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 FALSE;
 
        /* Check if any of the headers are already opened, or in the process of being opened */
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               gint opened_headers = 0;
-
-               iter = tny_list_create_iterator (header_list);
-               mgr = modest_runtime_get_window_mgr ();
-               while (!tny_iterator_is_done (iter)) {
-                       header = TNY_HEADER (tny_iterator_get_current (iter));
-                       if (header) {
-                               if (modest_window_mgr_find_registered_header (mgr, header, NULL))
-                                       opened_headers++;
-                               g_object_unref (header);
-                       }
-                       tny_iterator_next (iter);
-               }
-               g_object_unref (iter);
-
-               if (opened_headers > 0) {
-                       gchar *msg;
-
-                       msg = g_strdup_printf (_("mcen_nc_unable_to_delete_n_messages"),
-                                              opened_headers);
-
-                       modest_platform_run_information_dialog (GTK_WINDOW (win), (const gchar *) msg, FALSE);
-
-                       g_free (msg);
-                       g_object_unref (header_list);
-                       return FALSE;
-               }
-       }
 
        /* Select message */
        if (tny_list_get_length(header_list) == 1) {
@@ -519,36 +406,12 @@ modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win)
        response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
                                                            message);
 
-
        if (response == GTK_RESPONSE_OK) {
-               ModestWindowMgr *mgr = NULL;
-               GtkTreeModel *model = NULL;
                GtkTreeSelection *sel = NULL;
-               GList *sel_list = NULL, *tmp = NULL;
-               GtkTreeRowReference *next_row_reference = NULL;
-               GtkTreeRowReference *prev_row_reference = NULL;
-               GtkTreePath *next_path = NULL;
-               GtkTreePath *prev_path = NULL;
+               GList *sel_list = NULL;
                ModestMailOperation *mail_op = NULL;
 
                /* Find last selected row */
-               if (MODEST_IS_MAIN_WINDOW (win)) {
-                       model = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
-                       sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
-                       sel_list = gtk_tree_selection_get_selected_rows (sel, &model);
-                       for (tmp=sel_list; tmp; tmp=tmp->next) {
-                               if (tmp->next == NULL) {
-                                       prev_path = gtk_tree_path_copy((GtkTreePath *) tmp->data);
-                                       next_path = gtk_tree_path_copy((GtkTreePath *) tmp->data);
-
-                                       gtk_tree_path_prev (prev_path);
-                                       gtk_tree_path_next (next_path);
-
-                                       prev_row_reference = gtk_tree_row_reference_new (model, prev_path);
-                                       next_row_reference = gtk_tree_row_reference_new (model, next_path);
-                               }
-                       }
-               }
 
                /* Disable window dimming management */
                modest_window_disable_dimming (win);
@@ -571,24 +434,6 @@ modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win)
 
                        /* Get main window */
                        mgr = modest_runtime_get_window_mgr ();
-               } else if (MODEST_IS_MAIN_WINDOW (win)) {
-                       /* Select next or previous row */
-                       if (gtk_tree_row_reference_valid (next_row_reference)) {
-                               gtk_tree_selection_select_path (sel, next_path);
-                       }
-                       else if (gtk_tree_row_reference_valid (prev_row_reference)) {
-                               gtk_tree_selection_select_path (sel, prev_path);
-                       }
-
-                       /* Free */
-                       if (gtk_tree_row_reference_valid (next_row_reference))
-                               gtk_tree_row_reference_free (next_row_reference);
-                       if (next_path != NULL)
-                               gtk_tree_path_free (next_path);
-                       if (gtk_tree_row_reference_valid (prev_row_reference))
-                               gtk_tree_row_reference_free (prev_row_reference);
-                       if (prev_path != NULL)
-                               gtk_tree_path_free (prev_path);
                }
 
                /* Update toolbar dimming state */
@@ -621,15 +466,6 @@ modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow *
        g_return_if_fail (MODEST_IS_WINDOW(win));
 
        /* Check first if the header view has the focus */
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *w;
-               w = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                        MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (gtk_widget_is_focus (w)) {
-                       modest_ui_actions_on_delete_folder (action, MODEST_WINDOW(win));
-                       return;
-               }
-       }
        modest_ui_actions_on_delete_message (action, win);
 }
 
@@ -639,7 +475,7 @@ modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
        ModestWindowMgr *mgr = NULL;
 
 #ifdef MODEST_PLATFORM_MAEMO
-       modest_osso_save_state();
+       modest_window_mgr_save_state_for_all_windows (modest_runtime_get_window_mgr ());
 #endif /* MODEST_PLATFORM_MAEMO */
 
        g_debug ("closing down, clearing %d item(s) from operation queue",
@@ -686,9 +522,10 @@ 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));
+       if (MODEST_IS_MSG_VIEW_WINDOW (win))
+               modest_msg_view_window_add_to_contacts (MODEST_MSG_VIEW_WINDOW (win));
+       else if (MODEST_IS_MSG_EDIT_WINDOW (win))
+               modest_msg_edit_window_add_to_contacts (MODEST_MSG_EDIT_WINDOW (win));
 }
 
 void
@@ -727,11 +564,14 @@ modest_ui_actions_on_accounts (GtkAction *action,
                return;
        } else {
                /* Show the list of accounts */
-               GtkWindow *account_win = GTK_WINDOW (modest_account_view_window_new ());
+               GtkWindow *toplevel, *account_win;
+
+               account_win = GTK_WINDOW (modest_account_view_window_new ());
+               toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (win)));
 
                /* 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));
+               modest_utils_show_dialog_and_forget (toplevel, GTK_DIALOG (account_win));
        }
 }
 
@@ -858,10 +698,8 @@ modest_ui_actions_compose_msg(ModestWindow *win,
        }
 
 
-#ifdef MODEST_TOOLKIT_HILDON2
        if (win)
                account_name = g_strdup (modest_window_get_active_account(win));
-#endif
        if (!account_name) {
                account_name = modest_account_mgr_get_default_account(mgr);
        }
@@ -1003,9 +841,14 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op,
                                if (protocol) {
                                        if (tny_account_get_connection_status (account) ==
                                            TNY_CONNECTION_STATUS_CONNECTED) {
-                                               format = modest_protocol_get_translation (protocol,
-                                                                                         MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE,
-                                                                                         subject);
+                                               if (header) {
+                                                       format = modest_protocol_get_translation (protocol,
+                                                                                                 MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE,
+                                                                                                 subject);
+                                               } else {
+                                                       format = modest_protocol_get_translation (protocol,
+                                                                                                 MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE_LOST_HEADER);
+                                               }
                                        } else {
                                                format = g_strdup_printf (_("mail_ib_backend_server_invalid"),
                                                                          tny_account_get_hostname (account));
@@ -1014,8 +857,13 @@ modest_ui_actions_msg_retrieval_check (ModestMailOperation *mail_op,
                                g_object_unref (account);
                        }
 
-                       if (!format)
-                               format = g_strdup (_("emev_ni_ui_imap_message_not_available_in_server"));
+                       if (!format) {
+                               if (header) {
+                                       format = g_strdup (_("emev_ni_ui_imap_message_not_available_in_server"));
+                               } else {
+                                       format = g_strdup (_("emev_ni_ui_pop3_msg_recv_error"));
+                               }
+                       }
 
                        msg = g_strdup_printf (format, subject);
                        modest_platform_run_information_dialog (NULL, msg, FALSE);
@@ -1069,13 +917,8 @@ get_header_view_from_window (ModestWindow *window)
 {
        GtkWidget *header_view;
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_HEADER_WINDOW (window)){
+       if (MODEST_IS_HEADER_WINDOW (window)){
                header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window)));
-#endif
        } else {
                header_view = NULL;
        }
@@ -1120,7 +963,6 @@ get_info_from_header (TnyHeader *header, gboolean *is_draft, gboolean *can_open)
                                if (status == MODEST_TNY_SEND_QUEUE_FAILED) {
                                        *is_draft = TRUE;
                                }
-#ifdef MODEST_TOOLKIT_HILDON2
                                else {
                                        /* In Fremantle we can not
                                           open any message from
@@ -1128,7 +970,6 @@ get_info_from_header (TnyHeader *header, gboolean *is_draft, gboolean *can_open)
                                           failed state */
                                        *can_open = FALSE;
                                 }
-#endif
                        }
                        g_object_unref(traccount);
                } else {
@@ -1240,10 +1081,6 @@ open_msg_cb (ModestMailOperation *mail_op,
                gtk_widget_show_all (GTK_WIDGET(win));
        }
 
-       /* Update toolbar dimming state */
-       if (MODEST_IS_MAIN_WINDOW (parent_win)) {
-               modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (parent_win));
-       }
 
 cleanup:
        /* Free */
@@ -1278,7 +1115,7 @@ modest_ui_actions_disk_operations_error_handler (ModestMailOperation *mail_op,
                } else if (error->domain == MODEST_MAIL_OPERATION_ERROR &&
                           error->code == MODEST_MAIL_OPERATION_ERROR_FILE_IO) {
                        modest_platform_information_banner ((GtkWidget *) win,
-                                                           NULL, _CS ("sfil_ni_unable_to_open_file_not_found"));
+                                                           NULL, _CS_UNABLE_TO_OPEN_FILE_NOT_FOUND);
                } else if (user_data) {
                        modest_platform_information_banner ((GtkWidget *) win,
                                                            NULL, user_data);
@@ -1434,22 +1271,6 @@ open_msg_performer(gboolean canceled,
                error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
        }
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       gboolean show_open_draft = FALSE;
-       if (modest_protocol_registry_protocol_type_has_tag (protocol_registry,
-                                                           proto,
-                                                           MODEST_PROTOCOL_REGISTRY_LOCAL_STORE_PROTOCOLS)) {
-               TnyFolder *folder;
-               TnyFolderType folder_type;
-
-               folder = tny_header_get_folder (helper->header);
-               folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder);
-               show_open_draft = (folder_type == TNY_FOLDER_TYPE_DRAFTS);
-               g_object_unref (folder);
-       }
-#endif
-
-#ifdef MODEST_TOOLKIT_HILDON2
        gboolean is_draft;
        gboolean can_open;
        gchar *account_name = get_info_from_header (helper->header, &is_draft, &can_open);
@@ -1488,7 +1309,6 @@ open_msg_performer(gboolean canceled,
                goto clean;
        }
        g_free (account_name);
-#endif
        /* Create the mail operation */
        mail_op =
                modest_mail_operation_new_with_error_handling ((GObject *) parent_window,
@@ -1498,16 +1318,6 @@ open_msg_performer(gboolean canceled,
                                         mail_op);
 
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       if (show_open_draft) {
-               helper->banner_info = g_slice_new (OpenMsgBannerInfo);
-               helper->banner_info->message = g_strdup (_("mail_ib_opening_draft_message"));
-               helper->banner_info->banner = NULL;
-               helper->banner_info->idle_handler = g_timeout_add (500, open_msg_banner_idle,
-                                                                  helper->banner_info);
-       }
-#endif
-
 
        TnyList *headers;
        headers = TNY_LIST (tny_simple_list_new ());
@@ -1544,7 +1354,7 @@ open_msg_from_header (TnyHeader *header, GtkTreeRowReference *rowref, ModestWind
        OpenMsgHelper *helper;
        ModestWindow *window;
 
-       g_return_if_fail (header != NULL && rowref != NULL);
+       g_return_if_fail (header != NULL && rowref != NULL && gtk_tree_row_reference_valid (rowref));
 
        mgr = modest_runtime_get_window_mgr ();
 
@@ -1928,7 +1738,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win)
        ReplyForwardHelper *rf_helper = NULL;
        guint reply_forward_type;
 
-       g_return_if_fail (MODEST_IS_WINDOW(win));
+       g_return_if_fail (win && MODEST_IS_WINDOW(win));
 
        /* we check for low-mem; in that case, show a warning, and don't allow
         * reply/forward (because it could potentially require a lot of memory */
@@ -2048,7 +1858,7 @@ reply_forward (ReplyForwardAction action, ModestWindow *win)
                        if (folder)
                                g_object_unref (folder);
                } else {
-                       reply_forward_cb (NULL, header, FALSE, NULL, NULL, rf_helper);
+                       reply_forward_cb (NULL, header, FALSE, NULL, NULL, NULL);
                }
                /* Frees */
                g_object_unref (header_list);
@@ -2084,18 +1894,7 @@ void
 modest_ui_actions_on_next (GtkAction *action,
                           ModestWindow *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)
-                       return;
-
-               modest_header_view_select_next (
-                               MODEST_HEADER_VIEW(header_view));
-       } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+       if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
                modest_msg_view_window_select_next_message (
                                MODEST_MSG_VIEW_WINDOW (window));
        } else {
@@ -2109,15 +1908,7 @@ modest_ui_actions_on_prev (GtkAction *action,
 {
        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)
-                       return;
-
-               modest_header_view_select_prev (MODEST_HEADER_VIEW(header_view));
-       } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+       if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
                modest_msg_view_window_select_previous_message (MODEST_MSG_VIEW_WINDOW (window));
        } else {
                g_return_if_reached ();
@@ -2132,37 +1923,79 @@ modest_ui_actions_on_sort (GtkAction *action,
 
        g_return_if_fail (MODEST_IS_WINDOW(window));
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_HEADER_WINDOW (window)) {
+       if (MODEST_IS_HEADER_WINDOW (window)) {
                header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window)));
-#endif
        }
 
        if (!header_view) {
-               modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort"));
+               modest_platform_information_banner (NULL, NULL, _CS_NOTHING_TO_SORT);
 
                return;
        }
 
        /* Show sorting dialog */
-       modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
+       modest_utils_run_sort_dialog (MODEST_WINDOW (window), MODEST_SORT_HEADERS);
 }
 
 static void
-new_messages_arrived (ModestMailOperation *self,
-                     TnyList *new_headers,
-                     gpointer user_data)
+sync_folder_cb (ModestMailOperation *mail_op,
+               TnyFolder *folder,
+               gpointer user_data)
+{
+       ModestHeaderView *header_view = (ModestHeaderView *) user_data;
+
+       if (modest_mail_operation_get_status (mail_op) == MODEST_MAIL_OPERATION_STATUS_SUCCESS) {
+               ModestWindow *parent = (ModestWindow *) modest_mail_operation_get_source (mail_op);
+
+               /* We must clear first, because otherwise set_folder will ignore */
+               /*    the change as the folders are the same */
+               modest_header_view_clear (header_view);
+               modest_header_view_set_folder (header_view, folder, TRUE, parent, NULL, NULL);
+
+               g_object_unref (parent);
+       }
+
+       g_object_unref (header_view);
+}
+
+static gboolean
+idle_refresh_folder (gpointer source)
+{
+       ModestHeaderView *header_view = NULL;
+
+       /* If the window still exists */
+       if (!GTK_IS_WIDGET (source) ||
+           !GTK_WIDGET_VISIBLE (source))
+               return FALSE;
+
+       /* Refresh the current view */
+       if (MODEST_IS_HEADER_WINDOW (source))
+               header_view = modest_header_window_get_header_view ((ModestHeaderWindow *) source);
+       if (header_view) {
+               TnyFolder *folder = modest_header_view_get_folder (header_view);
+               if (folder) {
+                       /* Sync the folder status */
+                       ModestMailOperation *mail_op = modest_mail_operation_new (source);
+                       modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+                       modest_mail_operation_sync_folder (mail_op, folder, FALSE, sync_folder_cb, g_object_ref (header_view));
+                       g_object_unref (folder);
+                       g_object_unref (mail_op);
+               }
+       }
+
+       return FALSE;
+}
+
+static void
+update_account_cb (ModestMailOperation *self,
+                  TnyList *new_headers,
+                  gpointer user_data)
 {
-       GObject *source;
+       ModestWindow *top;
        gboolean show_visual_notifications;
 
-       source = modest_mail_operation_get_source (self);
-       show_visual_notifications = (source) ? FALSE : TRUE;
-       if (source)
-               g_object_unref (source);
+       top = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
+       show_visual_notifications = (top) ? FALSE : TRUE;
 
        /* Notify new messages have been downloaded. If the
           send&receive was invoked by the user then do not show any
@@ -2210,29 +2043,15 @@ new_messages_arrived (ModestMailOperation *self,
                g_object_unref (actually_new_list);
        }
 
-}
-
-gboolean
-retrieve_all_messages_cb (GObject *source,
-                         guint num_msgs,
-                         guint retrieve_limit)
-{
-       GtkWindow *window;
-       gchar *msg;
-       gint response;
-
-       window = GTK_WINDOW (source);
-       msg = g_strdup_printf (_("mail_nc_msg_count_limit_exceeded"),
-                              num_msgs, retrieve_limit);
-
-       /* Ask the user if they want to retrieve all the messages */
-       response =
-               modest_platform_run_confirmation_dialog_with_buttons (window, msg,
-                                                                     _("mcen_bd_get_all"),
-                                                                     _("mcen_bd_newest_only"));
-       /* Free and return */
-       g_free (msg);
-       return (response == GTK_RESPONSE_ACCEPT) ? TRUE : FALSE;
+       if (top) {
+               /* Refresh the current folder in an idle. We do this
+                  in order to avoid refresh cancelations if the
+                  currently viewed folder is the inbox */
+               g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+                                idle_refresh_folder,
+                                g_object_ref (top),
+                                g_object_unref);
+       }
 }
 
 typedef struct {
@@ -2268,20 +2087,11 @@ do_send_receive_performer (gboolean canceled,
                goto clean;
        }
 
-       /* Set send/receive operation in progress */
-       if (info->win && MODEST_IS_MAIN_WINDOW (info->win)) {
-               modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW (info->win));
-       }
-
-       if (info->win && MODEST_IS_MAIN_WINDOW (info->win))
-               g_signal_connect (G_OBJECT (info->mail_op), "operation-finished",
-                                 G_CALLBACK (on_send_receive_finished),
-                                 info->win);
 
        /* Send & receive. */
-       modest_mail_operation_update_account (info->mail_op, info->account_name, info->poke_status, info->interactive,
-                                             (info->win) ? retrieve_all_messages_cb : NULL,
-                                             new_messages_arrived, info->win);
+       modest_mail_operation_update_account (info->mail_op, info->account_name,
+                                             info->poke_status, info->interactive,
+                                             update_account_cb, info->win);
 
  clean:
        /* Frees */
@@ -2494,27 +2304,8 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
                modest_ui_actions_on_accounts (NULL, win);
 
        /* Refresh the current folder. The if is always TRUE it's just an extra check */
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *folder_view;
-               TnyFolderStore *folder_store;
-
-               folder_view =
-                       modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                            MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (!folder_view)
-                       return;
-
-               folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-               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);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_ACCOUNTS_WINDOW (win)) {
+       if (MODEST_IS_ACCOUNTS_WINDOW (win)) {
                modest_ui_actions_do_send_receive_all (win, TRUE, TRUE, TRUE);
-#endif
        } else {
                const gchar *active_account;
                active_account = modest_window_get_active_account (MODEST_WINDOW (win));
@@ -2526,82 +2317,11 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
 
 
 void
-modest_ui_actions_toggle_header_list_view (GtkAction *action, ModestMainWindow *main_window)
-{
-       ModestConf *conf;
-       GtkWidget *header_view;
-
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-
-       header_view = modest_main_window_get_child_widget (main_window,
-                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-       if (!header_view)
-               return;
-
-       conf = modest_runtime_get_conf ();
-
-       /* what is saved/restored is depending on the style; thus; we save with
-        * old style, then update the style, and restore for this new style
-        */
-       modest_widget_memory_save (conf, G_OBJECT(header_view), MODEST_CONF_HEADER_VIEW_KEY);
-
-       if (modest_header_view_get_style
-           (MODEST_HEADER_VIEW(header_view)) == MODEST_HEADER_VIEW_STYLE_DETAILS)
-               modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
-                                             MODEST_HEADER_VIEW_STYLE_TWOLINES);
-       else
-               modest_header_view_set_style (MODEST_HEADER_VIEW(header_view),
-                                             MODEST_HEADER_VIEW_STYLE_DETAILS);
-
-       modest_widget_memory_restore (conf, G_OBJECT(header_view),
-                                     MODEST_CONF_HEADER_VIEW_KEY);
-}
-
-
-void
-modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
-                                     TnyHeader *header,
-                                     ModestMainWindow *main_window)
-{
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-       g_return_if_fail (MODEST_IS_HEADER_VIEW (header_view));
-
-       /* in the case the folder is empty, show the empty folder message and focus
-        * folder view */
-       if (!header && gtk_widget_is_focus (GTK_WIDGET (header_view))) {
-               if (modest_header_view_is_empty (header_view)) {
-                       TnyFolder *folder = modest_header_view_get_folder (header_view);
-                       GtkWidget *folder_view =
-                               modest_main_window_get_child_widget (main_window,
-                                                                    MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-                       if (folder != NULL) {
-                               modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view), folder, FALSE);
-                               g_object_unref (folder);
-                       }
-                       gtk_widget_grab_focus (GTK_WIDGET (folder_view));
-                       return;
-               }
-       }
-       /* If no header has been selected then exit */
-       if (!header)
-               return;
-
-       /* Update focus */
-       if (!gtk_widget_is_focus (GTK_WIDGET(header_view)))
-           gtk_widget_grab_focus (GTK_WIDGET(header_view));
-
-       /* Update toolbar dimming state */
-       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
-       modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
-}
-
-void
 modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
                                       TnyHeader *header,
                                       GtkTreePath *path,
                                       ModestWindow *window)
 {
-       GtkWidget *open_widget;
        GtkTreeRowReference *rowref;
 
        g_return_if_fail (MODEST_IS_WINDOW(window));
@@ -2620,179 +2340,12 @@ modest_ui_actions_on_header_activated (ModestHeaderView *header_view,
        if (modest_platform_check_memory_low (MODEST_WINDOW(window), TRUE))
                return;
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
-               open_widget = modest_window_get_action_widget (MODEST_WINDOW (window), "/MenuBar/EmailMenu/EmailOpenMenu");
-               if (!GTK_WIDGET_IS_SENSITIVE (open_widget))
-                       return;
-       }
 
        rowref = gtk_tree_row_reference_new (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)), path);
        open_msg_from_header (header, rowref, MODEST_WINDOW (window));
        gtk_tree_row_reference_free (rowref);
 }
 
-static void
-set_active_account_from_tny_account (TnyAccount *account,
-                                    ModestWindow *window)
-{
-       const gchar *server_acc_name = tny_account_get_id (account);
-
-       /* We need the TnyAccount provided by the
-          account store because that is the one that
-          knows the name of the Modest account */
-       TnyAccount *modest_server_account =
-               modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store (),
-                                                            MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
-                                                            server_acc_name);
-       if (!modest_server_account) {
-               g_warning ("%s: could not get tny account\n", __FUNCTION__);
-               return;
-       }
-
-       /* Update active account, but only if it's not a pseudo-account */
-       if ((!modest_tny_account_is_virtual_local_folders(modest_server_account)) &&
-           (!modest_tny_account_is_memory_card_account(modest_server_account))) {
-               const gchar *modest_acc_name =
-                       modest_tny_account_get_parent_modest_account_name_for_server_account (modest_server_account);
-               if (modest_acc_name)
-                       modest_window_set_active_account (window, modest_acc_name);
-       }
-
-       g_object_unref (modest_server_account);
-}
-
-
-static void
-folder_refreshed_cb (ModestMailOperation *mail_op,
-                    TnyFolder *folder,
-                    gpointer user_data)
-{
-       ModestMainWindow *win = NULL;
-       GtkWidget *folder_view, *header_view;
-       const GError *error;
-
-       g_return_if_fail (TNY_IS_FOLDER (folder));
-
-       win = MODEST_MAIN_WINDOW (user_data);
-
-       /* Check if the operation failed due to memory low conditions */
-       error = modest_mail_operation_get_error (mail_op);
-       if (error && error->domain == MODEST_MAIL_OPERATION_ERROR &&
-           error->code == MODEST_MAIL_OPERATION_ERROR_LOW_MEMORY) {
-               modest_platform_run_information_dialog (GTK_WINDOW (win),
-                                                       _KR("memr_ib_operation_disabled"),
-                                                       TRUE);
-               return;
-       }
-
-       folder_view =
-               modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-       header_view =
-               modest_main_window_get_child_widget(win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-
-       if (folder_view) {
-               TnyFolderStore *current_folder;
-
-               current_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-               if (current_folder) {
-                       gboolean different = ((TnyFolderStore *) folder != current_folder);
-                       g_object_unref (current_folder);
-                       if (different)
-                               return;
-               }
-       }
-
-       /* Check if folder is empty and set headers view contents style */
-       if ((tny_folder_get_all_count (folder) == 0) ||
-           modest_header_view_is_empty (MODEST_HEADER_VIEW (header_view)))
-               modest_main_window_set_contents_style (win,
-                                                      MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
-}
-
-void
-modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
-                                              TnyFolderStore *folder_store,
-                                              gboolean selected,
-                                              ModestMainWindow *main_window)
-{
-       GtkWidget *header_view;
-
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-
-       header_view = modest_main_window_get_child_widget(main_window,
-                                                         MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-       if (!header_view)
-               return;
-
-
-       if (TNY_IS_ACCOUNT (folder_store)) {
-               if (selected) {
-                       set_active_account_from_tny_account (TNY_ACCOUNT (folder_store), MODEST_WINDOW (main_window));
-
-                       /* Show account details */
-                       modest_main_window_set_contents_style (main_window, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
-               }
-       } else {
-               if (TNY_IS_FOLDER (folder_store) && selected) {
-                       TnyAccount *account;
-
-                       /* Update the active account */
-                       account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
-                       if (account) {
-                               set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
-                               g_object_unref (account);
-                               account = NULL;
-                       }
-
-                       /* Set the header style by default, it could
-                          be changed later by the refresh callback to
-                          empty */
-                       modest_main_window_set_contents_style (main_window,
-                                                              MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
-
-                       /* Set folder on header view. This function
-                          will call tny_folder_refresh_async so we
-                          pass a callback that will be called when
-                          finished. We use that callback to set the
-                          empty view if there are no messages */
-                       modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
-                                                      TNY_FOLDER (folder_store),
-                                                      TRUE,
-                                                      MODEST_WINDOW (main_window),
-                                                      folder_refreshed_cb,
-                                                      main_window);
-
-                       /* Restore configuration. We need to do this
-                          *after* the set_folder because the widget
-                          memory asks the header view about its
-                          folder  */
-                       modest_widget_memory_restore (modest_runtime_get_conf (),
-                                                     G_OBJECT(header_view),
-                                                     MODEST_CONF_HEADER_VIEW_KEY);
-               } else {
-                       /* No need to save the header view
-                          configuration for Maemo because it only
-                          saves the sorting stuff and that it's
-                          already being done by the sort
-                          dialog. Remove it when the GNOME version
-                          has the same behaviour */
-#ifdef MODEST_TOOLKIT_GTK
-                       if (modest_main_window_get_contents_style (main_window) ==
-                           MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
-                               modest_widget_memory_save (modest_runtime_get_conf (), 
-                                                          G_OBJECT (header_view),
-                                                          MODEST_CONF_HEADER_VIEW_KEY);
-#endif
-                       modest_header_view_clear (MODEST_HEADER_VIEW(header_view));
-               }
-       }
-
-       /* Update dimming state */
-       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (main_window));
-       modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (main_window));
-}
-
 void
 modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,ModestItemType type,
                                     ModestWindow *win)
@@ -2891,20 +2444,6 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op,
        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
-        * temporary hack. See modest_ui_actions_on_save_to_drafts()
-        * for details */
-       win = MODEST_MAIN_WINDOW(modest_window_mgr_get_main_window(
-                                        modest_runtime_get_window_mgr(), FALSE));
-       if (win != NULL) {
-               GtkWidget *hdrview = modest_main_window_get_child_widget(
-                       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);
 
@@ -2977,7 +2516,6 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
        gchar *account_name;
        ModestAccountMgr *account_mgr;
        gboolean had_error = FALSE;
-       ModestMainWindow *win = NULL;
 
        g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), FALSE);
 
@@ -3040,27 +2578,12 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
                                              on_save_to_drafts_cb,
                                              g_object_ref(edit_window));
 
-#ifdef MODEST_TOOLKIT_HILDON2
        /* In hildon2 we always show the information banner on saving to drafts.
         * It will be a system information banner in this case.
         */
        gchar *text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
        modest_platform_information_banner (NULL, NULL, text);
        g_free (text);
-#else
-       /* Use the main window as the parent of the banner, if the
-          main window does not exist it won't be shown, if the parent
-          window exists then it's properly shown. We don't use the
-          editor window because it could be closed (save to drafts
-          could happen after closing the window */
-       win = (ModestMainWindow *)
-               modest_window_mgr_get_main_window( modest_runtime_get_window_mgr(), FALSE);
-       if (win) {
-               gchar *text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
-               modest_platform_information_banner (GTK_WIDGET (win), NULL, text);
-               g_free (text);
-       }
-#endif
        modest_msg_edit_window_set_modified (edit_window, FALSE);
 
        /* Frees */
@@ -3070,40 +2593,6 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
 
        modest_msg_edit_window_free_msg_data (edit_window, data);
 
-       /* ** FIXME **
-        * If the drafts folder is selected then make the header view
-        * insensitive while the message is being saved to drafts
-        * (it'll be sensitive again in on_save_to_drafts_cb()). This
-        * is not very clean but it avoids letting the drafts folder
-        * in an inconsistent state: the user could edit the message
-        * being saved and undesirable things would happen.
-        * In the average case the user won't notice anything at
-        * all. In the worst case (the user is editing a really big
-        * file from Drafts) the header view will be insensitive
-        * during the saving process (10 or 20 seconds, depending on
-        * the message). Anyway this is just a quick workaround: once
-        * we find a better solution it should be removed
-        * See NB#65125 (commend #18) for details.
-        */
-       if (!had_error && win != NULL) {
-               ModestFolderView *view = MODEST_FOLDER_VIEW(modest_main_window_get_child_widget(
-                       win, MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW));
-               if (view != NULL) {
-                       TnyFolder *folder = TNY_FOLDER(modest_folder_view_get_selected(view));
-                       if (folder) {
-                               if (modest_tny_folder_is_local_folder(folder)) {
-                                       TnyFolderType folder_type;
-                                       folder_type = modest_tny_folder_get_local_or_mmc_folder_type(folder);
-                                       if (folder_type == TNY_FOLDER_TYPE_DRAFTS) {
-                                               GtkWidget *hdrview = modest_main_window_get_child_widget(
-                                                       win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-                                               if (hdrview) gtk_widget_set_sensitive(hdrview, FALSE);
-                                       }
-                               }
-                       }
-                       if (folder != NULL) g_object_unref(folder);
-               }
-       }
 
        return !had_error;
 }
@@ -3113,7 +2602,7 @@ gboolean
 modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
 {
        TnyTransportAccount *transport_account = NULL;
-       gboolean had_error = FALSE;
+       gboolean had_error = FALSE, add_to_contacts;
        MsgData *data;
        ModestAccountMgr *account_mgr;
        gchar *account_name;
@@ -3122,17 +2611,14 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
 
        g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE);
 
-       if (!modest_msg_edit_window_check_names (edit_window, TRUE))
+       /* Check whether to automatically add new contacts to addressbook or not */
+       add_to_contacts = modest_conf_get_bool (modest_runtime_get_conf (),
+                                               MODEST_CONF_AUTO_ADD_TO_CONTACTS, NULL);
+       if (!modest_msg_edit_window_check_names (edit_window, add_to_contacts))
                return TRUE;
 
        data = modest_msg_edit_window_get_msg_data (edit_window);
 
-       if (data->subject == NULL || data->subject[0] == '\0') {
-               /* Empty subject -> no send */
-               modest_msg_edit_window_free_msg_data (edit_window, data);
-               return FALSE;
-       }
-
        recipients = g_strconcat (data->to?data->to:"", 
                                  data->cc?data->cc:"",
                                  data->bcc?data->bcc:"",
@@ -3168,7 +2654,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
        }
 
        /* Get the currently-active transport account for this modest account: */
-       if (strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) {
+       if (account_name && strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) {
                transport_account =
                        TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account
                                              (modest_runtime_get_account_store (),
@@ -3211,7 +2697,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
                if (error->domain == MODEST_MAIL_OPERATION_ERROR &&
                    error->code == MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED) {
                        g_warning ("%s failed: %s\n", __FUNCTION__, (modest_mail_operation_get_error (mail_operation))->message);
-                       modest_platform_information_banner (NULL, NULL, _CS("sfil_ni_not_enough_memory"));
+                       modest_platform_information_banner (NULL, NULL, _CS_NOT_ENOUGH_MEMORY);
                        had_error = TRUE;
                }
        }
@@ -3342,7 +2828,6 @@ modest_ui_actions_on_select_editor_background_color (GtkAction *action,
        if (modest_msg_edit_window_get_format (MODEST_MSG_EDIT_WINDOW(window)) == MODEST_MSG_EDIT_FORMAT_TEXT)
                return;
 
-       modest_msg_edit_window_select_background_color (window);
 }
 
 void
@@ -3419,7 +2904,8 @@ do_create_folder_cb (ModestMailOperation *mail_op,
                           full memory condition */
                        modest_platform_information_banner ((GtkWidget *) source_win, NULL,
                                                            _("mail_in_ui_folder_create_error"));
-                       do_create_folder (source_win, parent_folder, (const gchar *) suggested_name);
+                       do_create_folder ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (source_win)),
+                                         parent_folder, (const gchar *) suggested_name);
                }
 
        } else {
@@ -3427,11 +2913,6 @@ do_create_folder_cb (ModestMailOperation *mail_op,
                 * FIXME: any other? */
                GtkWidget *folder_view;
 
-               if (MODEST_IS_MAIN_WINDOW(source_win))
-                       folder_view =
-                               modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (source_win),
-                                                                    MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               else
                        folder_view = GTK_WIDGET(g_object_get_data (G_OBJECT (source_win),
                                                                    MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
 
@@ -3471,7 +2952,7 @@ do_create_folder_performer (gboolean canceled,
 
                /* This happens if we have selected the outbox folder
                   as the parent */
-               if (err->code == TNY_SERVICE_ERROR_UNKNOWN &&
+               if (err && err->code == TNY_SERVICE_ERROR_UNKNOWN &&
                    TNY_IS_MERGE_FOLDER (helper->parent)) {
                        /* Show an error and retry */
                        modest_platform_information_banner ((GtkWidget *) parent_window,
@@ -3523,7 +3004,7 @@ do_create_folder (GtkWindow *parent_window,
                helper->folder_name = g_strdup (folder_name);
                helper->parent = g_object_ref (parent_folder);
 
-               modest_platform_connect_if_remote_and_perform (GTK_WINDOW (parent_window),
+               modest_platform_connect_if_remote_and_perform (parent_window,
                                                               TRUE,
                                                               parent_folder,
                                                               do_create_folder_performer,
@@ -3537,21 +3018,17 @@ do_create_folder (GtkWindow *parent_window,
 }
 
 static void
-modest_ui_actions_create_folder(GtkWidget *parent_window,
+modest_ui_actions_create_folder(GtkWindow *parent_window,
                                 GtkWidget *folder_view,
                                TnyFolderStore *parent_folder)
 {
        if (!parent_folder) {
-#ifdef MODEST_TOOLKIT_HILDON2
                ModestTnyAccountStore *acc_store;
 
                acc_store = modest_runtime_get_account_store ();
 
                parent_folder = (TnyFolderStore *)
                        modest_tny_account_store_get_local_folders_account (acc_store);
-#else
-               parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
-#endif
        }
 
        if (parent_folder) {
@@ -3566,22 +3043,13 @@ modest_ui_actions_on_new_folder (GtkAction *action, ModestWindow *window)
 
        g_return_if_fail (MODEST_IS_WINDOW(window));
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               GtkWidget *folder_view;
-
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (!folder_view)
-                       return;
-
-               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view, NULL);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_FOLDER_WINDOW (window)) {
+       if (MODEST_IS_FOLDER_WINDOW (window)) {
                GtkWidget *folder_view;
+               GtkWindow *toplevel;
 
                folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window)));
-               modest_ui_actions_create_folder (GTK_WIDGET (window), folder_view, NULL);
-#endif
+               toplevel = (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) window);
+               modest_ui_actions_create_folder (toplevel, folder_view, NULL);
        } else {
                g_assert_not_reached ();
        }
@@ -3607,14 +3075,14 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op,
                message = g_strdup_printf (_KR("cerm_device_memory_full"), "");
        } else if (error->domain == MODEST_MAIL_OPERATION_ERROR &&
                   error->code == MODEST_MAIL_OPERATION_ERROR_FOLDER_EXISTS) {
-               message = _CS("ckdg_ib_folder_already_exists");
+               message = _CS_FOLDER_ALREADY_EXISTS;
        } else if (error->domain == TNY_ERROR_DOMAIN &&
                   error->code == TNY_SERVICE_ERROR_STATE) {
                /* This means that the folder is already in use (a
                   message is opened for example */
                message = _("emev_ni_internal_error");
        } else {
-               message = _CS("ckdg_ib_unable_to_rename");
+               message = _CS_UNABLE_TO_RENAME;
        }
 
        /* We don't set a parent for the dialog because the dialog
@@ -3648,8 +3116,6 @@ on_rename_folder_cb (ModestMailOperation *mail_op,
        /* Note that if the rename fails new_folder will be NULL */
        if (new_folder) {
                modest_folder_view_select_folder (folder_view, new_folder, FALSE);
-       } else {
-               modest_folder_view_select_first_inbox_or_local (folder_view);
        }
        gtk_widget_grab_focus (GTK_WIDGET (folder_view));
 }
@@ -3680,19 +3146,10 @@ on_rename_folder_performer (gboolean canceled,
 
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                mail_op);
-
-               if (MODEST_IS_MAIN_WINDOW(parent_window)) {
-
-                       folder_view = modest_main_window_get_child_widget (
-                               MODEST_MAIN_WINDOW (parent_window),
-                               MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               }
-#ifdef MODEST_TOOLKIT_HILDON2
-               else if (MODEST_IS_FOLDER_WINDOW (parent_window)) {
+               if (MODEST_IS_FOLDER_WINDOW (parent_window)) {
                        ModestFolderWindow *folder_window = (ModestFolderWindow *) parent_window;
                        folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (folder_window));
                }
-#endif
 
                /* Clear the folders view */
                sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view));
@@ -3728,16 +3185,8 @@ modest_ui_actions_on_edit_mode_rename_folder (ModestWindow *window)
 
        g_return_val_if_fail (MODEST_IS_WINDOW(window), FALSE);
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (!folder_view)
-                       return FALSE;
-
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_FOLDER_WINDOW (window)) {
+       if (MODEST_IS_FOLDER_WINDOW (window)) {
                folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window)));
-#endif
        } else {
                return FALSE;
        }
@@ -3755,7 +3204,7 @@ modest_ui_actions_on_edit_mode_rename_folder (ModestWindow *window)
 
                current_name = tny_folder_get_name (TNY_FOLDER (folder));
                parent = tny_folder_get_folder_store (TNY_FOLDER (folder));
-               response = modest_platform_run_rename_folder_dialog (GTK_WINDOW (window),
+               response = modest_platform_run_rename_folder_dialog (MODEST_WINDOW (window),
                                                                     parent, current_name,
                                                                     &folder_name);
                g_object_unref (parent);
@@ -3816,14 +3265,8 @@ on_delete_folder_cb (gboolean canceled,
                return;
        }
 
-       if (MODEST_IS_MAIN_WINDOW (parent_window)) {
-               folder_view = modest_main_window_get_child_widget (
-                       MODEST_MAIN_WINDOW (parent_window),
-                       MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_FOLDER_WINDOW (parent_window)) {
+       if (MODEST_IS_FOLDER_WINDOW (parent_window)) {
                folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (parent_window)));
-#endif
        } else {
                g_object_unref (G_OBJECT (info->folder));
                g_free (info);
@@ -3844,10 +3287,8 @@ on_delete_folder_cb (gboolean canceled,
                        mail_op);
        modest_mail_operation_remove_folder (mail_op, TNY_FOLDER (info->folder), info->move_to_trash);
 
-       modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view));
-
-       g_object_unref (G_OBJECT (mail_op));
-       g_object_unref (G_OBJECT (info->folder));
+       g_object_unref (mail_op);
+       g_object_unref (info->folder);
        g_free (info);
 }
 
@@ -3861,14 +3302,8 @@ delete_folder (ModestWindow *window, gboolean move_to_trash)
 
        g_return_val_if_fail (MODEST_IS_WINDOW(window), FALSE);
 
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_FOLDER_WINDOW (window)) {
+       if (MODEST_IS_FOLDER_WINDOW (window)) {
                folder_view = GTK_WIDGET (modest_folder_window_get_folder_view (MODEST_FOLDER_WINDOW (window)));
-#endif
        } else {
                return FALSE;
        }
@@ -3897,22 +3332,23 @@ delete_folder (ModestWindow *window, gboolean move_to_trash)
        g_free (message);
 
        if (response == GTK_RESPONSE_OK) {
-               DeleteFolderInfo *info;
+               TnyAccount *account = NULL;
+               DeleteFolderInfo *info = NULL;
                info = g_new0(DeleteFolderInfo, 1);
-               info->folder = folder;
+               info->folder = g_object_ref (folder);
                info->move_to_trash = move_to_trash;
-               g_object_ref (G_OBJECT (info->folder));
-               TnyAccount *account = tny_folder_get_account (TNY_FOLDER (folder));
+
+               account = tny_folder_get_account (TNY_FOLDER (folder));
                modest_platform_connect_if_remote_and_perform (GTK_WINDOW (window),
                                                               TRUE,
                                                               TNY_FOLDER_STORE (account),
                                                               on_delete_folder_cb, info);
                g_object_unref (account);
+               g_object_unref (folder);
                return TRUE;
        } else {
                return FALSE;
        }
-       g_object_unref (G_OBJECT (folder));
 }
 
 void
@@ -3930,14 +3366,6 @@ modest_ui_actions_on_edit_mode_delete_folder (ModestWindow *window)
        return delete_folder (window, FALSE);
 }
 
-void
-modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action, ModestMainWindow *main_window)
-{
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-
-       delete_folder (MODEST_WINDOW (main_window), TRUE);
-}
-
 
 typedef struct _PasswordDialogFields {
        GtkWidget *username;
@@ -3952,19 +3380,11 @@ password_dialog_check_field (GtkEditable *editable,
        const gchar *value;
        gboolean any_value_empty = FALSE;
 
-#ifdef MODEST_TOOLKIT_HILDON2
-       value = hildon_entry_get_text (HILDON_ENTRY (fields->username));
-#else
-       value = gtk_entry_get_text (GTK_ENTRY (fields->username));
-#endif
+       value = modest_entry_get_text (fields->username);
        if ((value == NULL) || value[0] == '\0') {
                any_value_empty = TRUE;
        }
-#ifdef MODEST_TOOLKIT_HILDON2
-       value = hildon_entry_get_text (HILDON_ENTRY (fields->password));
-#else
-       value = gtk_entry_get_text (GTK_ENTRY (fields->password));
-#endif
+       value = modest_entry_get_text (fields->password);
        if ((value == NULL) || value[0] == '\0') {
                any_value_empty = TRUE;
        }
@@ -4000,7 +3420,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                gtk_dialog_new_with_buttons (_("mail_ti_password_protected"),
                                             NULL,
                                             GTK_DIALOG_MODAL,
-                                            _HL("wdgt_bd_done"),
+                                            _HL_DONE,
                                             GTK_RESPONSE_ACCEPT,
                                             NULL);
        gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
@@ -4053,15 +3473,10 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
        gchar *initial_username = modest_account_mgr_get_server_account_username (
                modest_runtime_get_account_mgr(), server_account_name);
 
-#ifdef MODEST_TOOLKIT_HILDON2
-       GtkWidget *entry_username = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
+       GtkWidget *entry_username = modest_toolkit_factory_create_entry (modest_runtime_get_toolkit_factory ());
        if (initial_username)
-               hildon_entry_set_text (HILDON_ENTRY (entry_username), initial_username);
-#else
-       GtkWidget *entry_username = gtk_entry_new ();
-       if (initial_username)
-               gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
-#endif
+               modest_entry_set_text (entry_username, initial_username);
+
        /* Dim this if a connection has ever succeeded with this username,
         * as per the UI spec: */
        /* const gboolean username_known =  */
@@ -4074,63 +3489,43 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
         */
        gtk_widget_set_sensitive (entry_username, FALSE);
 
-#ifndef MODEST_TOOLKIT_GTK
        /* Auto-capitalization is the default, so let's turn it off: */
+#ifdef MAEMO_CHANGES
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_username), HILDON_GTK_INPUT_MODE_FULL);
+#endif
 
        /* 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);
 
-#ifdef MODEST_TOOLKIT_HILDON2
-       GtkWidget *caption = modest_maemo_utils_create_captioned (sizegroup, NULL,
-                                                                 _("mail_fi_username"), FALSE,
-                                                                 entry_username);
-#else
-       GtkWidget *caption = hildon_caption_new (sizegroup,
-               _("mail_fi_username"), entry_username, NULL, HILDON_CAPTION_MANDATORY);
-#endif
+       GtkWidget *caption = modest_toolkit_utils_create_captioned (sizegroup, NULL,
+                                                                   _("mail_fi_username"), FALSE,
+                                                                   entry_username);
        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
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_username,
-                           TRUE, FALSE, 0);
-#endif /* !MODEST_TOOLKIT_GTK */
 
        /* password: */
-#ifdef MODEST_TOOLKIT_HILDON2
-       GtkWidget *entry_password = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
-#else
-       GtkWidget *entry_password = gtk_entry_new ();
-#endif
+       GtkWidget *entry_password = modest_toolkit_factory_create_entry (modest_runtime_get_toolkit_factory ());
        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: */
+#ifdef MAEMO_CHANGES
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry_password),
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
-
-#ifdef MODEST_TOOLKIT_HILDON2
-       caption = modest_maemo_utils_create_captioned (sizegroup, NULL,
-                                                      _("mail_fi_password"), FALSE,
-                                                      entry_password);
-#else
-       caption = hildon_caption_new (sizegroup,
-               _("mail_fi_password"), entry_password, NULL, HILDON_CAPTION_MANDATORY);
 #endif
+
+       caption = modest_toolkit_utils_create_captioned (sizegroup, NULL,
+                                                        _("mail_fi_password"), FALSE,
+                                                        entry_password);
        gtk_widget_show (entry_password);
        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
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry_password,
-                           TRUE, FALSE, 0);
-#endif /* !MODEST_TOOLKIT_GTK */
 
        if (initial_username != NULL)
                gtk_widget_grab_focus (GTK_WIDGET (entry_password));
@@ -4156,11 +3551,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
 
                if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
                        if (username) {
-#ifdef MODEST_TOOLKIT_HILDON2
-                               *username = g_strdup (hildon_entry_get_text (HILDON_ENTRY(entry_username)));
-#else
-                               *username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
-#endif
+                               *username = g_strdup (modest_entry_get_text (entry_username));
 
                                /* Note that an empty field becomes the "" string */
                                if (*username && strlen (*username) > 0) {
@@ -4186,11 +3577,7 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                        }
 
                        if (password) {
-#ifdef MODEST_TOOLKIT_HILDON2
-                               *password = g_strdup (hildon_entry_get_text (HILDON_ENTRY(entry_password)));
-#else
-                               *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_password)));
-#endif
+                               *password = g_strdup (modest_entry_get_text (entry_password));
 
                                /* We do not save the password in the configuration,
                                 * because this function is only called for passwords that should
@@ -4203,10 +3590,6 @@ modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                        if (cancel)
                                *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;
@@ -4341,7 +3724,7 @@ modest_ui_actions_on_copy (GtkAction *action,
 
                if (num_of_unc_msgs == 0 || continue_download) {
                        modest_platform_information_banner (
-                                       NULL, NULL, _CS("mcen_ib_getting_items"));
+                                       NULL, NULL, _CS_GETTING_ITEMS);
                        modest_header_view_copy_selection (
                                        MODEST_HEADER_VIEW (focused_widget));
                } else
@@ -4356,23 +3739,16 @@ modest_ui_actions_on_copy (GtkAction *action,
        /* Show information banner if there was a copy to clipboard */
        if(copied)
                modest_platform_information_banner (
-                               NULL, NULL, _CS("ecoc_ib_edwin_copied"));
+                               NULL, NULL, _CS_COPIED);
 }
 
 void
 modest_ui_actions_on_undo (GtkAction *action,
                           ModestWindow *window)
 {
-       ModestEmailClipboard *clipboard = NULL;
-
        if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
                modest_msg_edit_window_undo (MODEST_MSG_EDIT_WINDOW (window));
-       } else if (MODEST_IS_MAIN_WINDOW (window)) {
-               /* Clear clipboard source */
-               clipboard = modest_runtime_get_email_clipboard ();
-               modest_email_clipboard_clear (clipboard);
-       }
-       else {
+       } else {
                g_return_if_reached ();
        }
 }
@@ -4465,7 +3841,7 @@ modest_ui_actions_on_paste (GtkAction *action,
                        PasteAsAttachmentHelper *helper = g_new0 (PasteAsAttachmentHelper, 1);
                        helper->window = MODEST_MSG_EDIT_WINDOW (window);
                        helper->banner = modest_platform_animation_banner (GTK_WIDGET (window), NULL,
-                                                                          _CS("ckct_nw_pasting"));
+                                                                          _CS_PASTING);
                        modest_email_clipboard_get_data (e_clipboard, &src_folder, &data, &delete);
                        mail_op = modest_mail_operation_new (G_OBJECT (window));
                        if (helper->banner != NULL) {
@@ -4522,7 +3898,7 @@ modest_ui_actions_on_paste (GtkAction *action,
                        if (response == GTK_RESPONSE_OK) {
                                /* Launch notification */
                                inf_note = modest_platform_animation_banner (GTK_WIDGET (window), NULL,
-                                                                            _CS("ckct_nw_pasting"));
+                                                                            _CS_PASTING);
                                if (inf_note != NULL)  {
                                        gtk_window_set_modal (GTK_WINDOW(inf_note), FALSE);
                                        gtk_widget_show (GTK_WIDGET(inf_note));
@@ -4542,7 +3918,7 @@ modest_ui_actions_on_paste (GtkAction *action,
                } else if (src_folder != NULL) {
                        /* Launch notification */
                        inf_note = modest_platform_animation_banner (GTK_WIDGET (window), NULL,
-                                                                    _CS("ckct_nw_pasting"));
+                                                                    _CS_PASTING);
                        if (inf_note != NULL)  {
                                gtk_window_set_modal (GTK_WINDOW(inf_note), FALSE);
                                gtk_widget_show (GTK_WIDGET(inf_note));
@@ -4591,29 +3967,6 @@ modest_ui_actions_on_select_all (GtkAction *action,
                gtk_text_buffer_select_range (buffer, &start, &end);
        } else if (GTK_IS_HTML (focused_widget)) {
                gtk_html_select_all (GTK_HTML (focused_widget));
-       } else if (MODEST_IS_MAIN_WINDOW (window)) {
-               GtkWidget *header_view = focused_widget;
-               GtkTreeSelection *selection = NULL;
-
-               if (!(MODEST_IS_HEADER_VIEW (focused_widget))) {
-                       header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
-                                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               }
-
-               /* Disable window dimming management */
-               modest_window_disable_dimming (MODEST_WINDOW(window));
-
-               /* Select all messages */
-               selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(header_view));
-               gtk_tree_selection_select_all (selection);
-
-               /* Set focuse on header view */
-               gtk_widget_grab_focus (header_view);
-
-               /* Enable window dimming management */
-               modest_window_enable_dimming (MODEST_WINDOW(window));
-               modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
-               modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (window));
        }
 
 }
@@ -4729,9 +4082,6 @@ modest_ui_actions_on_change_fullscreen (GtkAction *action,
        fullscreen = modest_window_mgr_get_fullscreen_mode (mgr);
        modest_window_mgr_set_fullscreen_mode (mgr, !fullscreen);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       gtk_window_present (GTK_WINDOW (window));
-#endif
 }
 
 /*
@@ -4744,6 +4094,7 @@ headers_action_show_details (TnyHeader *header,
 
 {
        gboolean async_retrieval;
+       GtkWindow *toplevel;
        TnyMsg *msg = NULL;
 
        if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
@@ -4752,7 +4103,8 @@ headers_action_show_details (TnyHeader *header,
        } else {
                async_retrieval = FALSE;
        }
-       modest_platform_run_header_details_dialog (GTK_WINDOW (window), header, async_retrieval, msg);
+       toplevel = (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) window);
+       modest_platform_run_header_details_dialog (toplevel, header, async_retrieval, msg);
        if (msg)
                g_object_unref (msg);
 }
@@ -4778,37 +4130,6 @@ modest_ui_actions_on_details (GtkAction *action,
                        g_object_unref (header);
                }
                g_object_unref (msg);
-
-       } else if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *folder_view, *header_view;
-
-               /* Check which widget has the focus */
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                                   MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (gtk_widget_is_focus (folder_view)) {
-                       TnyFolderStore *folder_store
-                               = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-                       if (!folder_store) {
-                               g_warning ("%s: No item was selected.\n", __FUNCTION__);
-                               return;
-                       }
-                       /* Show only when it's a folder */
-                       /* This function should not be called for account items,
-                        * because we dim the menu item for them. */
-                       if (TNY_IS_FOLDER (folder_store)) {
-                               modest_platform_run_folder_details_dialog (GTK_WINDOW (win),
-                                                                          TNY_FOLDER (folder_store));
-                       }
-
-                       g_object_unref (folder_store);
-
-               } else {
-                       header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-                       /* Show details of each header */
-                       do_headers_action (win, headers_action_show_details, header_view);
-               }
-#ifdef MODEST_TOOLKIT_HILDON2
        } else if (MODEST_IS_HEADER_WINDOW (win)) {
                TnyFolder *folder;
                GtkWidget *header_view;
@@ -4816,11 +4137,11 @@ modest_ui_actions_on_details (GtkAction *action,
                header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
                folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view));
                if (folder) {
-                       modest_platform_run_folder_details_dialog (GTK_WINDOW (win),
-                                                                  folder);
+                       GtkWindow *toplevel = (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) win);
+
+                       modest_platform_run_folder_details_dialog (toplevel, folder);
                        g_object_unref (folder);
                }
-#endif
        }
 }
 
@@ -4830,7 +4151,7 @@ modest_ui_actions_on_limit_error (GtkAction *action,
 {
        g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win));
 
-       modest_platform_information_banner ((GtkWidget *) win, NULL, _CS("ckdg_ib_maximum_characters_reached"));
+       modest_platform_information_banner ((GtkWidget *) win, NULL, _CS_MAXIMUM_CHARACTERS_REACHED);
 
 }
 
@@ -4852,17 +4173,6 @@ modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
        modest_msg_edit_window_show_bcc (window, gtk_toggle_action_get_active (toggle));
 }
 
-void
-modest_ui_actions_toggle_folders_view (GtkAction *action,
-                                      ModestMainWindow *main_window)
-{
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
-
-       if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-               modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SPLIT);
-       else
-               modest_main_window_set_style (main_window, MODEST_MAIN_WINDOW_STYLE_SIMPLE);
-}
 
 void
 modest_ui_actions_on_toggle_toolbar (GtkToggleAction *toggle,
@@ -4929,152 +4239,6 @@ modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window
        modest_msg_edit_window_check_names (window, FALSE);
 }
 
-#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
- * the OK button because we do not want the user to select a disallowed
- * destination for a folder.
- * The user also not desired to be able to use NEW button on items where
- * folder creation is not possibel.
- */
-static void
-on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
-                                           TnyFolderStore *folder_store,
-                                           gboolean selected,
-                                           gpointer user_data)
-{
-       GtkWidget *dialog = NULL;
-       gboolean ok_sensitive = TRUE, new_sensitive = TRUE;
-       gboolean moving_folder = FALSE;
-       gboolean is_local_account = TRUE;
-       GtkWidget *folder_view = NULL;
-       ModestTnyFolderRules rules;
-
-       g_return_if_fail (MODEST_IS_FOLDER_VIEW(self));
-
-       if (!selected)
-               return;
-
-       dialog = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_DIALOG);
-       if (!dialog)
-               return;
-
-       /* check if folder_store is an remote account */
-       if (TNY_IS_ACCOUNT (folder_store)) {
-               TnyAccount *local_account = NULL;
-               TnyAccount *mmc_account = NULL;
-               ModestTnyAccountStore *account_store = NULL;
-
-               account_store = modest_runtime_get_account_store ();
-               local_account = modest_tny_account_store_get_local_folders_account (account_store);
-               mmc_account = modest_tny_account_store_get_mmc_folders_account (account_store);
-
-               if ((gpointer) local_account != (gpointer) folder_store &&
-                   (gpointer) mmc_account != (gpointer) folder_store) {
-                       ModestProtocolType proto;
-                       proto = modest_tny_account_get_protocol_type (TNY_ACCOUNT (folder_store));
-                       if (proto == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
-                               proto = MODEST_PROTOCOLS_STORE_MAILDIR;
-                       }
-                       is_local_account = FALSE;
-                       /* New button should be dimmed on remote
-                          POP account root */
-                       new_sensitive = (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
-                                                                                        proto,
-                                                                                        MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS));
-               }
-               g_object_unref (local_account);
-
-               /* It could not exist */
-               if (mmc_account)
-                       g_object_unref (mmc_account);
-       }
-
-       /* Check the target folder rules */
-       if (TNY_IS_FOLDER (folder_store)) {
-               rules = modest_tny_folder_get_rules (TNY_FOLDER (folder_store));
-               if (rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE) {
-                       ok_sensitive = FALSE;
-                       new_sensitive = FALSE;
-                       goto end;
-               }
-       }
-
-       /* Check if we're moving a folder */
-       if (MODEST_IS_MAIN_WINDOW (user_data)) {
-               /* Get the widgets */
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (user_data),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               if (gtk_widget_is_focus (folder_view))
-                       moving_folder = TRUE;
-       }
-
-       if (moving_folder) {
-               TnyFolderStore *moved_folder = NULL, *parent = NULL;
-
-               /* Get the folder to move */
-               moved_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-               /* Check that we're not moving to the same folder */
-               if (TNY_IS_FOLDER (moved_folder)) {
-                       parent = tny_folder_get_folder_store (TNY_FOLDER (moved_folder));
-                       if (parent == folder_store)
-                               ok_sensitive = FALSE;
-                       g_object_unref (parent);
-               }
-
-               if (ok_sensitive && TNY_IS_ACCOUNT (folder_store)) {
-                       /* Do not allow to move to an account unless it's the
-                          local folders account */
-                       if (!is_local_account)
-                               ok_sensitive = FALSE;
-               }
-
-               if (ok_sensitive && (moved_folder == folder_store)) {
-                       /* Do not allow to move to itself */
-                       ok_sensitive = FALSE;
-               }
-               g_object_unref (moved_folder);
-       } else {
-               TnyFolder *src_folder = NULL;
-
-               /* Moving a message */
-               if (MODEST_IS_MSG_VIEW_WINDOW (user_data)) {
-
-                       TnyHeader *header = NULL;
-                       header = modest_msg_view_window_get_header
-                               (MODEST_MSG_VIEW_WINDOW (user_data));
-                       if (!TNY_IS_HEADER(header))
-                               g_warning ("%s: could not get source header", __FUNCTION__);
-                       else
-                               src_folder = tny_header_get_folder (header);
-
-                       if (header)
-                               g_object_unref (header);
-               } else {
-                       src_folder =
-                               TNY_FOLDER (modest_folder_view_get_selected
-                                           (MODEST_FOLDER_VIEW (folder_view)));
-               }
-
-               if (TNY_IS_FOLDER(src_folder)) {
-                       /* Do not allow to move the msg to the same folder */
-                       /* Do not allow to move the msg to an account */
-                       if ((gpointer) src_folder == (gpointer) folder_store ||
-                           TNY_IS_ACCOUNT (folder_store))
-                               ok_sensitive = FALSE;
-                       g_object_unref (src_folder);
-               } else
-                       g_warning ("%s: could not get source folder", __FUNCTION__);
-       }
-
- end:
-       /* Set sensitivity of the OK and NEW button */
-       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, ok_sensitive);
-       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), MODEST_GTK_RESPONSE_NEW_FOLDER, new_sensitive);
-}
-#endif
 
 static void
 on_move_to_dialog_response (GtkDialog *dialog,
@@ -5091,14 +4255,13 @@ on_move_to_dialog_response (GtkDialog *dialog,
        parent_win = (GtkWidget *) helper->win;
        folder_view = MODEST_FOLDER_VIEW (g_object_get_data (G_OBJECT (dialog),
                                                             MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
-
        switch (response) {
                TnyFolderStore *dst_folder;
                TnyFolderStore *selected;
 
        case MODEST_GTK_RESPONSE_NEW_FOLDER:
                selected = modest_folder_view_get_selected (folder_view);
-               modest_ui_actions_create_folder (GTK_WIDGET (dialog), GTK_WIDGET (folder_view), selected);
+               modest_ui_actions_create_folder ((GtkWindow *) dialog, GTK_WIDGET (folder_view), selected);
                g_object_unref (selected);
                return;
        case GTK_RESPONSE_NONE:
@@ -5108,16 +4271,7 @@ on_move_to_dialog_response (GtkDialog *dialog,
        case GTK_RESPONSE_OK:
                dst_folder = modest_folder_view_get_selected (folder_view);
 
-               if (MODEST_IS_MAIN_WINDOW (parent_win)) {
-                       /* Clean list to move used for filtering */
-                       modest_folder_view_set_list_to_move (folder_view, NULL);
-
-                       modest_ui_actions_on_main_window_move_to (NULL,
-                                                                 GTK_WIDGET (folder_view),
-                                                                 dst_folder,
-                                                                 MODEST_MAIN_WINDOW (parent_win));
-#ifdef MODEST_TOOLKIT_HILDON2
-               } else if (MODEST_IS_FOLDER_WINDOW (parent_win)) {
+               if (MODEST_IS_FOLDER_WINDOW (parent_win)) {
                        /* Clean list to move used for filtering */
                        modest_folder_view_set_list_to_move (folder_view, NULL);
 
@@ -5125,7 +4279,6 @@ on_move_to_dialog_response (GtkDialog *dialog,
                                                                    dst_folder,
                                                                    helper->list,
                                                                    GTK_WINDOW (parent_win));
-#endif
                } else {
                        /* if the user selected a root folder
                           (account) then do not perform any action */
@@ -5173,15 +4326,6 @@ create_move_to_dialog (GtkWindow *win,
 
        dialog = modest_platform_create_move_to_dialog (win, &tree_view);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       /* Track changes in the selection to
-        * disable the OK button whenever "Move to" is not possible
-        * disbale NEW button whenever New is not possible */
-       g_signal_connect (tree_view,
-                         "folder_selection_changed",
-                         G_CALLBACK (on_move_to_dialog_folder_selection_changed),
-                         win);
-#endif
 
        /* It could happen that we're trying to move a message from a
           window (msg window for example) after the main window was
@@ -5209,8 +4353,8 @@ create_move_to_dialog (GtkWindow *win,
 
                modest_folder_view_set_style (MODEST_FOLDER_VIEW (tree_view),
                                              MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
-               modest_folder_view_update_model (MODEST_FOLDER_VIEW (tree_view),
-                                                TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+               /* modest_folder_view_update_model (MODEST_FOLDER_VIEW (tree_view), */
+               /*                               TNY_ACCOUNT_STORE (modest_runtime_get_account_store ())); */
 
                active_account_name = modest_window_get_active_account (MODEST_WINDOW (win));
                mgr = modest_runtime_get_account_mgr ();
@@ -5235,14 +4379,8 @@ create_move_to_dialog (GtkWindow *win,
        g_object_set_data (G_OBJECT(dialog), MODEST_MOVE_TO_DIALOG_FOLDER_VIEW, tree_view);
 
        /* Hide special folders */
-#ifndef MODEST_TOOLKIT_HILDON2
-       modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (tree_view), FALSE);
-#endif
        if (list_to_move)
                modest_folder_view_set_list_to_move (MODEST_FOLDER_VIEW (tree_view), list_to_move);
-#ifndef MODEST_TOOLKIT_HILDON2
-       modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
-#endif
 
        gtk_widget_show (GTK_WIDGET (tree_view));
 
@@ -5348,22 +4486,6 @@ move_to_cb (ModestMailOperation *mail_op,
                        /* No more messages to view, so close this window */
                        modest_ui_actions_on_close_window (NULL, MODEST_WINDOW(self));
                }
-       } else if (MODEST_IS_MAIN_WINDOW (object) &&
-                  gtk_tree_row_reference_valid (helper->reference)) {
-               GtkWidget *header_view;
-               GtkTreePath *path;
-               GtkTreeSelection *sel;
-
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(object),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view));
-               path = gtk_tree_row_reference_get_path (helper->reference);
-               /* We need to unselect the previous one
-                  because we could be copying instead of
-                  moving */
-               gtk_tree_selection_unselect_all (sel);
-               gtk_tree_selection_select_path (sel, path);
-               gtk_tree_path_free (path);
        }
        g_object_unref (object);
 
@@ -5377,19 +4499,10 @@ folder_move_to_cb (ModestMailOperation *mail_op,
                   TnyFolder *new_folder,
                   gpointer user_data)
 {
-       GtkWidget *folder_view;
        GObject *object;
 
        object = modest_mail_operation_get_source (mail_op);
-       if (MODEST_IS_MAIN_WINDOW (object)) {
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(object),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               g_object_ref (folder_view);
-               g_object_unref (object);
-               move_to_cb (mail_op, user_data);
-               modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view), new_folder, FALSE);
-               g_object_unref (folder_view);
-       } else {
+       {
                move_to_cb (mail_op, user_data);
        }
 }
@@ -5409,27 +4522,6 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
        const GError *error;
        TnyAccount *account = NULL;
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       ModestWindow *main_window = NULL;
-
-       /* Disable next automatic folder selection */
-       main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
-                                                        FALSE); /* don't create */
-
-       /* Show notification dialog only if the main window exists */
-       if (main_window) {
-               GtkWidget *folder_view = NULL;
-
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               modest_folder_view_disable_next_folder_selection (MODEST_FOLDER_VIEW(folder_view));
-
-               if (user_data && TNY_IS_FOLDER (user_data)) {
-                       modest_folder_view_select_folder (MODEST_FOLDER_VIEW (folder_view),
-                                                         TNY_FOLDER (user_data), FALSE);
-               }
-       }
-#endif
        win = modest_mail_operation_get_source (mail_op);
        error = modest_mail_operation_get_error (mail_op);
 
@@ -5451,148 +4543,6 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
                g_object_unref (win);
 }
 
-static void
-open_msg_for_purge_cb (ModestMailOperation *mail_op,
-                      TnyHeader *header,
-                      gboolean canceled,
-                      TnyMsg *msg,
-                      GError *err,
-                      gpointer user_data)
-{
-       TnyList *parts;
-       TnyIterator *iter;
-       gint pending_purges = 0;
-       gboolean some_purged = FALSE;
-       ModestWindow *win = MODEST_WINDOW (user_data);
-       ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
-
-       /* If there was any error */
-       if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg)) {
-               modest_window_mgr_unregister_header (mgr, header);
-               return;
-       }
-
-       /* Once the message has been retrieved for purging, we check if
-        * it's all ok for purging */
-
-       parts = tny_simple_list_new ();
-       tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
-       iter = tny_list_create_iterator (parts);
-
-       while (!tny_iterator_is_done (iter)) {
-               TnyMimePart *part;
-               part = TNY_MIME_PART (tny_iterator_get_current (iter));
-               if (part && (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part))) {
-                       if (tny_mime_part_is_purged (part))
-                               some_purged = TRUE;
-                       else
-                               pending_purges++;
-               }
-
-               if (part)
-                       g_object_unref (part);
-
-               tny_iterator_next (iter);
-       }
-       g_object_unref (iter);
-
-
-       if (pending_purges>0) {
-               gint response;
-               response = modest_platform_run_confirmation_dialog (GTK_WINDOW (win),_("mcen_nc_purge_file_text_inbox"));
-
-               if (response == GTK_RESPONSE_OK) {
-                       GtkWidget *info;
-                       info =
-                               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;
-
-                               part = TNY_MIME_PART (tny_iterator_get_current (iter));
-                               if (part && (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part)))
-                                       tny_mime_part_set_purged (part);
-
-                               if (part)
-                                       g_object_unref (part);
-
-                               tny_iterator_next (iter);
-                       }
-                       g_object_unref (iter);
-
-                       tny_msg_rewrite_cache (msg);
-
-                       gtk_widget_destroy (info);
-               }
-       }
-
-       modest_window_mgr_unregister_header (mgr, header);
-
-       g_object_unref (parts);
-}
-
-static void
-modest_ui_actions_on_main_window_remove_attachments (GtkAction *action,
-                                                    ModestMainWindow *win)
-{
-       GtkWidget *header_view;
-       TnyList *header_list;
-       TnyHeader *header;
-       TnyHeaderFlags flags;
-       ModestWindow *msg_view_window =  NULL;
-       gboolean found;
-
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
-
-       header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-
-       header_list = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
-       if (!header_list) {
-               g_warning ("%s: no header selected", __FUNCTION__);
-               return;
-       }
-
-       if (tny_list_get_length (header_list) == 1) {
-               TnyIterator *iter = tny_list_create_iterator (header_list);
-               header = TNY_HEADER (tny_iterator_get_current (iter));
-               g_object_unref (iter);
-       } else
-               return;
-
-       if (!header || !TNY_IS_HEADER(header)) {
-               g_warning ("%s: header is not valid", __FUNCTION__);
-               return;
-       }
-
-       found = modest_window_mgr_find_registered_header (modest_runtime_get_window_mgr (),
-                                                         header, &msg_view_window);
-       flags = tny_header_get_flags (header);
-       if (!(flags & TNY_HEADER_FLAG_CACHED))
-               return;
-       if (found) {
-               if (msg_view_window != NULL)
-                       modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (msg_view_window), TRUE);
-               else {
-                       /* do nothing; uid was registered before, so window is probably on it's way */
-                       g_debug ("header %p has already been registered", header);
-               }
-       } else {
-               ModestMailOperation *mail_op = NULL;
-               modest_window_mgr_register_header (modest_runtime_get_window_mgr (), header, NULL);
-               mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT (win),
-                                                                        modest_ui_actions_disk_operations_error_handler,
-                                                                        NULL, NULL);
-               modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
-               modest_mail_operation_get_msg (mail_op, header, FALSE, open_msg_for_purge_cb, win);
-
-               g_object_unref (mail_op);
-       }
-       if (header)
-               g_object_unref (header);
-       if (header_list)
-               g_object_unref (header_list);
-}
 
 /*
  * Checks if we need a connection to do the transfer and if the user
@@ -5754,21 +4704,6 @@ xfer_messages_performer  (gboolean canceled,
 
        movehelper = g_new0 (MoveToHelper, 1);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       movehelper->banner = modest_platform_animation_banner (GTK_WIDGET (win), NULL,
-                                                              _CS("ckct_nw_pasting"));
-       if (movehelper->banner != NULL)  {
-               g_object_ref (movehelper->banner);
-               gtk_widget_show (GTK_WIDGET (movehelper->banner));
-       }
-#endif
-
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *header_view =
-                       modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
-                                                            MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               movehelper->reference = get_next_after_selected_headers (MODEST_HEADER_VIEW (header_view));
-       }
 
        /* Perform the mail operation */
        mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(win),
@@ -5830,7 +4765,7 @@ on_move_folder_cb (gboolean canceled,
        MoveToHelper *helper = g_new0 (MoveToHelper, 1);
 #ifndef MODEST_TOOLKIT_HILDON2
        helper->banner = modest_platform_animation_banner (GTK_WIDGET (parent_window), NULL,
-                       _CS("ckct_nw_pasting"));
+                       _CS_PASTING);
        if (helper->banner != NULL)  {
                g_object_ref (helper->banner);
                gtk_widget_show (GTK_WIDGET(helper->banner));
@@ -5856,10 +4791,6 @@ on_move_folder_cb (gboolean canceled,
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                         mail_op);
 
-       if (MODEST_IS_MAIN_WINDOW (parent_window)) {
-               modest_folder_view_select_folder (MODEST_FOLDER_VIEW(info->folder_view),
-                                                 TNY_FOLDER (info->dst_folder), TRUE);
-       }
        modest_mail_operation_xfer_folder (mail_op,
                        TNY_FOLDER (info->src_folder),
                        info->dst_folder,
@@ -5888,76 +4819,6 @@ get_account_from_folder_store (TnyFolderStore *folder_store)
 
 /*
  * UI handler for the "Move to" action when invoked from the
- * ModestMainWindow
- */
-static void
-modest_ui_actions_on_main_window_move_to (GtkAction *action,
-                                         GtkWidget *folder_view,
-                                         TnyFolderStore *dst_folder,
-                                         ModestMainWindow *win)
-{
-       ModestHeaderView *header_view = NULL;
-       TnyFolderStore *src_folder = NULL;
-
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW (win));
-
-       /* Get the source folder */
-       src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-       /* Get header view */
-       header_view = (ModestHeaderView *)
-               modest_main_window_get_child_widget (win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-
-       /* Get folder or messages to transfer */
-       if (gtk_widget_is_focus (folder_view)) {
-               gboolean do_xfer = TRUE;
-
-               /* Allow only to transfer folders to the local root folder */
-               if (TNY_IS_ACCOUNT (dst_folder) &&
-                   !MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (dst_folder) &&
-                   !modest_tny_account_is_memory_card_account (TNY_ACCOUNT (dst_folder))) {
-                       do_xfer = FALSE;
-               } else if (!TNY_IS_FOLDER (src_folder)) {
-                       g_warning ("%s: src_folder is not a TnyFolder.\n", __FUNCTION__);
-                       do_xfer = FALSE;
-               }
-
-               if (do_xfer) {
-                       MoveFolderInfo *info = g_new0 (MoveFolderInfo, 1);
-                       DoubleConnectionInfo *connect_info = g_slice_new (DoubleConnectionInfo);
-
-                       info->src_folder = g_object_ref (src_folder);
-                       info->dst_folder = g_object_ref (dst_folder);
-                       info->delete_original = TRUE;
-                       info->folder_view = folder_view;
-
-                       connect_info->callback = on_move_folder_cb;
-                       connect_info->dst_account = get_account_from_folder_store (TNY_FOLDER_STORE (dst_folder));
-                       connect_info->data = info;
-
-                       modest_platform_double_connect_and_perform(GTK_WINDOW (win), TRUE,
-                                                                  TNY_FOLDER_STORE (src_folder),
-                                                                  connect_info);
-               }
-       } else if (gtk_widget_is_focus (GTK_WIDGET(header_view))) {
-               TnyList *headers;
-
-               headers = modest_header_view_get_selected_headers(header_view);
-
-               /* Transfer the messages */
-               modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), TNY_FOLDER (src_folder),
-                                                           headers, TNY_FOLDER (dst_folder));
-
-               g_object_unref (headers);
-       }
-
-       /* Frees */
-       g_object_unref (src_folder);
-}
-
-#ifdef MODEST_TOOLKIT_HILDON2
-/*
- * UI handler for the "Move to" action when invoked from the
  * ModestFolderWindow
  */
 static void
@@ -6014,7 +4875,6 @@ modest_ui_actions_on_folder_window_move_to (GtkWidget *folder_view,
        /* Frees */
        g_object_unref (src_folder);
 }
-#endif
 
 
 void
@@ -6112,16 +4972,6 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win)
 
        g_return_val_if_fail (MODEST_IS_WINDOW (win), FALSE);
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       /* Get the main window if exists */
-       ModestMainWindow *main_window;
-       if (MODEST_IS_MAIN_WINDOW (win))
-               main_window = MODEST_MAIN_WINDOW (win);
-       else
-               main_window =
-                       MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
-                                                                              FALSE)); /* don't create */
-#endif
 
        list_to_move = modest_platform_get_list_to_move (MODEST_WINDOW (win));
 
@@ -6232,9 +5082,7 @@ void
 modest_ui_actions_remove_attachments (GtkAction *action,
                                      ModestWindow *window)
 {
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               modest_ui_actions_on_main_window_remove_attachments (action, MODEST_MAIN_WINDOW (window));
-       } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+       if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
                modest_msg_view_window_remove_attachments (MODEST_MSG_VIEW_WINDOW (window), FALSE);
        } else {
                /* not supported window for this action */
@@ -6247,9 +5095,11 @@ modest_ui_actions_on_settings (GtkAction *action,
                               ModestWindow *win)
 {
        GtkWidget *dialog;
+       GtkWindow *toplevel;
 
        dialog = modest_platform_get_global_settings_dialog ();
-       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
+       toplevel = (GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (win));
+       gtk_window_set_transient_for (GTK_WINDOW (dialog), toplevel);
        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
        gtk_widget_show_all (dialog);
 
@@ -6280,31 +5130,6 @@ 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;
-
-       g_return_if_fail (win && MODEST_IS_MAIN_WINDOW (win));
-
-       /* Get selected folder */
-       folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-       folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-       /* Switch help_id */
-       if (folder_store && TNY_IS_FOLDER (folder_store))
-               help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store));
-
-       if (folder_store)
-               g_object_unref (folder_store);
-
-        if (help_id)
-                modest_platform_show_help (GTK_WINDOW (win), help_id);
-       else
-               modest_ui_actions_on_help (action, win);
-#endif
 }
 
 static void
@@ -6539,61 +5364,8 @@ modest_ui_actions_on_toggle_find_in_page (GtkAction *action,
        else
                active = TRUE;
 
-       modest_msg_edit_window_toggle_find_toolbar (MODEST_MSG_EDIT_WINDOW (window),
-                                                   active);
-}
-
-static void
-on_send_receive_finished (ModestMailOperation  *mail_op,
-                          gpointer user_data)
-{
-       GtkWidget *header_view, *folder_view;
-       TnyFolderStore *folder_store;
-       ModestMainWindow *main_win = MODEST_MAIN_WINDOW (user_data);
-
-       /* Set send/receive operation finished */
-       modest_main_window_notify_send_receive_completed (main_win);
-
-       /* Don't refresh the current folder if there were any errors */
-       if (modest_mail_operation_get_status (mail_op) !=
-           MODEST_MAIL_OPERATION_STATUS_SUCCESS)
-               return;
-
-       /* Refresh the current folder if we're viewing a window. We do
-          this because the user won't be able to see the new mails in
-          the selected folder after a Send&Receive because it only
-          performs a poke_status, i.e, only the number of read/unread
-          messages is updated, but the new headers are not
-          downloaded */
-       folder_view = modest_main_window_get_child_widget (main_win,
-                                                          MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-       if (!folder_view)
-               return;
-
-       folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-       /* Do not need to refresh INBOX again because the
-          update_account does it always automatically */
-       if (folder_store && TNY_IS_FOLDER (folder_store) &&
-           tny_folder_get_folder_type (TNY_FOLDER (folder_store)) != TNY_FOLDER_TYPE_INBOX) {
-               ModestMailOperation *refresh_op;
-
-               header_view = modest_main_window_get_child_widget (main_win,
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-
-               /* We do not need to set the contents style
-                  because it hasn't changed. We also do not
-                  need to save the widget status. Just force
-                  a refresh */
-               refresh_op = modest_mail_operation_new (G_OBJECT (main_win));
-               modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), refresh_op);
-               modest_mail_operation_refresh_folder (refresh_op, TNY_FOLDER (folder_store),
-                                                     folder_refreshed_cb, main_win);
-               g_object_unref (refresh_op);
-       }
-
-       if (folder_store)
-               g_object_unref (folder_store);
+       modest_msg_edit_window_toggle_isearch_toolbar (MODEST_MSG_EDIT_WINDOW (window),
+                                                      active);
 }
 
 
@@ -6658,7 +5430,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self,
                                                           server_name);
                break;
        case TNY_SERVICE_ERROR_SEND:
-               message = g_strdup (_CS("sfil_ib_unable_to_send"));
+               message = g_strdup (_CS_UNABLE_TO_SEND);
                break;
        case TNY_SERVICE_ERROR_UNAVAILABLE:
                message = modest_protocol_get_translation (protocol,
@@ -6668,7 +5440,7 @@ modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self,
        default:
                g_warning ("%s: unexpected ERROR %d",
                           __FUNCTION__, err->code);
-               message = g_strdup (_CS("sfil_ib_unable_to_send"));
+               message = g_strdup (_CS_UNABLE_TO_SEND);
                break;
        }
 
@@ -6694,17 +5466,10 @@ modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_queue,
        if (!top_window)
                return;
 
-#ifndef MODEST_TOOLKIT_HILDON2
-       if (MODEST_IS_MAIN_WINDOW (top_window)) {
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (top_window),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-       }
-#else
        if (MODEST_IS_HEADER_WINDOW (top_window)) {
                header_view = (GtkWidget *)
                        modest_header_window_get_header_view (MODEST_HEADER_WINDOW (top_window));
        }
-#endif
 
        /* Get selected folder */
        if (header_view)
@@ -6771,25 +5536,7 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
        ModestProtocol *protocol;
        TnyHeader *header = NULL;
 
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *header_view;
-               TnyList* headers = NULL;
-               TnyIterator *iter;
-               header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               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);
-#ifdef MODEST_TOOLKIT_HILDON2
-       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+       if (MODEST_IS_HEADER_WINDOW (win)) {
                GtkWidget *header_view;
                TnyList* headers = NULL;
                TnyIterator *iter;
@@ -6809,7 +5556,6 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
                }
                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));
                if (header)