[Xfce4-commits] <postler:master> Store folder and unread monitor in the model

Christian Dywan noreply at xfce.org
Sun Jul 18 20:38:01 CEST 2010


Updating branch refs/heads/master
         to d2fd92ed91a13d86b879a1553fa0a011d3852ab8 (commit)
       from 59e73365e5048b33aeffa55536c5e8fa20b384d8 (commit)

commit d2fd92ed91a13d86b879a1553fa0a011d3852ab8
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jul 18 20:00:06 2010 +0200

    Store folder and unread monitor in the model
    
    This ties monitors to row lifespan just like we need it.

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

diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index ebd8494..cae5245 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -19,8 +19,6 @@ public class Postler.Folders : Gtk.TreeView {
     Accounts accounts;
     Gtk.TreeStore store;
     string last_location;
-    FileMonitor[] unread_monitors = {};
-    uint unread_monitors_count = 0;
 
     public Postler.Messages messages { get; set; }
     public string? selected_location {
@@ -49,13 +47,17 @@ public class Postler.Folders : Gtk.TreeView {
         ICON,
         NAME,
         LOCATION,
-        INFO
+        INFO,
+        FOLDER_MONITOR,
+        UNREAD_MONITOR,
     }
 
     public Folders (Accounts accounts) {
         this.accounts = accounts;
-        store = new Gtk.TreeStore (4,
-            typeof (string), typeof (string), typeof (string), typeof (AccountInfo));
+        store = new Gtk.TreeStore (6,
+            typeof (string), typeof (string), typeof (string),
+            typeof (AccountInfo),
+            typeof (GLib.FileMonitor), typeof (GLib.FileMonitor));
         set_model (store);
         insert_column_with_attributes (-1, "Icon",
             new Gtk.CellRendererPixbuf (), "stock-id", Columns.ICON);
@@ -92,9 +94,6 @@ public class Postler.Folders : Gtk.TreeView {
     public bool populate () {
         store.clear ();
 
-        unread_monitors = {};
-        unread_monitors_count = 0;
-
         return populate_accounts (accounts.get_infos ());
     }
 
@@ -152,33 +151,31 @@ public class Postler.Folders : Gtk.TreeView {
                     if (account_info.hide != null && name in account_info.hide)
                         continue;
 
-                    /* FIXME: Handle duplicate or obsolete unread monitor */
                     var account_dir = folder_dir.resolve_relative_path (name);
-                    unread_monitors += account_dir.monitor_directory (0, null);
-                    unread_monitors_count++;
-                    unread_monitors[unread_monitors_count - 1].changed.connect (
-                        (monitor, file, other, event) => {
+                    var monitor = account_dir.monitor_directory (0, null);
+                    monitor.changed.connect ((monitor, file, other, event) => {
                         var account_infos = new GLib.List<AccountInfo> ();
                         account_infos.prepend (account_info);
                         populate_accounts (account_infos);
                     });
+                    store.set (account_iter,
+                        Columns.FOLDER_MONITOR, monitor);
 
                     Gtk.TreeIter folder_iter;
                     if (name == "INBOX") {
                         var msg_dir = folder_dir.resolve_relative_path (
                             account_info.path + "/" + name + "/new");
-                        unread_monitors += msg_dir.monitor_directory (0, null);
-                        unread_monitors_count++;
+                        monitor = msg_dir.monitor_directory (0, null);
                         string path = store.get_string_from_iter (account_iter);
-                        unread_monitors[unread_monitors_count - 1].changed.connect (
-                            (monitor, file, other, event) => {
+                        monitor.changed.connect ((monitor, file, other, event) => {
                             unread_monitor_changed (msg_dir, path, account_info.name);
                         });
                         unread_monitor_changed (msg_dir, path, account_info.name);
 
                         store.set (account_iter,
                             Columns.ICON, STOCK_INBOX,
-                            Columns.LOCATION, account_info.path + "/" + name);
+                            Columns.LOCATION, account_info.path + "/" + name,
+                            Columns.UNREAD_MONITOR, monitor);
                         continue;
                     }
 



More information about the Xfce4-commits mailing list