[Xfce4-commits] <postler:master> Display number of files waiting in Queue folders

Christian Dywan noreply at xfce.org
Tue Dec 14 20:52:03 CET 2010


Updating branch refs/heads/master
         to e02f5cecab1d62b3627ea1ccb7e6a964b1f06885 (commit)
       from 75fb7302d0ddf042e0f3e2d6156f7d139c193153 (commit)

commit e02f5cecab1d62b3627ea1ccb7e6a964b1f06885
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Dec 13 21:09:50 2010 +0100

    Display number of files waiting in Queue folders

 postler/postler-folders.vala |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 9f13de4..e3716da 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -53,17 +53,19 @@ public class Postler.Folders : Gtk.TreeView {
         GLib.Idle.add (populate);
     }
 
-    void unread_monitor_changed (File msg_dir, string path, string account) {
+    void unread_monitor_changed (File msg_dir, string path, string label) {
         try {
             var msg_enumerator = msg_dir.enumerate_children ("", 0, null);
             int unread = 0;
             FileInfo info;
             while ((info = msg_enumerator.next_file (null)) != null)
                 unread++;
+            if (unread == 0)
+                return;
             Gtk.TreeIter iter;
             if (store.get_iter_from_string (out iter, path))
                 store.set (iter,
-                    Columns.NAME, "%s (%d)".printf (account, unread));
+                    Columns.NAME, "%s (%d)".printf (label, unread));
         } catch (GLib.Error error) {
             GLib.critical (_("Failed to monitor folder \"%s\": %s"),
                            msg_dir.get_path (), error.message);
@@ -231,7 +233,7 @@ public class Postler.Folders : Gtk.TreeView {
                                          account_iter, out folder_iter))
                         store.remove (folder_iter);
 
-                    store.insert_with_values (null,
+                    store.insert_with_values (out folder_iter,
                         folder.localized != null ? account_iter : parent_iter, -1,
                         Columns.ICON, folder.stock_id ?? Gtk.STOCK_DIRECTORY,
                         Columns.NAME, folder.label ?? folder_name,
@@ -239,6 +241,19 @@ public class Postler.Folders : Gtk.TreeView {
                         Columns.LOCATION, account_info.path + "/" + name,
                         Columns.INFO, account_info,
                         Columns.FOLDER_MONITOR, monitor);
+
+                    if (folder.role == "Queue") {
+                        var msg_dir = folder_dir.resolve_relative_path (
+                            account_info.path + "/" + name + "/new");
+                        monitor = msg_dir.monitor_directory (0, null);
+                        string path = store.get_string_from_iter (folder_iter);
+                        monitor.changed.connect ((monitor, file, other, event) => {
+                            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);
+                    }
                 }
 
                 Gtk.TreeIter folder_iter = new Gtk.TreeIter ();



More information about the Xfce4-commits mailing list