[Pkg-mozext-commits] [firetray] 349/399: cleaning
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:24:12 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 2b2812aee65a521105d80070c694ee4407c532c9
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Sat Mar 16 16:04:07 2013 +0100
cleaning
---
src/chrome/content/options.js | 20 ++++-----
src/chrome/content/options.xul | 3 +-
src/modules/FiretrayHandler.jsm | 57 +++++++++++++++++++-------
src/modules/FiretrayMessaging.jsm | 8 ++--
src/modules/linux/FiretrayChatStatusIcon.jsm | 20 +++++++--
src/modules/linux/FiretrayWindow.jsm | 12 ++++--
6 files changed, 79 insertions(+), 41 deletions(-)
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index df76a5d..1b1e2ce 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -20,9 +20,13 @@ let log = firetray.Logging.getLogger("firetray.UIOptions");
var firetrayUIOptions = {
strings: null,
+ prefwindow: null,
onLoad: function(e) {
this.strings = document.getElementById("firetray-options-strings");
+ this.prefwindow = document.getElementById("firetray-preferences");
+ if (!this.prefwindow)
+ log.error("pref window not found");
if (firetray.Handler.inMailApp) {
Cu.import("resource:///modules/mailServices.js");
@@ -32,7 +36,7 @@ var firetrayUIOptions = {
this.hidePrefPane("pref-pane-mail");
}
- if (firetray.Handler.isChatEnabled())
+ if (firetray.Handler.isChatProvided())
Cu.import("resource://firetray/FiretrayChat.jsm");
else
this.hidePrefPane("pref-pane-chat");
@@ -67,11 +71,9 @@ var firetrayUIOptions = {
},
hidePrefPane: function(name){
- if (!this._prefwindow)
- this._prefwindow = document.getElementById("firetray-preferences");
- let radio = document.getAnonymousElementByAttribute(this._prefwindow, "pane", name);
+ let radio = document.getAnonymousElementByAttribute(this.prefwindow, "pane", name);
if (radio.selected)
- _prefwindow.showPane(document.getElementById(PREF_DEFAULT_PANE));
+ this.prefwindow.showPane(document.getElementById(PREF_DEFAULT_PANE));
radio.hidden = true;
},
@@ -664,14 +666,6 @@ var firetrayUIOptions = {
if (!/\d/.test(charStr))
event.preventDefault();
}
- },
-
- toggleChat: function(enabled) {
- log.debug("Chat icon enable="+enabled);
- if (enabled)
- firetray.Chat.init();
- else
- firetray.Chat.shutdown();
}
};
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 268d8c6..b66577c 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -313,8 +313,7 @@
<checkbox id="ui_chat_icon_enable" preference="pref_chat_icon_enable"
label="&chat_icon_enable.label;"
- accesskey="&chat_icon_enable.accesskey;"
- oncommand="firetrayUIOptions.toggleChat(this.checked);"/>
+ accesskey="&chat_icon_enable.accesskey;"/>
</vbox>
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 45ef444..0bf8a21 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -111,14 +111,15 @@ firetray.Handler = {
}
}
- let chatIsEnabled = this.isChatEnabled();
- log.info('isChatEnabled='+chatIsEnabled);
- if (chatIsEnabled) {
+ let chatIsProvided = this.isChatProvided();
+ log.info('isChatProvided='+chatIsProvided);
+ if (chatIsProvided) {
Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
Cu.import("resource://firetray/FiretrayChat.jsm");
firetray.Utils.addObservers(firetray.Handler, [
"account-added", "account-removed"]);
- if (this.existsChatAccount())
+ if (firetray.Utils.prefService.getBoolPref("chat_icon_enable") &&
+ this.existsChatAccount())
firetray.Chat.init();
}
@@ -139,7 +140,8 @@ firetray.Handler = {
shutdown: function() {
log.debug("Disabling Handler");
- if (firetray.Handler.isChatEnabled()) firetray.Chat.shutdown();
+ if (firetray.Handler.isChatProvided() && firetray.Chat.initialized)
+ firetray.Chat.shutdown();
if (this.inMailApp)
firetray.Messaging.shutdown();
@@ -158,11 +160,14 @@ firetray.Handler = {
},
isChatEnabled: function() {
- return this.appHasChat &&
- Services.prefs.getBoolPref("mail.chat.enabled") &&
+ return this.isChatProvided() &&
firetray.Utils.prefService.getBoolPref("chat_icon_enable");
},
+ isChatProvided: function() {
+ return this.appHasChat && Services.prefs.getBoolPref("mail.chat.enabled");
+ },
+
tryCloseLibs: function() {
try {
for (libName in this.ctypesLibs) {
@@ -233,11 +238,11 @@ firetray.Handler = {
case "account-removed": // emitted by IM
if (!this.existsChatAccount())
- firetray.Chat.shutdown();
+ firetray.Handler.toggleChat(false);
break;
case "account-added": // emitted by IM
if (!firetray.Chat.initialized)
- firetray.Chat.init();
+ firetray.Handler.toggleChat(true);
break;
default:
@@ -245,6 +250,21 @@ firetray.Handler = {
}
},
+ toggleChat: function(enabled) {
+ log.debug("Chat icon enable="+enabled);
+
+ if (enabled) {
+ firetray.Chat.init();
+ for (let winId in firetray.Handler.windows)
+ firetray.ChatStatusIcon.attachOnFocusInCallback(winId);
+
+ } else {
+ for (let winId in firetray.Handler.windows)
+ firetray.ChatStatusIcon.detachOnFocusInCallback(winId);
+ firetray.Chat.shutdown();
+ }
+ },
+
// these get overridden in OS-specific Icon/Window handlers
setIconImageDefault: function() {},
setIconImageNewMail: function() {},
@@ -393,7 +413,7 @@ firetray.Handler = {
// FIXME: since prefs can also be changed from config editor, we need to
-// observe *all* firetray prefs !
+// 1. observe *all* firetray prefs, and 2. change options' UI accordingly !
firetray.PrefListener = new PrefListener(
FIRETRAY_PREF_BRANCH,
function(branch, name) {
@@ -431,6 +451,11 @@ firetray.PrefListener = new PrefListener(
if (firetray.Handler.inMailApp)
firetray.Messaging.updateMsgCountWithCb();
break;
+
+ case 'chat_icon_enable':
+ firetray.Handler.toggleChat(firetray.Handler.isChatEnabled());
+ break;
+
default:
}
});
@@ -441,9 +466,10 @@ firetray.MailChatPrefListener = new PrefListener(
log.debug('MailChat pref changed: '+name);
switch (name) {
case 'enabled':
- let doEnableChat = (firetray.Handler.appHasChat &&
- firetray.Utils.prefService.getBoolPref("chat_icon_enable"));
- if (!doEnableChat) return;
+ let enableChatCond =
+ (firetray.Handler.appHasChat &&
+ firetray.Utils.prefService.getBoolPref("chat_icon_enable"));
+ if (!enableChatCond) return;
if (Services.prefs.getBoolPref("mail.chat.enabled")) {
if (!firetray.Chat) {
@@ -453,9 +479,10 @@ firetray.MailChatPrefListener = new PrefListener(
"account-added", "account-removed"]);
}
if (firetray.Handler.existsChatAccount())
- firetray.Chat.init();
+ firetray.Handler.toggleChat(true);
+
} else {
- firetray.Chat.shutdown();
+ firetray.Handler.toggleChat(false);
}
break;
default:
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index a1d3ee1..e1d8e4d 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -165,10 +165,10 @@ firetray.Messaging = {
if (!this.initialized) return;
if ("undefined" === typeof(callback) || !callback)
- callback = function(msgCountChange, newMsgCount) { // default
+ callback = function(msgCountChanged, newMsgCount) { // default
firetray.Messaging.updateIcon(newMsgCount);
- if (msgCountChange) {
+ if (msgCountChanged) {
let mailChangeTriggerFile = firetray.Utils.prefService.getCharPref("mail_change_trigger");
if (mailChangeTriggerFile)
firetray.Messaging.runProcess(mailChangeTriggerFile, [newMsgCount.toString()]);
@@ -184,8 +184,8 @@ firetray.Messaging = {
} else
log.error('unknown message count type');
- let msgCountChange = (this.newMsgCount !== this.currentMsgCount);
- callback.call(this, msgCountChange, this.newMsgCount);
+ let msgCountChanged = (this.newMsgCount !== this.currentMsgCount);
+ callback.call(this, msgCountChanged, this.newMsgCount);
this.currentMsgCount = this.newMsgCount;
},
diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm
index caea80f..18e6ecd 100644
--- a/src/modules/linux/FiretrayChatStatusIcon.jsm
+++ b/src/modules/linux/FiretrayChatStatusIcon.jsm
@@ -9,6 +9,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
+Cu.import("resource://firetray/ctypes/ctypesMap.jsm");
Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
Cu.import("resource://firetray/ctypes/linux/gio.jsm");
Cu.import("resource://firetray/ctypes/linux/gdk.jsm");
@@ -36,7 +37,7 @@ firetray.ChatStatusIcon = {
o[FIRETRAY_IM_STATUS_OFFLINE] = null;
return o;
})(),
- callbacks: {onFocusIn: {}},
+ signals: {'focus-in': {callback: {}, handler: {}}},
init: function() {
if (!firetray.Handler.inMailApp) throw "ChatStatusIcon for mail app only";
@@ -96,9 +97,20 @@ firetray.ChatStatusIcon = {
attachOnFocusInCallback: function(xid) {
log.debug("attachOnFocusInCallback xid="+xid);
- this.callbacks.onFocusIn[xid] = gtk.GCallbackWidgetFocuEvent_t(firetray.ChatStatusIcon.onFocusIn);
- gobject.g_signal_connect(firetray.Handler.gtkWindows.get(xid),
- "focus-in-event", firetray.ChatStatusIcon.callbacks.onFocusIn[xid], null);
+ this.signals['focus-in'].callback[xid] =
+ gtk.GCallbackWidgetFocuEvent_t(firetray.ChatStatusIcon.onFocusIn);
+ this.signals['focus-in'].handler[xid] = gobject.g_signal_connect(
+ firetray.Handler.gtkWindows.get(xid), "focus-in-event",
+ firetray.ChatStatusIcon.signals['focus-in'].callback[xid], null);
+ log.debug("focus-in handler="+this.signals['focus-in'].handler[xid]);
+ },
+
+ detachOnFocusInCallback: function(xid) {
+ log.debug("detachOnFocusInCallback xid="+xid);
+ let gtkWin = firetray.Handler.gtkWindows.get(xid);
+ gobject.g_signal_handler_disconnect(gtkWin, this.signals['focus-in'].handler[xid]);
+ delete this.signals['focus-in'].callback[xid];
+ delete this.signals['focus-in'].handler[xid];
},
// NOTE: fluxbox issues a FocusIn event when switching workspace by hotkey :(
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index f3a2b30..78832e4 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -68,6 +68,11 @@ firetray.Window = {
if (!gtkVersionCheck.isNull())
log.error("gtk_check_version="+gtkVersionCheck.readString());
+ if (firetray.Handler.isChatEnabled()) {
+ Cu.import("resource://firetray/FiretrayChat.jsm");
+ Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
+ }
+
this.initialized = true;
},
@@ -210,6 +215,9 @@ firetray.Window = {
return false;
}
+ if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized)
+ firetray.ChatStatusIcon.detachOnFocusInCallback(xid);
+
if (!delete firetray.Handler.windows[xid])
throw new DeleteError();
firetray.Handler.gtkWindows.remove(xid);
@@ -650,10 +658,8 @@ firetray.Handler.registerWindow = function(win) {
this.windows[xid].startupFilterCb = gdk.GdkFilterFunc_t(firetray.Window.startupFilter);
gdk.gdk_window_add_filter(gdkWin, this.windows[xid].startupFilterCb, null);
- if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized) { // missing import ok
- Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
+ if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized)
firetray.ChatStatusIcon.attachOnFocusInCallback(xid);
- }
} catch (x) {
firetray.Window.unregisterWindowByXID(xid);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list