[Xfce4-commits] <postler:master> Dynamically show and hide inbox indicators
Christian Dywan
noreply at xfce.org
Tue Jan 4 05:52:08 CET 2011
Updating branch refs/heads/master
to a14c2997c0b2b4451cfcf836a42302580fe56395 (commit)
from 48945971495874bdb02370c7802f0b2a489ae74f (commit)
commit a14c2997c0b2b4451cfcf836a42302580fe56395
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Jan 3 17:38:16 2011 +0100
Dynamically show and hide inbox indicators
postler/postler-service.vala | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index 1bbcec8..f5250da 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2011 Christian Dywan <christian at twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,18 +18,44 @@ namespace Postler {
Indicate.Server indicator;
List<Indicate.Indicator> items;
+ void update_inbox_indicator (Indicate.Indicator item) {
+ string path = item.get_property ("url") + "/INBOX/new";
+ uint new_messages = 0;
+ try {
+ var inbox = Dir.open (path, 0);
+ while (inbox.read_name () != null)
+ new_messages++;
+ var folder = File.new_for_path (path);
+ var monitor = folder.monitor_directory (0, null);
+ monitor.changed.connect ((monitor, file, other, event) => {
+ update_inbox_indicator (item);
+ });
+ } catch (Error error) {
+ GLib.warning ("Indicator: %s", error.message);
+ }
+
+ if (new_messages > 0) {
+ item.set_property ("count", new_messages.to_string ());
+ item.emit_show ();
+ }
+ else
+ item.emit_hide ();
+ }
+
void add_inbox_indicator (AccountInfo info) {
if (info.type != AccountType.IMAP)
return;
var item = new Indicate.Indicator.with_server (indicator);
item.set_property ("name", info.name);
+ item.set_property ("url", info.path);
+ item.set_property ("draw-attention", "true");
item.user_display.connect ((item) => {
string name = item.get_property ("name");
Postler.App.spawn_module ("bureau", name);
});
- item.emit_show ();
items.append (item);
+ update_inbox_indicator (item);
}
public PostlerService () {
More information about the Xfce4-commits
mailing list