Build fix
[modest] / src / hildon2 / modest-msg-view-window.c
index 48836f0..70effef 100644 (file)
@@ -66,6 +66,7 @@
 #include <glib/gstdio.h>
 #include <modest-debug.h>
 #include <modest-header-window.h>
+#include <modest-account-protocol.h>
 
 #define MYDOCS_ENV "MYDOCSDIR"
 #define DOCS_FOLDER ".documents"
@@ -227,6 +228,7 @@ static void setup_menu (ModestMsgViewWindow *self);
 static gboolean _modest_msg_view_window_map_event (GtkWidget *widget,
                                                   GdkEvent *event,
                                                   gpointer userdata);
+static void update_branding (ModestMsgViewWindow *self);
 
 
 /* list my signals */
@@ -530,10 +532,6 @@ init_window (ModestMsgViewWindow *obj)
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_scroll, TRUE, TRUE, 0);
        gtk_container_add   (GTK_CONTAINER(obj), main_vbox);
 
-       priv->find_toolbar = hildon_find_toolbar_new (NULL);
-       hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
-       gtk_widget_set_no_show_all (priv->find_toolbar, TRUE);
-
        /* NULL-ize fields if the window is destroyed */
        g_signal_connect (priv->msg_view, "destroy", G_CALLBACK (gtk_widget_destroyed), &(priv->msg_view));
 
@@ -816,12 +814,20 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
        modest_window_set_active_account (MODEST_WINDOW(obj), modest_account_name);
        modest_window_set_active_mailbox (MODEST_WINDOW(obj), mailbox);
 
-       g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj);
-       g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj);
-       priv->last_search = NULL;
-
+       /* First add out toolbar ... */
        modest_msg_view_window_show_toolbar (MODEST_WINDOW (obj), TRUE);
 
+       /* ... and later the find toolbar. This way find toolbar will
+          be shown over the other */
+       priv->find_toolbar = hildon_find_toolbar_new (NULL);
+       hildon_window_add_toolbar (HILDON_WINDOW (obj), GTK_TOOLBAR (priv->find_toolbar));
+       gtk_widget_set_no_show_all (priv->find_toolbar, TRUE);
+       g_signal_connect (G_OBJECT (priv->find_toolbar), "close", 
+                         G_CALLBACK (modest_msg_view_window_find_toolbar_close), obj);
+       g_signal_connect (G_OBJECT (priv->find_toolbar), "search", 
+                         G_CALLBACK (modest_msg_view_window_find_toolbar_search), obj);
+       priv->last_search = NULL;
+
        /* Init the clipboard actions dim status */
        modest_msg_view_grab_focus(MODEST_MSG_VIEW (priv->msg_view));
 
@@ -904,6 +910,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg,
 
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        update_window_title (MODEST_MSG_VIEW_WINDOW (window));
+       update_branding (MODEST_MSG_VIEW_WINDOW (window));
 
        /* gtk_widget_show_all (GTK_WIDGET (window)); */
        modest_msg_view_window_update_priority (window);
@@ -991,6 +998,7 @@ modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view,
        }
 
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), NULL);
+       update_branding (MODEST_MSG_VIEW_WINDOW (window));
 
        path = gtk_tree_row_reference_get_path (row_reference);
        if (gtk_tree_model_get_iter (priv->header_model, &iter, path)) {
@@ -1033,6 +1041,7 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg,
        priv->is_search_result = TRUE;
 
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
+       update_branding (MODEST_MSG_VIEW_WINDOW (window));
        
        update_window_title (window);
        /* gtk_widget_show_all (GTK_WIDGET (window));*/
@@ -1082,6 +1091,7 @@ modest_msg_view_window_new_with_other_body (TnyMsg *msg,
                tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        }
        update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
+       update_branding (MODEST_MSG_VIEW_WINDOW (obj));
 
        /* gtk_widget_show_all (GTK_WIDGET (obj)); */
 
@@ -2087,6 +2097,7 @@ view_msg_cb (ModestMailOperation *mail_op,
                tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
                modest_msg_view_window_update_priority (self);
                update_window_title (MODEST_MSG_VIEW_WINDOW (self));
+               update_branding (MODEST_MSG_VIEW_WINDOW (self));
                modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view));
        }
 
@@ -2660,7 +2671,7 @@ typedef struct
 static void save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct);
 static gboolean idle_save_mime_part_show_result (SaveMimePartInfo *info);
 static gpointer save_mime_part_to_file (SaveMimePartInfo *info);
