Modified dimming rule of "Add to contacts" to support edit windows
[modest] / src / modest-ui-actions.c
index 87f8627..6c8fdde 100644 (file)
@@ -66,8 +66,8 @@
 #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-ui-constants.h"
 #include <widgets/modest-main-window.h>
 #include <widgets/modest-msg-view-window.h>
@@ -639,7 +639,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",
@@ -2152,20 +2152,22 @@ modest_ui_actions_on_sort (GtkAction *action,
 }
 
 static void
-sync_folder_cb (TnyFolder *folder,
-               gboolean cancelled,
-               GError *err,
+sync_folder_cb (ModestMailOperation *mail_op,
+               TnyFolder *folder,
                gpointer user_data)
 {
        ModestHeaderView *header_view = (ModestHeaderView *) user_data;
 
-       tny_folder_refresh_async (folder, NULL, NULL, NULL);
-       /* ModestWindow *parent = (ModestWindow *) gtk_widget_get_ancestor ((GtkWidget *) user_data, GTK_TYPE_WINDOW); */
+       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); */
+               /* 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);
 }
@@ -2186,15 +2188,18 @@ idle_refresh_folder (gpointer source)
                header_view = modest_header_window_get_header_view ((ModestHeaderWindow *) source);
 #else
        if (MODEST_IS_MAIN_WINDOW (source))
-               header_view = modest_main_window_get_child_widget ((ModestMainWindow *) source,
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
+               header_view = MODEST_HEADER_VIEW (modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (source),
+                                                                                      MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
 #endif
        if (header_view) {
                TnyFolder *folder = modest_header_view_get_folder (header_view);
                if (folder) {
                        /* Sync the folder status */
-                       tny_folder_sync_async (folder, TRUE, sync_folder_cb, NULL, g_object_ref (header_view));
+                       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);
                }
        }
 
@@ -2206,11 +2211,11 @@ 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;
+       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
@@ -2258,15 +2263,14 @@ update_account_cb (ModestMailOperation *self,
                g_object_unref (actually_new_list);
        }
 
-       if (source) {
+       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 (source),
+                                g_object_ref (top),
                                 g_object_unref);
-               g_object_unref (source);
        }
 }
 
@@ -3156,7 +3160,8 @@ 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 names but do not automatically add them to addressbook */
+       if (!modest_msg_edit_window_check_names (edit_window, FALSE))
                return TRUE;
 
        data = modest_msg_edit_window_get_msg_data (edit_window);