[Pkg-mozext-commits] [firetray] 313/399: * fix TB crash when mail.chat.enabled is false (#58) * fix item menu titles for Seamonkey * fix middle-click (activate) to show window when hidden

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:05 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 8516409607bf4ffa5709051c3ea6405ab980eaff
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sun Sep 9 01:29:51 2012 +0200

    * fix TB crash when mail.chat.enabled is false (#58)
    * fix item menu titles for Seamonkey
    * fix middle-click (activate) to show window when hidden
---
 src/chrome/content/options.js        |    2 +-
 src/modules/FiretrayHandler.jsm      |   54 +++++++++++++++++++++++++++++-----
 src/modules/linux/FiretrayWindow.jsm |   35 ++++++++++++----------
 3 files changed, 66 insertions(+), 25 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 25e5b27..da5841f 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -32,7 +32,7 @@ var firetrayUIOptions = {
       this.hidePrefPane("pref-pane-mail");
     }
 
-    if (firetray.Handler.appHasChat)
+    if (firetray.Handler.isChatEnabled())
       Cu.import("resource://firetray/FiretrayChat.jsm");
     else
       this.hidePrefPane("pref-pane-chat");
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 5a031e6..d579b13 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -57,6 +57,7 @@ firetray.Handler = {
 
   init: function() {            // does creates icon
     firetray.PrefListener.register(false);
+    firetray.MailChatPrefListener.register(false);
 
     // version checked during install, so we shouldn't need to care
     let xulVer = Services.appinfo.platformVersion; // Services.vc.compare(xulVer,"2.0a")>=0
@@ -105,8 +106,7 @@ firetray.Handler = {
       }
     }
 
-    if (this.appHasChat && Services.prefs.getBoolPref("mail.chat.enabled") &&
-        firetray.Utils.prefService.getBoolPref("chat_icon_enable")) {
+    if (this.isChatEnabled()) {
       Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
       Cu.import("resource://firetray/FiretrayChat.jsm");
       firetray.Utils.addObservers(firetray.Handler, [
@@ -127,9 +127,7 @@ firetray.Handler = {
 
   shutdown: function() {
     log.debug("Disabling Handler");
-    firetray.PrefListener.unregister();
-
-    if (firetray.Handler.appHasChat) firetray.Chat.shutdown();
+    if (firetray.Handler.isChatEnabled()) firetray.Chat.shutdown();
 
     if (this.inMailApp)
       firetray.Messaging.shutdown();
@@ -139,11 +137,22 @@ firetray.Handler = {
 
     firetray.Utils.removeAllObservers(this);
 
+    firetray.MailChatPrefListener.register(false);
+    firetray.PrefListener.unregister();
+
     this.appStarted = false;
     this.initialized = false;
     return true;
   },
 
+  isChatEnabled: function() {
+    let chatIsEnabled = (this.appHasChat &&
+                         Services.prefs.getBoolPref("mail.chat.enabled") &&
+                         firetray.Utils.prefService.getBoolPref("chat_icon_enable"));
+    log.info('isChatEnabled='+chatIsEnabled);
+    return chatIsEnabled;
+  },
+
   tryCloseLibs: function() {
     try {
       for (libName in this.ctypesLibs) {
@@ -183,6 +192,7 @@ firetray.Handler = {
     case "sessionstore-windows-restored":
     case "mail-startup-done":
     case "final-ui-startup":
+      if (firetray.Handler.appStarted) return; // second TB window issues "mail-startup-done"
       log.debug("RECEIVED: "+topic+", launching timer");
       // sessionstore-windows-restored does not come after the realization of
       // all windows... so we wait a little
@@ -200,11 +210,11 @@ firetray.Handler = {
         this.restoreWarnOnClose();
       break;
 
-    case "account-removed":
+    case "account-removed":     // emitted by IM
       if (!this.existsChatAccount())
         firetray.Chat.shutdown();
       break;
-    case "account-added":
+    case "account-added":       // emitted by IM
       if (!firetray.Chat.initialized)
         firetray.Chat.init();
       break;
@@ -370,8 +380,10 @@ firetray.Handler = {
 }; // firetray.Handler
 
 
+// FIXME: since prefs can also be changed from config editor, we need to
+// observe *all* firetray prefs !
 firetray.PrefListener = new PrefListener(
-  "extensions.firetray.",
+  FIRETRAY_PREF_BRANCH,
   function(branch, name) {
     log.debug('Pref changed: '+name);
     switch (name) {
@@ -411,6 +423,32 @@ firetray.PrefListener = new PrefListener(
     }
   });
 
+firetray.MailChatPrefListener = new PrefListener(
+  "mail.chat.",
+  function(branch, name) {
+    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;
+
+      if (Services.prefs.getBoolPref("mail.chat.enabled")) {
+        if (!firetray.Chat) {
+          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 (firetray.Handler.existsChatAccount())
+          firetray.Chat.init();
+      } else {
+        firetray.Chat.shutdown();
+      }
+      break;
+    default:
+    }
+  });
 
 firetray.VersionChangeHandler = {
 
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index 8c4fbc7..684beab 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -202,18 +202,18 @@ firetray.Window = {
   },
 
   unregisterWindowByXID: function(xid) {
-    this.updateVisibility(xid, false);
-
-    if (firetray.Handler.windows.hasOwnProperty(xid)) {
-      if (!delete firetray.Handler.windows[xid])
-        throw new DeleteError();
-      firetray.Handler.gtkWindows.remove(xid);
-      firetray.Handler.gdkWindows.remove(xid);
-      firetray.PopupMenu.removeWindowItem(xid);
-    } else {
+    if (!firetray.Handler.windows.hasOwnProperty(xid)) {
       log.error("can't unregister unknown window "+xid);
       return false;
     }
+
+    if (!delete firetray.Handler.windows[xid])
+      throw new DeleteError();
+    firetray.Handler.gtkWindows.remove(xid);
+    firetray.Handler.gdkWindows.remove(xid);
+    firetray.PopupMenu.removeWindowItem(xid);
+    firetray.Handler.visibleWindowsCount -= 1;
+
     log.debug("window "+xid+" unregistered");
     return true;
   },
@@ -490,7 +490,11 @@ firetray.Window = {
   getWindowTitle: function(xid) {
     let title = firetray.Handler.windows[xid].baseWin.title;
     log.debug("|baseWin.title="+title+"|");
-    let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appName);
+    let tailIndex;
+    if (firetray.Handler.appId === FIRETRAY_SEAMONKEY_ID)
+      tailIndex = title.indexOf(" - "+firetray.Handler.appName);
+    else
+      tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appName);
     if (tailIndex !== -1)
       return title.substring(0, tailIndex);
     else if (title === "Mozilla "+firetray.Handler.appName)
@@ -603,7 +607,7 @@ firetray.Handler.registerWindow = function(win) {
     this.windows[xid].filterWindowCb = gdk.GdkFilterFunc_t(firetray.Window.filterWindow);
     gdk.gdk_window_add_filter(gdkWin, this.windows[xid].filterWindowCb, null);
 
-    if (firetray.Handler.appHasChat && firetray.Chat.initialized) { // missing import ok
+    if (firetray.Handler.isChatEnabled() && firetray.Chat.initialized) { // missing import ok
       Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
       firetray.ChatStatusIcon.attachOnFocusInCallback(xid);
     }
@@ -657,12 +661,11 @@ firetray.Handler.activateLastWindow = function(gtkStatusIcon, gdkEvent, userData
 
     let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
     log.debug("visibilityRate="+visibilityRate);
-    if (visibilityRate === 1) {
-      for(var key in firetray.Handler.windows);
-      firetray.Window.activate(key);
-    } else {
+    if (visibilityRate < 1)
       firetray.Handler.showAllWindows();
-    }
+
+    for(var key in firetray.Handler.windows);
+    firetray.Window.activate(key);
   }
 
   let stopPropagation = false;

-- 
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