OpenMsgHelper *helper;
ModestWindow *window;
- g_return_if_fail (header != NULL && rowref != NULL);
+ g_return_if_fail (header != NULL && rowref != NULL && gtk_tree_row_reference_valid (rowref));
mgr = modest_runtime_get_window_mgr ();
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
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 {
/* 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 */
/* This happens if we have selected the outbox folder
as the parent */
- if (err->code == TNY_SERVICE_ERROR_UNKNOWN &&
+ if (err && err->code == TNY_SERVICE_ERROR_UNKNOWN &&
TNY_IS_MERGE_FOLDER (helper->parent)) {
/* Show an error and retry */
modest_platform_information_banner ((GtkWidget *) parent_window,