[Pkg-mozext-commits] [firetray] 322/399: appropriate way of determining if a conversation is currently shown

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:07 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 b20db43bdde7f059749af012f84ff72099768652
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Fri Oct 19 01:19:44 2012 +0200

    appropriate way of determining if a conversation is currently shown
---
 src/modules/FiretrayChat.jsm |   39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm
index 4063c6f..b6c29a4 100644
--- a/src/modules/FiretrayChat.jsm
+++ b/src/modules/FiretrayChat.jsm
@@ -61,9 +61,9 @@ firetray.Chat = {
       let conv = subject.QueryInterface(Ci.prplIMessage).conversation;
       log.debug("conversation name="+conv.name); // normalizedName shouldn't be necessary
 
-      let convIsActiveTabInActiveWin = this.isConvActiveTabInActiveWindow(conv);
-      log.debug("convIsActiveTabInActiveWin="+convIsActiveTabInActiveWin);
-      if (!convIsActiveTabInActiveWin) { // don't blink when conv tab already on top
+      let convIsCurrentlyShown = this.isConvCurrentlyShown(conv);
+      log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
+      if (!convIsCurrentlyShown) { // don't blink when conv tab already on top
         this.acknowledgeOnFocus.must = true;
         this.acknowledgeOnFocus.conv = conv;
         firetray.ChatStatusIcon.setIconBlinking(true);
@@ -91,30 +91,34 @@ firetray.Chat = {
     log.debug("acknowledgeOnFocus.must="+this.acknowledgeOnFocus.must);
     if (!this.acknowledgeOnFocus.must) return;
 
-    let convIsActiveTabInActiveWin = this.isConvActiveTabInActiveWindow(
+    let convIsCurrentlyShown = this.isConvCurrentlyShown(
       this.acknowledgeOnFocus.conv, xid);
-    log.debug("convIsActiveTabInActiveWin="+convIsActiveTabInActiveWin);
+    log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
 
-    if (this.acknowledgeOnFocus.must && convIsActiveTabInActiveWin) {
+    if (this.acknowledgeOnFocus.must && convIsCurrentlyShown) {
       firetray.ChatStatusIcon.setIconBlinking(false);
       this.acknowledgeOnFocus.must = false;
     }
   },
 
-  isConvActiveTabInActiveWindow: function(conv, xid) {
+  isConvCurrentlyShown: function(conv, xid) {
     let activeWin = xid || firetray.Handler.findActiveWindow();
     if (!firetray.Handler.windows[activeWin]) return false;
 
-    let activeChatTab = null;
-    activeChatTab = this.findActiveChatTab(activeWin);
+    let activeChatTab = this.findSelectedChatTab(activeWin);
+    if (!activeChatTab) return false;
 
-    let convNameRegex = new RegExp(" - "+conv.title+"$");
-    let title = activeChatTab && activeChatTab.title;
-    log.debug("conv.title='"+conv.title+"' title="+title);
-    return convNameRegex.test(title);
+    // for now there is only one Chat tab, so we don't need to
+    // findSelectedChatTabFromTab(activeChatTab.tabNode). And, as there is only
+    // one forlderPaneBox, there will also probably be only one contactlistbox
+    // for all Chat tabs anyway
+    let selectedConv = this.findSelectedConv(activeWin);
+
+    log.debug("conv.title='"+conv.title+"' selectedConv.title='"+selectedConv.title+"'");
+    return (conv.id == selectedConv.id);
   },
 
-  findActiveChatTab: function(xid) {
+  findSelectedChatTab: function(xid) {
     let win = firetray.Handler.windows[xid].chromeWin;
     let tabmail = win.document.getElementById("tabmail");
     let chatTabs = tabmail.tabModes.chat.tabs;
@@ -123,6 +127,13 @@ firetray.Chat = {
     return null;
   },
 
+  findSelectedConv: function(xid) {
+    let win = firetray.Handler.windows[xid].chromeWin;
+    let selectedItem = win.document.getElementById("contactlistbox").selectedItem;
+    if (!selectedItem || selectedItem.localName != "imconv") return null;
+    return selectedItem.conv;
+  },
+
   updateIcon: function() {
     let globalConnectedStatus = this.globalConnectedStatus();
     let userStatus;

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