-static void save_mime_parts_to_file_with_checks (SaveMimePartInfo *info);
+static void save_mime_parts_to_file_with_checks (GtkWindow *parent, SaveMimePartInfo *info);
 
 static void
 save_mime_part_info_free (SaveMimePartInfo *info, gboolean with_struct)
@@ -2742,24 +2753,27 @@ save_mime_part_to_file (SaveMimePartInfo *info)
 }
 
 static void
-save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
+save_mime_parts_to_file_with_checks (GtkWindow *parent,
+                                    SaveMimePartInfo *info)
 {
        gboolean is_ok = TRUE;
         gint replaced_files = 0;
         const GList *files = info->pairs;
-        const GList *iter;
+        const GList *iter, *to_replace = NULL;
 
         for (iter = files; (iter != NULL) && (replaced_files < 2); iter = g_list_next(iter)) {
                 SaveMimePartPair *pair = iter->data;
                 if (modest_utils_file_exists (pair->filename)) {
                        replaced_files++;
+                       if (replaced_files == 1)
+                               to_replace = iter;
                 }
         }
        if (replaced_files) {
-               GtkWidget *confirm_overwrite_dialog;
+               gint response;
 
                if (replaced_files == 1) {
-                       SaveMimePartPair *pair = files->data;
+                       SaveMimePartPair *pair = to_replace->data;
                        const gchar *basename = strrchr (pair->filename, G_DIR_SEPARATOR) + 1;
                        gchar *escaped_basename, *message;
 
@@ -2767,17 +2781,15 @@ save_mime_parts_to_file_with_checks (SaveMimePartInfo *info)
                        message = g_strdup_printf ("%s\n%s",
                                                   _FM("docm_nc_replace_file"),
                                                   (escaped_basename) ? escaped_basename : "");
-                       confirm_overwrite_dialog = hildon_note_new_confirmation (NULL, message);
+                       response = modest_platform_run_confirmation_dialog (parent, message);
                        g_free (message);
                        g_free (escaped_basename);
                } else {
-                       confirm_overwrite_dialog = hildon_note_new_confirmation (NULL,
-                                                                                _FM("docm_nc_replace_multiple"));
+                       response = modest_platform_run_confirmation_dialog (parent,
+                                                                           _FM("docm_nc_replace_multiple"));
                }
-               if (gtk_dialog_run (GTK_DIALOG (confirm_overwrite_dialog)) != GTK_RESPONSE_OK)
+               if (response != GTK_RESPONSE_OK)
                        is_ok = FALSE;
-
-               gtk_widget_destroy (confirm_overwrite_dialog);
        }
 
        if (!is_ok) {
@@ -2854,7 +2866,7 @@ save_attachments_response (GtkDialog *dialog,
                SaveMimePartInfo *info = g_slice_new0 (SaveMimePartInfo);
                info->pairs = files_to_save;
                info->result = TRUE;
-               save_mime_parts_to_file_with_checks (info);
+               save_mime_parts_to_file_with_checks ((GtkWindow *) dialog, info);
        }
 
  end:
@@ -3074,6 +3086,7 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean
        tny_msg_rewrite_cache (msg);
        tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
        g_object_unref (msg);
+       update_branding (MODEST_MSG_VIEW_WINDOW (window));
 
        g_object_unref (mime_parts);
 
@@ -3450,3 +3463,34 @@ modest_msg_view_window_reload (ModestMsgViewWindow *self)
 
        g_object_unref (header);
 }
+
+static void
+update_branding (ModestMsgViewWindow *self)
+{
+       const gchar *account; 
+       const gchar *mailbox;
+       ModestAccountMgr *mgr;
+       ModestProtocol *protocol = NULL;
+       gchar *service_name = NULL;
+       const GdkPixbuf *service_icon = NULL;
+       ModestMsgViewWindowPrivate *priv;
+
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+
+       account = modest_window_get_active_account (MODEST_WINDOW (self));
+       mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (self));
+
+       mgr = modest_runtime_get_account_mgr ();
+       
+       if (modest_account_mgr_account_is_multimailbox (mgr, account, &protocol)) {
+               if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+                       service_name = modest_account_protocol_get_service_name (MODEST_ACCOUNT_PROTOCOL (protocol),
+                                                                                account, mailbox);
+                       service_icon = modest_account_protocol_get_service_icon (MODEST_ACCOUNT_PROTOCOL (protocol),
+                                                                                account, mailbox, MODEST_ICON_SIZE_SMALL);
+               }
+       }
+
+       modest_msg_view_set_branding (MODEST_MSG_VIEW (priv->msg_view), service_name, service_icon);
+       g_free (service_name);
+}