summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Barisione <marco@barisione.org>2011-11-21 08:51:13 (GMT)
committerMarco Barisione <marco@barisione.org>2011-11-21 08:51:13 (GMT)
commit6b5d676e78aeeaa5330438c4b090b392ec3a3f85 (patch)
tree1df30482da000cea122ad1e14b7836898039b5ce
parent6f4a8dd6ae6bc588f53948b80908b5df8dd98f2d (diff)
downloadshell-message-notifier-6b5d676e78aeeaa5330438c4b090b392ec3a3f85.tar.gz
shell-message-notifier-6b5d676e78aeeaa5330438c4b090b392ec3a3f85.tar.xz
Hook into the shell to get notified when the message count changes
-rw-r--r--extension.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/extension.js b/extension.js
index ca6c82b..c2c871d 100644
--- a/extension.js
+++ b/extension.js
@@ -16,7 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+const Lang = imports.lang;
const Main = imports.ui.main;
+const MessageTray = imports.ui.messageTray;
const St = imports.gi.St;
let label;
@@ -32,22 +34,37 @@ MessageLabel.prototype = {
this.actor = new St.Button({name: 'messageButton'});
this.actor.set_child(this.countLabel);
- this._updateText();
+ this.updateCount();
},
- _updateText: function() {
+ updateCount: function() {
this.countLabel.set_text('0');
}
};
+function customSetCount(count, visible) {
+ let fallbackSetCount = Lang.bind(this, originalSetCount);
+ fallbackSetCount(count, visible);
+
+ label.updateCount();
+}
+
+let originalSetCount;
+
function init() {
+ originalSetCount = MessageTray.Source.prototype._setCount;
+
label = new MessageLabel();
}
function enable() {
+ MessageTray.Source.prototype._setCount = customSetCount;
+
Main.panel._rightBox.insert_actor(label.actor, 0);
}
function disable() {
+ MessageTray.Source.prototype._setCount = originalSetCount;
+
Main.panel._rightBox.remove_actor(label);
}