X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui-actions.c;h=e6069a5a81e33982d606c41749f390baf7f10eb1;hp=61dd61f794defeddedcde2b7c7b4e922da2b36e5;hb=28d019df4f60f67426a816fc4da9f8df51784a8d;hpb=f42dcfb53f942ace9efab748723d358498e78344 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 61dd61f..e6069a5 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -2151,18 +2151,50 @@ modest_ui_actions_on_sort (GtkAction *action, modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS); } +static gboolean +idle_refresh_folder (gpointer source) +{ + ModestHeaderView *header_view = NULL; + + /* If the window still exists */ + if (!GTK_IS_WIDGET (source) || + !GTK_WIDGET_VISIBLE (source)) + return FALSE; + + /* Refresh the current view */ +#ifdef MODEST_TOOLKIT_HILDON2 + if (MODEST_IS_HEADER_WINDOW (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); +#endif + 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); + g_object_unref (folder); + } + } + + return FALSE; +} + static void -new_messages_arrived (ModestMailOperation *self, - TnyList *new_headers, - gpointer user_data) +update_account_cb (ModestMailOperation *self, + TnyList *new_headers, + gpointer user_data) { GObject *source; gboolean show_visual_notifications; source = modest_mail_operation_get_source (self); show_visual_notifications = (source) ? FALSE : TRUE; - if (source) - g_object_unref (source); /* Notify new messages have been downloaded. If the send&receive was invoked by the user then do not show any @@ -2210,6 +2242,16 @@ new_messages_arrived (ModestMailOperation *self, g_object_unref (actually_new_list); } + if (source) { + /* 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_unref); + g_object_unref (source); + } } typedef struct { @@ -2257,7 +2299,7 @@ do_send_receive_performer (gboolean canceled, /* Send & receive. */ modest_mail_operation_update_account (info->mail_op, info->account_name, info->poke_status, info->interactive, - new_messages_arrived, info->win); + update_account_cb, info->win); clean: /* Frees */