X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=58b285967911747b89d488df2ada81e0c4c0e4ce;hp=d70586dc38808084d62736c12a41f94e5cfe7413;hb=596a74d8798410d738adef0ad9357aa6c6ade185;hpb=e5c4ad03681b448912adaf378dc31d77c70b9ce2 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index d70586d..58b2859 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -2151,6 +2151,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) { @@ -2173,12 +2194,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); } } @@ -2190,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 @@ -2242,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); } } @@ -3180,7 +3200,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) } /* Get the currently-active transport account for this modest account: */ - if (strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) { + if (account_name && strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) { transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),