[Xfce4-commits] <postler:master> Monitor selected folders and refresh message list

Christian Dywan noreply at xfce.org
Wed Nov 10 00:16:01 CET 2010


Updating branch refs/heads/master
         to 849d0aeedf99909ab9746001719d1bfbd3659229 (commit)
       from d28c9f93db1c44ceab73fbf741c7ef5ce7f2b1b7 (commit)

commit 849d0aeedf99909ab9746001719d1bfbd3659229
Author: Allen Lowe <lallenlowe at gmail.com>
Date:   Tue Nov 9 12:06:47 2010 -0700

    Monitor selected folders and refresh message list
    
    I added a GIO.FolderMonitor that starts everytime you click a
    folder, then it refreshes the message list automatically.
    
    https://bugs.launchpad.net/postler/+bug/671586

 postler/postler-folders.vala |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 6ff55ef..4d565a4 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -19,6 +19,7 @@ public class Postler.Folders : Gtk.TreeView {
     Accounts accounts;
     Gtk.TreeStore store;
     string last_location;
+    FileMonitor folder_monitor;
 
     public Postler.Messages messages { get; set; }
     public string? selected_location {
@@ -74,6 +75,11 @@ public class Postler.Folders : Gtk.TreeView {
         { "Trash", STOCK_USER_TRASH, N_("Trash") },
         { "Archive", STOCK_ARCHIVE, N_("Archive") }
     };
+    
+    void folder_monitor_changed (string location) {
+        messages.populate (location);
+        messages.grab_focus ();
+    }
 
     void unread_monitor_changed (File msg_dir, string path, string account) {
         try {
@@ -259,6 +265,20 @@ public class Postler.Folders : Gtk.TreeView {
         if (location != null) {
             messages.populate (location);
             messages.grab_focus ();
+
+            var location_dir = File.new_for_path (location);
+            var message_dir = location_dir.resolve_relative_path (
+                location + "/cur");
+            try {
+                folder_monitor = message_dir.monitor_directory (0, null);
+            }
+            catch (GLib.IOError error) {
+                GLib.critical (_("Failed to monitor folder \"%s\": %s"),
+                    location, error.message);
+            }
+            folder_monitor.changed.connect ((folder_monitor, file, other, event) => {
+                folder_monitor_changed (location);
+            });
         }
         else
             messages.clear ();



More information about the Xfce4-commits mailing list