Move easysetup wizard to src/widgets
[modest] / src / widgets / modest-msg-view-window.c
index 03ddee8..d46db30 100644 (file)
@@ -37,7 +37,7 @@
 #include "modest-marshal.h"
 #include "modest-platform.h"
 #include <modest-utils.h>
-#include <modest-maemo-utils.h>
+#include <modest-toolkit-utils.h>
 #include <modest-tny-msg.h>
 #include <modest-msg-view-window.h>
 #include "modest-msg-view-window-ui-dimming.h"
 #include <modest-toolkit-factory.h>
 #include <modest-scrollable.h>
 #include <modest-isearch-toolbar.h>
-#include <hildon/hildon-picker-dialog.h>
-#include <hildon/hildon-app-menu.h>
 #include "modest-defs.h"
-#include "modest-hildon-includes.h"
 #include "modest-ui-dimming-manager.h"
 #include <gdk/gdkkeysyms.h>
 #include <modest-tny-account.h>
 #include <modest-account-protocol.h>
 #include <modest-icon-names.h>
 #include <modest-ui-actions.h>
+#include <modest-window-mgr.h>
 #include <tny-camel-msg.h>
+#include <modest-icon-names.h>
+
+#ifdef MODEST_PLATFORM_MAEMO
+#include <modest-maemo-utils.h>
+#endif
 
 #define MYDOCS_ENV "MYDOCSDIR"
 #define DOCS_FOLDER ".documents"
@@ -377,12 +380,10 @@ static void
 modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
 {
        GObjectClass *gobject_class;
-       HildonWindowClass *hildon_window_class;
        ModestWindowClass *modest_window_class;
        GtkBindingSet *binding_set;
 
        gobject_class = (GObjectClass*) klass;
-       hildon_window_class = (HildonWindowClass *) klass;
        modest_window_class = (ModestWindowClass *) klass;
 
        parent_class            = g_type_class_peek_parent (klass);
@@ -2185,6 +2186,59 @@ view_msg_cb (ModestMailOperation *mail_op,
                        gtk_tree_row_reference_free (row_reference);
                self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op);
                if (self) {
+                       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+                       /* First we check if the parent is a folder window */
+                       if (priv->msg_uid && !modest_window_mgr_get_folder_window (MODEST_WINDOW_MGR (modest_runtime_get_window_mgr ()))) {
+                               gboolean is_merge;
+                               TnyAccount *account = NULL;
+                               GtkWidget *header_window = NULL;
+
+                               is_merge = g_str_has_prefix (priv->msg_uid, "merge:");
+
+                               /* Get the account */
+                               if (!is_merge)
+                                       account = tny_account_store_find_account (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()),
+                                                                                 priv->msg_uid);
+
+                               if (is_merge || account) {
+                                       TnyFolder *folder = NULL;
+
+                                       /* Try to get the message, if it's already downloaded
+                                          we don't need to connect */
+                                       if (account) {
+                                               folder = modest_tny_folder_store_find_folder_from_uri (TNY_FOLDER_STORE (account), 
+                                                                                                      priv->msg_uid);
+                                       } else {
+                                               ModestTnyAccountStore *account_store;
+                                               ModestTnyLocalFoldersAccount *local_folders_account;
+
+                                               account_store = modest_runtime_get_account_store ();
+                                               local_folders_account = MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (
+                                                       modest_tny_account_store_get_local_folders_account (account_store));
+                                               folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account);
+                                               g_object_unref (local_folders_account);
+                                       }
+                                       if (account) g_object_unref (account);
+
+                                       if (folder) {
+                                               header_window = (GtkWidget *)
+                                                       modest_header_window_new (
+                                                               folder, 
+                                                               modest_window_get_active_account (MODEST_WINDOW (self)), 
+                                                               modest_window_get_active_mailbox (MODEST_WINDOW (self)));
+                                               if (!modest_window_mgr_register_window (modest_runtime_get_window_mgr (),
+                                                                                       MODEST_WINDOW (header_window),
+                                                                                       NULL)) {
+                                                       gtk_widget_destroy (GTK_WIDGET (header_window));
+                                               } else {
+                                                       gtk_widget_show_all (GTK_WIDGET (header_window));
+                                               }
+                                               g_object_unref (folder);
+                                       }
+                               }
+                       }
+
+
                        /* Restore window title */
                        update_window_title (self);
                        modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (self));
@@ -2370,7 +2424,9 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
        if (!parent_priv->toolbar) {
                parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
                                                                  "/ToolBar");
-               gtk_toolbar_set_icon_size (GTK_TOOLBAR (parent_priv->toolbar), HILDON_ICON_SIZE_FINGER);
+
+               /* We don't use HILDON_ICON_SIZE_FINGER in order to avoid the ifdef here */
+               gtk_toolbar_set_icon_size (GTK_TOOLBAR (parent_priv->toolbar), gtk_icon_size_from_name ("hildon-finger"));
                gtk_widget_set_no_show_all (parent_priv->toolbar, TRUE);
 
                priv->next_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageNext");
@@ -3166,7 +3222,7 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
                /* In Hildon 2.2 save and delete operate over all the attachments as there's no
                 * selection available */
                mime_parts = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view));
-               if (mime_parts && !modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) {
+               if (mime_parts && !modest_toolkit_utils_select_attachments (GTK_WINDOW (window), mime_parts, FALSE)) {
                        g_object_unref (mime_parts);
                        return;
                }
@@ -3321,7 +3377,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
        g_object_unref (tmp);
        g_object_unref (iter);
 
-       if (!modest_maemo_utils_select_attachments (GTK_WINDOW (window), mime_parts, TRUE) ||
+       if (!modest_toolkit_utils_select_attachments (GTK_WINDOW (window), mime_parts, TRUE) ||
            tny_list_get_length (mime_parts) == 0) {
                g_object_unref (mime_parts);
                return;