* Fixes NB#78732, messages now appear in the Outbox after the first sent message
authorSergio Villar Senin <svillar@igalia.com>
Mon, 7 Jan 2008 11:16:32 +0000 (11:16 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 7 Jan 2008 11:16:32 +0000 (11:16 +0000)
pmo-trunk-r3985

src/maemo/modest-main-window.c
src/modest-tny-local-folders-account.c
src/modest-ui-actions.c
src/widgets/modest-header-view.c

index c4bf2c5..1802a81 100644 (file)
@@ -1852,29 +1852,31 @@ on_msg_count_changed (ModestHeaderView *header_view,
 {
        gboolean folder_empty = FALSE;
        gboolean all_marked_as_deleted = FALSE;
-       TnyFolderChangeChanged changed; 
        ModestMainWindowPrivate *priv;
        
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (main_window));
        g_return_if_fail (TNY_IS_FOLDER(folder));
-       g_return_if_fail (TNY_IS_FOLDER_CHANGE(change));
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window);
-       
-       changed = tny_folder_change_get_changed (change);
-       
-       /* If something changes */
-       if ((changed) & TNY_FOLDER_CHANGE_CHANGED_ALL_COUNT)
-               folder_empty = (tny_folder_change_get_new_all_count (change) == 0);
-       else
-               folder_empty = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
 
-       /* Play a sound (if configured) and make the LED blink  */
-       if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS)
-               modest_platform_on_new_headers_received (NULL, FALSE);
-       
-       /* Check header removed  (hide marked as DELETED headers) */
-       if (changed & TNY_FOLDER_CHANGE_CHANGED_EXPUNGED_HEADERS) {
-               modest_header_view_refilter (MODEST_HEADER_VIEW(priv->header_view));
+       if (change != NULL) {
+               TnyFolderChangeChanged changed;
+
+               changed = tny_folder_change_get_changed (change);
+               /* If something changes */
+               if ((changed) & TNY_FOLDER_CHANGE_CHANGED_ALL_COUNT)
+                       folder_empty = (tny_folder_change_get_new_all_count (change) == 0);
+               else
+                       folder_empty = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+               
+               /* Play a sound (if configured) and make the LED blink  */
+               if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) {
+                       modest_platform_on_new_headers_received (NULL, FALSE);
+               }
+               
+               /* Checks header removed  (hide marked as DELETED headers) */
+               if (changed & TNY_FOLDER_CHANGE_CHANGED_EXPUNGED_HEADERS) {
+                       modest_header_view_refilter (MODEST_HEADER_VIEW(priv->header_view));
+               }
        }
 
        /* Check if all messages are marked to be deleted */
