Show translated names in first item of paths in change folder dialog
[modest] / src / widgets / modest-msg-view-window.c
index abd650c..3882232 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"
@@ -284,8 +287,8 @@ modest_msg_view_window_get_type (void)
                        (GInstanceInitFunc) modest_msg_view_window_init,
                        NULL
                };
-#ifdef MODEST_TOOLKIT_GTK
-               my_type = g_type_register_static (MODEST_TYPE_WINDOW,
+#ifndef MODEST_TOOLKIT_HILDON2
+               my_type = g_type_register_static (MODEST_TYPE_SHELL_WINDOW,
                                                  "ModestMsgViewWindow",
                                                  &my_info, 0);
 #else
@@ -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);
@@ -471,11 +472,6 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
                g_error_free (error);
                error = NULL;
        }
-       /* ****** */
-
-       /* Add accelerators */
-       gtk_window_add_accel_group (GTK_WINDOW (obj), 
-                                   gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
        
        priv->is_search_result = FALSE;
        priv->is_outbox = FALSE;
@@ -1896,6 +1892,7 @@ message_reader_performer (gboolean canceled,
        info = (MsgReaderInfo *) user_data;
        if (canceled || err) {
                update_window_title (MODEST_MSG_VIEW_WINDOW (parent_window));
+               modest_ui_actions_on_close_window (NULL, MODEST_WINDOW (parent_window));
                goto frees;
        }
 
@@ -2185,6 +2182,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 +2420,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 +3218,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;
                }
@@ -3207,12 +3259,11 @@ modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
                                                              num), num);
        }
 
-       /****** HILDON2:START
-        * creation of hildon file chooser dialog for saving
-        */
-       save_dialog = hildon_file_chooser_dialog_new (GTK_WINDOW (window), 
-                                                     GTK_FILE_CHOOSER_ACTION_SAVE);
-       /****** HILDON2:END */
+       /* Creation of hildon file chooser dialog for saving */
+       save_dialog = modest_toolkit_factory_create_file_chooser_dialog (modest_runtime_get_toolkit_factory (),
+                                                                        "",
+                                                                        (GtkWindow *) window,
+                                                                        GTK_FILE_CHOOSER_ACTION_SAVE);
 
        /* Get last used folder */
        conf_folder = modest_conf_get_string (modest_runtime_get_conf (),
@@ -3322,7 +3373,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;