[Xfce4-commits] <postler:master> Correctly determine the number of accounts

Christian Dywan noreply at xfce.org
Mon Dec 20 21:26:01 CET 2010


Updating branch refs/heads/master
         to 12f689c5f6819f2ef19cd6ce04e881271f08a093 (commit)
       from dabedeb107050978d6a69aeb4bc9fec9556ac4ae (commit)

commit 12f689c5f6819f2ef19cd6ce04e881271f08a093
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Dec 20 21:18:08 2010 +0100

    Correctly determine the number of accounts
    
    We must only count IMAP accounts and we need to pass the
    number in the callback because for refreshing only one
    account info is passed.

 postler/postler-folders.vala |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 9e894e0..0fe9b41 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -96,7 +96,17 @@ public class Postler.Folders : Gtk.TreeView {
         return false;
     }
 
-    public bool populate_accounts (GLib.List<AccountInfo> infos) {
+    public bool populate_accounts (GLib.List<AccountInfo> infos, int count=-1) {
+        int num_accounts = 0;
+        if (count > -1)
+            num_accounts = count;
+        else {
+            foreach (unowned AccountInfo account_info in infos) {
+                if (account_info.type == AccountType.IMAP)
+                    num_accounts++;
+            }
+        }
+        bool one_account = num_accounts < 2;
         bool need_update = false;
 
         /* foreach (unowned AccountInfo account_info in infos) { */
@@ -204,9 +214,7 @@ public class Postler.Folders : Gtk.TreeView {
                             account_info.path + "/" + name + "/new");
                         var monitor = msg_dir.monitor_directory (0, null);
                         string path = store.get_string_from_iter (account_iter);
-                        string label = account_info.name;
-                        if (infos.length () < 2)
-                            label = _("Inbox");
+                        string label = one_account ? _("Inbox") : account_info.name;
                         monitor.changed.connect ((monitor, file, other, event) => {
                             unread_monitor_changed (msg_dir, path, label);
                         });
@@ -226,7 +234,7 @@ public class Postler.Folders : Gtk.TreeView {
                     monitor.changed.connect ((monitor, file, other, event) => {
                         var account_infos = new GLib.List<AccountInfo> ();
                         account_infos.prepend (account_info);
-                        populate_accounts (account_infos);
+                        populate_accounts (account_infos, num_accounts);
                     });
 
                     unowned MailFolder folder = account_info.get_localized_folder (name);
@@ -245,8 +253,7 @@ public class Postler.Folders : Gtk.TreeView {
                         Columns.ELLIPSIZE, Pango.EllipsizeMode.MIDDLE,
                         Columns.LOCATION, account_info.path + "/" + name,
                         Columns.INFO, account_info,
-                        Columns.FOLDER_MONITOR, monitor,
-                        Columns.UNREAD_MONITOR, monitor);
+                        Columns.FOLDER_MONITOR, monitor);
                     var msg_dir = folder_dir.resolve_relative_path (
                         account_info.path + "/" + name + "/new");
                     monitor = msg_dir.monitor_directory (0, null);
@@ -255,6 +262,7 @@ public class Postler.Folders : Gtk.TreeView {
                         unread_monitor_changed (msg_dir, path, folder.label ?? folder_name);
                     });
                     unread_monitor_changed (msg_dir, path, folder.label ?? folder_name);
+                    store.set (folder_iter, Columns.UNREAD_MONITOR, monitor);
                 }
 
                 /* Look for missing special folders or create them */



More information about the Xfce4-commits mailing list