Updating branch refs/heads/master to 50922e9a1df6942272796427efb32e3ea57f655a (commit) from a975fad4e2ccf56e670c4a93c1b031a59f183ec3 (commit)
commit 50922e9a1df6942272796427efb32e3ea57f655a Author: Christian Dywan <christ...@twotoasts.de> Date: Fri Jun 4 15:53:24 2010 +0200 Update number of unread messages on file changes postler/postler-folders.vala | 30 +++++++++++++++++++++++++----- 1 files changed, 25 insertions(+), 5 deletions(-) diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala index 4d1959b..fb337fa 100644 --- a/postler/postler-folders.vala +++ b/postler/postler-folders.vala @@ -20,6 +20,8 @@ struct Postler.MailFolder { public class Postler.Folders : Gtk.TreeView { Gtk.TreeStore store; string last_location; + FileMonitor[] unread_monitors = {}; + uint unread_monitors_count = 0; public Postler.Messages messages { get; set; } public string? selected_location { @@ -58,7 +60,22 @@ public class Postler.Folders : Gtk.TreeView { { "Trash", STOCK_USER_TRASH, N_("Trash") } }; + void unread_monitor_changed (File msg_dir, string path, string account) { + var msg_enumerator = msg_dir.enumerate_children ("", 0, null); + int unread = 0; + FileInfo info; + while ((info = msg_enumerator.next_file (null)) != null) + unread++; + Gtk.TreeIter iter; + if (store.get_iter_from_string (out iter, path)) + store.set (iter, + Columns.NAME, "%s (%d)".printf (account, unread), + -1); + } + bool populate () { + unread_monitors = {}; + unread_monitors_count = 0; string toplevel = Environment.get_variable ("MAILDIR"); if (toplevel == null || toplevel == "") toplevel = Environment.get_home_dir () + "/Mail"; @@ -96,14 +113,17 @@ public class Postler.Folders : Gtk.TreeView { if (name == "INBOX") { var msg_dir = folder_dir.resolve_relative_path ( location + "/" + name + "/new"); - var msg_enumerator = msg_dir.enumerate_children ("", 0, null); - int unread = 0; - while ((info = msg_enumerator.next_file (null)) != null) - unread++; + unread_monitors += msg_dir.monitor_directory (0, null); + unread_monitors_count++; + string path = store.get_string_from_iter (account_iter); + unread_monitors[unread_monitors_count - 1].changed.connect ( + (monitor, file, other, event) => { + unread_monitor_changed (msg_dir, path, account_name); + }); + unread_monitor_changed (msg_dir, path, account_name); store.set (account_iter, Columns.ICON, STOCK_INBOX, - Columns.NAME, "%s (%d)".printf (account_name, unread), Columns.LOCATION, location + "/" + name, -1); continue; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits