[gnome-shell-extensions/extension-live-disable: 9/11] gajim: port to new extension API
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/extension-live-disable: 9/11] gajim: port to new extension API
- Date: Tue, 2 Aug 2011 21:37:49 +0000 (UTC)
commit 765905f5b8bea25358ab0e2eb6f1cafbebc98707
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue Aug 2 23:33:25 2011 +0200
gajim: port to new extension API
main() has been replaced by init(), enable() and disable()
when disabling, all sources and notifications associated with gajim
contacts are automatically closed
extensions/gajim/extension.js | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/extensions/gajim/extension.js b/extensions/gajim/extension.js
index 9f97e9a..3b5e698 100644
--- a/extensions/gajim/extension.js
+++ b/extensions/gajim/extension.js
@@ -263,15 +263,31 @@ function GajimClient() {
GajimClient.prototype = {
_init: function() {
this._sources = {};
+ },
+
+ proxy : function() {
+ return this._proxy;
+ },
+
+ enable: function() {
this._cacheDir = GLib.get_user_cache_dir() + '/gnome-shell/gajim-avatars';
GLib.mkdir_with_parents(this._cacheDir, 0x1c0); // 0x1c0 = octal 0700
this._proxy = new Gajim(DBus.session, 'org.gajim.dbus', '/org/gajim/dbus/RemoteObject');
- this._proxy.connect('NewMessage', Lang.bind(this, this._messageReceived));
+ this._newMessageId = this._proxy.connect('NewMessage', Lang.bind(this, this._messageReceived));
},
- proxy : function() {
- return this._proxy;
+ disable: function() {
+ if (this._newMessageId) {
+ this._proxy.disconnect(this._newMessageId);
+ this._newMessageId = 0;
+ }
+ this._proxy = null;
+
+ for (let id in this._sources)
+ this._sources[id].destroy();
+
+ this._sources = { };
},
_messageReceived : function(emitter, data) {
@@ -308,6 +324,6 @@ GajimClient.prototype = {
};
-function main() {
- let client = new GajimClient();
+function init() {
+ return new GajimClient();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]