[Xfce4-commits] <postler:master> Update accounts if folders were missing before parsing

Christian Dywan noreply at xfce.org
Wed Dec 1 23:16:01 CET 2010


Updating branch refs/heads/master
         to dd221b4d328823779d8b369d47464cad24fbc5c7 (commit)
       from d4a49a02a1b7d04d254d8629a611cf34fa0e415f (commit)

commit dd221b4d328823779d8b369d47464cad24fbc5c7
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Dec 1 23:15:00 2010 +0100

    Update accounts if folders were missing before parsing
    
    Accounts.update() is made public, and used instead of removing
    and inserting at once.
    
    Before populating accounts, we check if one is incomplete, and
    afterwards update the accounts.
    
    Fixes: https://bugs.launchpad.net/postler/+bug/683799

 postler/postler-accounts.vala |    4 ++--
 postler/postler-folders.vala  |   14 +++++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 7e22e7e..7527fff 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -154,7 +154,7 @@ public class Postler.Accounts : GLib.Object {
         reload ();
     }
 
-    void update_accountrc () {
+    public void update () {
         try {
             foreach (AccountInfo account_info in infos) {
                 string group = account_info.name ?? account_info.address;
@@ -344,7 +344,7 @@ public class Postler.Accounts : GLib.Object {
         if (info.type == AccountType.IMAP)
             info.path = data_path + info.name;
         infos.append (info);
-        update_accountrc ();
+        update ();
     }
 
     public virtual signal void remove_info (AccountInfo info) {
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 1afa1ca..5c52873 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -113,11 +113,12 @@ public class Postler.Folders : Gtk.TreeView {
     }
 
     public bool populate_accounts (GLib.List<AccountInfo> infos) {
+        bool need_update = false;
+
         /* foreach (unowned AccountInfo account_info in infos) { */
         for (unowned GLib.List<AccountInfo> info_iter = infos;
             info_iter != null; info_iter = info_iter.next) {
             AccountInfo account_info = info_iter.data;
-
             if (account_info.type == AccountType.SEARCH) {
                 store.insert_with_values (null, null, -1,
                     Columns.ICON, STOCK_FOLDER_SAVED_SEARCH,
@@ -127,6 +128,7 @@ public class Postler.Folders : Gtk.TreeView {
                 continue;
             }
 
+            bool incomplete = account_info.get_folder (FolderType.SENT) == null;
             try {
                 var folder_dir = File.new_for_path (account_info.path);
 
@@ -263,6 +265,8 @@ public class Postler.Folders : Gtk.TreeView {
                                    Columns.NAME, folder.label);
                     }
                 });
+                if (incomplete)
+                    need_update = true;
 
                 expand_row (store.get_path (account_iter), false);
             }
@@ -270,6 +274,8 @@ public class Postler.Folders : Gtk.TreeView {
                 GLib.critical (_("Failed to read folder \"%s\": %s"),
                     account_info.path, error.message);
             }
+            if (need_update)
+                accounts.update ();
         }
         return false;
     }
@@ -395,8 +401,7 @@ public class Postler.Folders : Gtk.TreeView {
                      Columns.INFO, out account_info);
                  if (account_info != null) {
                      account_info.hide += "," + name;
-                     accounts.remove_info (account_info);
-                     accounts.add_info (account_info);
+                     accounts.update ();
                      populate ();
                  }
              }
@@ -457,8 +462,7 @@ public class Postler.Folders : Gtk.TreeView {
                      store.get (iter, Columns.INFO, out account_info);
                      AccountSetup.edit_account (account_info).done.connect (
                          (setup, info) => {
-                         accounts.remove_info (info);
-                         accounts.add_info (info);
+                         accounts.update ();
                          populate ();
                      } );
                  }



More information about the Xfce4-commits mailing list