* Removed a duplicated save_state call
[modest] / src / widgets / modest-header-view.c
index d8fcb75..03e1ed8 100644 (file)
@@ -1152,18 +1152,17 @@ modest_header_view_set_folder (ModestHeaderView *self,
                /* Pick my reference. Nothing to do with the mail operation */
                priv->folder = g_object_ref (folder);
 
-               /* no message selected */
+               /* Clear the selection if exists */
+               selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self));
+               gtk_tree_selection_unselect_all(selection);
                g_signal_emit (G_OBJECT(self), signals[HEADER_SELECTED_SIGNAL], 0, NULL);
 
+               /* create the helper */
                info = g_malloc0 (sizeof(SetFolderHelper));
                info->header_view = self;
                info->cb = callback;
                info->user_data = user_data;
 
-               /* bug 57631: Clear the selection if exists */
-               selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self));
-               gtk_tree_selection_unselect_all(selection);
-
                /* Create the mail operation (source will be the parent widget) */
                mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, source);
                modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
@@ -1579,6 +1578,7 @@ folder_monitor_update (TnyFolderObserver *self,
        ModestHeaderViewPrivate *priv = NULL;
        TnyFolderChangeChanged changed;
        HeadersCountChangedHelper *helper = NULL;
+       TnyFolder *folder = NULL;
 
        changed = tny_folder_change_get_changed (change);
        
@@ -1586,8 +1586,9 @@ folder_monitor_update (TnyFolderObserver *self,
           view has changed before this call to the observer
           happens */
        priv = MODEST_HEADER_VIEW_GET_PRIVATE (MODEST_HEADER_VIEW (self));
-       if (tny_folder_change_get_folder (change) != priv->folder)
-               return;
+       folder = tny_folder_change_get_folder (change);
+       if (folder != priv->folder)
+               goto frees;
 
        /* Check folder count */
        if ((changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) ||
@@ -1595,12 +1596,18 @@ folder_monitor_update (TnyFolderObserver *self,
                helper = g_slice_new0 (HeadersCountChangedHelper);
                helper->self = MODEST_HEADER_VIEW(self);
                helper->change = g_object_ref(change);
-               
-               g_idle_add_full (G_PRIORITY_DEFAULT, 
-                                idle_notify_headers_count_changed, 
-                                helper,
-                                idle_notify_headers_count_changed_destroy);
+
+/*             if (folder != NULL) */
+/*                     tny_folder_poke_status (folder); */
+
+               idle_notify_headers_count_changed (helper);
+               idle_notify_headers_count_changed_destroy (helper);
        }       
+
+       /* Free */
+ frees:
+       if (folder != NULL)
+               g_object_unref (folder);
 }
 
 gboolean