From 80799ecbfdb8a869b59598723413554fab02e8b6 Mon Sep 17 00:00:00 2001 From: Allen Lowe Date: Tue, 9 Nov 2010 12:06:47 -0700 Subject: [PATCH] I added a gio FolderMonitor that starts everytime you click a folder, then it refreshes the message list automatically --- postler/postler-folders.vala | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala index 6ff55ef..81806bc 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,19 @@ 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 (); -- 1.7.1