[Xfce4-commits] <postler:master> Refresh badge based on number of new on disk

Christian Dywan noreply at xfce.org
Sun Mar 20 17:08:03 CET 2011


Updating branch refs/heads/master
         to 54c3ec95f36fe340d57b4ba26cc8d6e42af4d22b (commit)
       from 27cf79ea246afadaddadd670db9d94e7f4b79e7c (commit)

commit 54c3ec95f36fe340d57b4ba26cc8d6e42af4d22b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Mar 20 17:04:40 2011 +0100

    Refresh badge based on number of new on disk

 postler/postler-service.vala |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index c856456..d551cef 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -93,7 +93,6 @@ namespace Postler {
     class PostlerService : Object {
         double total = 0;
         int unread = 0;
-        int interval = 600; /* 10 minutes */
         Dock.Item dockitem;
 
 #if HAVE_INDICATE
@@ -148,8 +147,24 @@ namespace Postler {
             return true;
         }
 
+        bool badge_timer () {
+            var accounts = new Accounts ();
+            uint new_messages = 0;
+            foreach (var info in accounts.get_infos ()) {
+                try {
+                    var inbox = Dir.open (info.path + "/INBOX/new", 0);
+                    while (inbox.read_name () != null)
+                        new_messages++;
+                }
+                catch (GLib.Error error) { }
+            }
+            dockitem.set_badge (new_messages);
+            return true;
+        }
+
         public PostlerService () {
-            GLib.Timeout.add_seconds (interval, new_message_timer);
+            GLib.Timeout.add_seconds (600, new_message_timer); /* 10 minutes */
+            GLib.Timeout.add_seconds (30, badge_timer);
 
             dockitem = new Dock.Item.for_name (_("Postler"));
 
@@ -286,7 +301,6 @@ namespace Postler {
                             return;
                         }
                         GLib.debug ("Done: %d new messages", unread);
-                        dockitem.set_badge (unread);
                         if (unread > 0) {
                             Postler.App.send_notification (
                                 ngettext ("You have %d message",



More information about the Xfce4-commits mailing list