From 2d9cb14ff1c313a85369989f2a64ca3e3eead136 Mon Sep 17 00:00:00 2001 From: Jesus McCloud Date: Tue, 16 Nov 2010 00:53:54 +0100 Subject: [PATCH] put notify code into folders --- postler/postler-bureau.vala | 14 ++------------ postler/postler-folders.vala | 8 ++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala index a7c2304..1e0578e 100644 --- a/postler/postler-bureau.vala +++ b/postler/postler-bureau.vala @@ -14,7 +14,6 @@ public class Postler.Bureau : Gtk.Window { Gtk.UIManager ui; Gtk.ActionGroup actions; - Notify.Notification new_mail_notify; Gtk.VBox shelf; Gtk.Toolbar toolbar; Gtk.Entry search; @@ -90,21 +89,13 @@ public class Postler.Bureau : Gtk.Window { private bool new_message_timer () { accounts.receive (); - if(folders.unread>0){ - new_mail_notify= new Notify.Notification("Postler", "You have "+folders.unread.to_string()+" new message(s)", null,null); - //how to do icons? new_mail_notify.attach_to_status_icon (new Gtk.StatusIcon.from_stock("stock_mail_compose")); - new_mail_notify.show(); - } + folders.display_notify=true; return true; } void action_mail_receive () { accounts.receive (); - if(folders.unread>0){ - new_mail_notify= new Notify.Notification("Postler", "You have "+folders.unread.to_string()+" new message(s)", null,null); - new_mail_notify.show(); - } - + folders.display_notify=true; } void compose_message (string? prefix=null, string? recipient=null) { @@ -416,7 +407,6 @@ public class Postler.Bureau : Gtk.Window { screen.get_monitor_geometry (0, out monitor); double window_width = monitor.width / 1.7; set_default_size ((int)window_width, (int)(monitor.height / 1.7)); - Notify.init("Postler"); ui = new Gtk.UIManager (); actions = new Gtk.ActionGroup ("Bureau"); actions.set_translation_domain (Config.GETTEXT_PACKAGE); diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala index 8a8bc01..fe2c4a3 100644 --- a/postler/postler-folders.vala +++ b/postler/postler-folders.vala @@ -17,7 +17,9 @@ struct Postler.MailFolder { public class Postler.Folders : Gtk.TreeView { Accounts accounts; + Notify.Notification new_mail_notify; public int unread { get; set; default=0; } + public bool display_notify {get; set; default=false;} Gtk.TreeStore store; string last_location; @@ -56,6 +58,7 @@ public class Postler.Folders : Gtk.TreeView { public Folders (Accounts accounts) { this.accounts = accounts; + Notify.init("Postler"); store = new Gtk.TreeStore (7, typeof (string), typeof (string), typeof (string), typeof (AccountInfo), @@ -87,6 +90,11 @@ public class Postler.Folders : Gtk.TreeView { if (store.get_iter_from_string (out iter, path)) store.set (iter, Columns.NAME, "%s (%d)".printf (account, unread)); + if((unread>0)&&(display_notify)){ + new_mail_notify= new Notify.Notification("Postler", "You have "+unread.to_string()+" new message(s)", null,null); + new_mail_notify.show(); + display_notify=false; + } } catch (GLib.Error error) { GLib.critical (_("Failed to monitor folder \"%s\": %s"), msg_dir.get_path (), error.message); -- 1.7.3.1