[Pkg-mozext-commits] [firetray] 355/399: support urgency hint

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:13 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 3aca4f64f18e2efa2312d86c469f9440a4b6282e
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sat Mar 30 01:12:35 2013 +0100

    support urgency hint
---
 src/modules/FiretrayChat.jsm                 |   38 ++++++++++++++++++--------
 src/modules/ctypes/linux/gtk.jsm             |    1 +
 src/modules/linux/FiretrayChatStatusIcon.jsm |   10 +++++--
 3 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm
index 71221d2..29b27c9 100644
--- a/src/modules/FiretrayChat.jsm
+++ b/src/modules/FiretrayChat.jsm
@@ -60,13 +60,13 @@ firetray.Chat = {
     case "new-directed-incoming-message": // when PM or cited in channel
       let conv = subject.QueryInterface(Ci.prplIMessage).conversation;
       log.debug("conversation name="+conv.name); // normalizedName shouldn't be necessary
-      this.startIconBlinkingMaybe(conv);
+      this.startGetAttentionMaybe(conv);
       break;
 
     case "unread-im-count-changed":
       let unreadMsgCount = data;
       if (unreadMsgCount == 0)
-        this.stopIconBlinkingMaybe();
+        this.stopGetAttentionMaybe(firetray.Handler.findActiveWindow());
 
       let localizedTooltip = PluralForm.get(
         unreadMsgCount,
@@ -80,21 +80,38 @@ firetray.Chat = {
     }
   },
 
-  // rename to setUrgency(bool), and possibly handle blinking ourselves
-  // (gtk_status_icon_set_blinking deprecated)
-  startIconBlinkingMaybe: function(conv) {
+  startGetAttentionMaybe: function(conv) {
+    log.debug('startGetAttentionMaybe');
     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;
+
+      /* there can potentially be multiple windows, each with a Chat tab and
+       the same conv open... so we need to handle all windows */
+      for (let xid in firetray.Handler.windows) {
+        let win = firetray.Handler.windows[xid].chromeWin;
+        let contactlist = win.document.getElementById("contactlistbox");
+        for (let i=0; i<contactlist.itemCount; ++i) {
+          let item = contactlist.getItemAtIndex(i);
+          if (item.localName !== 'imconv')
+            continue;
+          if (item.hasOwnProperty('conv') && item.conv.target === conv) {
+            firetray.ChatStatusIcon.setUrgency(xid, true);
+          }
+        }
+      }
+
       firetray.ChatStatusIcon.setIconBlinking(true);
-      // TODO: + gtk_window_set_urgency_hint(true)
     }
   },
 
-  stopIconBlinkingMaybe: function(xid) { // xid optional
-    log.error("acknowledgeOnFocus.must="+this.acknowledgeOnFocus.must);
+  /**
+   * @param xid id of the window that MUST have initiated this event
+   */
+  stopGetAttentionMaybe: function(xid) {
+    log.debug("stopGetAttentionMaybe acknowledgeOnFocus.must="+this.acknowledgeOnFocus.must);
     if (!this.acknowledgeOnFocus.must) return;
 
     let convIsCurrentlyShown = this.isConvCurrentlyShown(
@@ -102,14 +119,13 @@ firetray.Chat = {
     log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
 
     if (this.acknowledgeOnFocus.must && convIsCurrentlyShown) {
-      // TODO: + gtk_window_set_urgency_hint(false)
+      firetray.ChatStatusIcon.setUrgency(xid, false);
       firetray.ChatStatusIcon.setIconBlinking(false);
       this.acknowledgeOnFocus.must = false;
     }
   },
 
-  isConvCurrentlyShown: function(conv, xid) {
-    let activeWin = xid || firetray.Handler.findActiveWindow();
+  isConvCurrentlyShown: function(conv, activeWin) {
     if (!firetray.Handler.windows[activeWin]) return false;
 
     let activeChatTab = this.findSelectedChatTab(activeWin);
diff --git a/src/modules/ctypes/linux/gtk.jsm b/src/modules/ctypes/linux/gtk.jsm
index 6aa3c1b..81769d3 100644
--- a/src/modules/ctypes/linux/gtk.jsm
+++ b/src/modules/ctypes/linux/gtk.jsm
@@ -120,6 +120,7 @@ function gtk_defines(lib) {
   lib.lazy_bind("gtk_widget_get_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
   lib.lazy_bind("gtk_widget_get_parent_window", gdk.GdkWindow.ptr, this.GtkWidget.ptr);
   lib.lazy_bind("gtk_window_set_decorated", ctypes.void_t, this.GtkWindow.ptr, gobject.gboolean);
+  lib.lazy_bind("gtk_window_set_urgency_hint", ctypes.void_t, this.GtkWindow.ptr, gobject.gboolean);
 
   lib.lazy_bind("gtk_widget_is_focus", gobject.gboolean, this.GtkWidget.ptr);
   lib.lazy_bind("gtk_widget_has_focus", gobject.gboolean, this.GtkWidget.ptr);
diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm
index 18e6ecd..775af45 100644
--- a/src/modules/linux/FiretrayChatStatusIcon.jsm
+++ b/src/modules/linux/FiretrayChatStatusIcon.jsm
@@ -81,10 +81,15 @@ firetray.ChatStatusIcon = {
     this.setIconImageFromGIcon(this.themedIcons[name]);
   },
 
+  // TODO: handle blinking ourselves (gtk_status_icon_set_blinking deprecated)
   setIconBlinking: function(blink) {
     gtk.gtk_status_icon_set_blinking(this.trayIcon, blink);
   },
 
+  setUrgency: function(xid, urgent) {
+    gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), urgent);
+  },
+
   setIconTooltip: function(txt) {
     if (!this.trayIcon) return false;
     gtk.gtk_status_icon_set_tooltip_text(this.trayIcon, txt);
@@ -113,13 +118,14 @@ firetray.ChatStatusIcon = {
     delete this.signals['focus-in'].handler[xid];
   },
 
-  // NOTE: fluxbox issues a FocusIn event when switching workspace by hotkey :(
+  // NOTE: fluxbox issues a FocusIn event when switching workspace
+  // by hotkey, which means 2 FocusIn events when switching to a moz app :(
   // (http://sourceforge.net/tracker/index.php?func=detail&aid=3190205&group_id=35398&atid=413960)
   onFocusIn: function(widget, event, data) {
     log.debug("onFocusIn");
     let xid = firetray.Window.getXIDFromGtkWidget(widget);
     log.debug("xid="+xid);
-    firetray.Chat.stopIconBlinkingMaybe(xid);
+    firetray.Chat.stopGetAttentionMaybe(xid);
   }
 
   // FIXME: TODO: onclick/activate -> chatHandler.showCurrentConversation()

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