@@ -1886,8 +1888,7 @@ on_msg_count_changed (ModestHeaderView *header_view,
                modest_main_window_set_contents_style (main_window,
                                                       MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
                gtk_widget_grab_focus (GTK_WIDGET (priv->folder_view));
-       }
-       else {
+       } else {
                modest_main_window_set_contents_style (main_window,
                                                       MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
        }
index 8929330..12ee27e 100644 (file)
@@ -232,10 +232,6 @@ modest_tny_local_folders_account_add_folder_to_outbox (ModestTnyLocalFoldersAcco
        g_return_if_fail (MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (self));
        g_return_if_fail (TNY_IS_FOLDER (per_account_outbox));
 
-       /* We can not test it yet, because there is no API to set the
-          type of a folder */
-/*     g_return_if_fail (tny_folder_get_folder_type (per_account_outbox) == TNY_FOLDER_TYPE_OUTBOX); */
-
        priv = TNY_LOCAL_FOLDERS_ACCOUNT_GET_PRIVATE (self);
 
        /* Create on-demand */
index 83cd10a..84665a0 100644 (file)
@@ -2035,8 +2035,6 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
 {
        ModestMainWindow *win = NULL;
        GtkWidget *header_view;
-       gboolean folder_empty = FALSE;
-       gboolean all_marked_as_deleted = FALSE;
 
        g_return_if_fail (TNY_IS_FOLDER (folder));
 
@@ -2056,9 +2054,7 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
        }
 
        /* Check if folder is empty and set headers view contents style */
-       folder_empty = (tny_folder_get_all_count (folder) == 0);
-       all_marked_as_deleted = modest_header_view_is_empty (MODEST_HEADER_VIEW(header_view));
-       if (folder_empty || all_marked_as_deleted)
+       if (tny_folder_get_all_count (folder) == 0)
                modest_main_window_set_contents_style (win,
                                                       MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
 }
index e90e1c6..ead0760 100644 (file)
@@ -150,8 +150,10 @@ struct _ModestHeaderViewPrivate {
        gulong  selection_changed_handler;
        gulong  acc_removed_handler;
 
-       HeaderViewStatus status;
        GList *drag_begin_cached_selected_rows;
+
+       HeaderViewStatus status;
+       guint status_timeout;
 };
 
 typedef struct _HeadersCountChangedHelper HeadersCountChangedHelper;
@@ -558,6 +560,7 @@ modest_header_view_init (ModestHeaderView *obj)
        priv->observers_lock = g_mutex_new ();
 
        priv->status  = HEADER_VIEW_INIT;
+       priv->status_timeout = 0;
 
        priv->observer_list_lock = g_mutex_new();
        priv->observer_list = NULL;
@@ -1203,6 +1206,9 @@ modest_header_view_set_folder (ModestHeaderView *self,
        }
                                                      
        if (priv->folder) {
+               if (priv->status_timeout)
+                       g_source_remove (priv->status_timeout);
+
                g_mutex_lock (priv->observers_lock);
                tny_folder_remove_observer (priv->folder, TNY_FOLDER_OBSERVER (self));
                g_object_unref (priv->folder);
@@ -1872,7 +1878,32 @@ _clipboard_set_selected_data (ModestHeaderView *header_view,
        g_object_unref (headers);
 }
 
+typedef struct {
+       ModestHeaderView *self;
+       TnyFolder *folder;
+} NotifyFilterInfo;
+
+static gboolean
+notify_filter_change (gpointer data)
+{
+       NotifyFilterInfo *info = (NotifyFilterInfo *) data;
+
+       g_signal_emit (info->self, 
+                      signals[MSG_COUNT_CHANGED_SIGNAL], 
+                      0, info->folder, NULL);
+
+       return FALSE;
+}
+
+static void
+notify_filter_change_destroy (gpointer data)
+{
+       NotifyFilterInfo *info = (NotifyFilterInfo *) data;
 
+       g_object_unref (info->self);
+       g_object_unref (info->folder);
+       g_slice_free (NotifyFilterInfo, info);
+}
 
 static gboolean
 filter_row (GtkTreeModel *model,
@@ -1887,7 +1918,8 @@ filter_row (GtkTreeModel *model,
        gboolean visible = TRUE;
        gboolean found = FALSE;
        GValue value = {0,};
-       
+       HeaderViewStatus old_status;
+
        g_return_val_if_fail (MODEST_IS_HEADER_VIEW (user_data), FALSE);
        priv = MODEST_HEADER_VIEW_GET_PRIVATE (user_data);
 
@@ -1929,8 +1961,23 @@ filter_row (GtkTreeModel *model,
        }
 
  frees:
+       old_status = priv->status;
        priv->status = ((gboolean) priv->status) && !visible;
-       
+       if (priv->status != old_status) {
+               NotifyFilterInfo *info;
+
+               if (priv->status_timeout)
+                       g_source_remove (priv->status_timeout);
+
+               info = g_slice_new0 (NotifyFilterInfo);
+               info->self = g_object_ref (G_OBJECT (user_data));
+               info->folder = tny_header_get_folder (header);
+               priv->status_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
+                                                          notify_filter_change,
+                                                          info,
+                                                          notify_filter_change_destroy);
+       }
+
        return visible;
 }