First step in refactoring ModestMsgViewWindow to be a common class with
[modest] / src / modest-ui-actions.c
index a51726d..22b9011 100644 (file)
 #include <modest-folder-window.h>
 #include <modest-maemo-utils.h>
 #endif
-
-#ifdef MODEST_PLATFORM_MAEMO
-#include "hildon2/modest-osso-state-saving.h"
-#endif /* MODEST_PLATFORM_MAEMO */
-#ifndef MODEST_TOOLKIT_GTK
-#include "hildon2/modest-hildon-includes.h"
-#include "hildon2/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>
@@ -654,7 +646,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",
@@ -2176,6 +2168,27 @@ modest_ui_actions_on_sort (GtkAction *action,
        modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);
 }
 
+static void
+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)
 {
@@ -2198,12 +2211,12 @@ idle_refresh_folder (gpointer source)
        if (header_view) {
                TnyFolder *folder = modest_header_view_get_folder (header_view);
                if (folder) {
-                       /* 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,
-                                                      (ModestWindow *) source, NULL, NULL);
+                       /* 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);
                }
        }