[Pkg-mozext-commits] [firetray] 370/399: * add chat_icon_blink, chat_icon_blink_style options * fix MailChatPrefListener unregistering * use GDK_INTERP_BILINEAR for gdk_pixbuf_composite
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:24:16 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 08bd79a1c977a731664011d5b361be88132b5802
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Fri May 10 15:33:50 2013 +0200
* add chat_icon_blink, chat_icon_blink_style options
* fix MailChatPrefListener unregistering
* use GDK_INTERP_BILINEAR for gdk_pixbuf_composite
---
src/chrome/content/options.js | 45 +++++++++++++++++++++--
src/chrome/content/options.xul | 26 +++++++++++++-
src/chrome/locale/en-US/options.dtd | 8 +++++
src/defaults/preferences/prefs.js | 2 ++
src/modules/FiretrayChat.jsm | 50 ++++++++++++++++++--------
src/modules/FiretrayHandler.jsm | 32 +++++++++++++++--
src/modules/commons.js | 5 +++
src/modules/ctypes/linux/gdk.jsm | 5 ++-
src/modules/linux/FiretrayChatStatusIcon.jsm | 9 +++--
src/modules/linux/FiretrayStatusIcon.jsm | 2 +-
src/modules/linux/FiretrayWindow.jsm | 2 +-
11 files changed, 162 insertions(+), 24 deletions(-)
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 1b1e2ce..5029789 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -36,9 +36,10 @@ var firetrayUIOptions = {
this.hidePrefPane("pref-pane-mail");
}
- if (firetray.Handler.isChatProvided())
+ if (firetray.Handler.isChatProvided()) {
Cu.import("resource://firetray/FiretrayChat.jsm");
- else
+ this.initChatControls();
+ } else
this.hidePrefPane("pref-pane-chat");
this.updateWindowAndIconOptions();
@@ -195,6 +196,11 @@ var firetrayUIOptions = {
this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
},
+ initChatControls: function() {
+ this.initChatBlinkSettings();
+ this.toggleChatIcon(firetray.Utils.prefService.getBoolPref("chat_icon_enable"));
+ },
+
initNotificationSettings: function() {
document.getElementById("ui_radio_mail_notification_unread_count").value =
FIRETRAY_NOTIFICATION_MESSAGE_COUNT;
@@ -224,6 +230,17 @@ var firetrayUIOptions = {
// this.disableMessageCountMaybe(prefMsgCountType); // done in toggleNotifications()
},
+ initChatBlinkSettings: function() {
+ document.getElementById("ui_chat_icon_blink_style_normal").value =
+ FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL;
+ document.getElementById("ui_chat_icon_blink_style_cross_fade").value =
+ FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE;
+
+ let blinkStyle = document.getElementById("ui_chat_icon_blink_style");
+ let prefBlinkStyle = firetray.Utils.prefService.getIntPref("chat_icon_blink_style");
+ blinkStyle.selectedIndex = this.radioGetIndexByValue(blinkStyle, prefBlinkStyle);
+ },
+
radioGetIndexByValue: function(radio, value) {
for (let i=0, len=radio.itemCount; i<len; ++i)
if (+radio.getItemAtIndex(i).value == value) return i;
@@ -256,6 +273,12 @@ var firetrayUIOptions = {
this.disableMessageCountMaybe(messageCountType);
},
+ updateChatBlinkSettings: function() {
+ let radioBlinkStyle = document.getElementById("ui_chat_icon_blink_style");
+ let blinkStyle = +radioBlinkStyle.getItemAtIndex(radioBlinkStyle.selectedIndex).value;
+ firetray.Utils.prefService.setIntPref("chat_icon_blink_style", blinkStyle);
+ },
+
disableNotificationMaybe: function(notificationSetting) {
log.debug("disableNotificationMaybe: "+notificationSetting);
@@ -307,6 +330,24 @@ var firetrayUIOptions = {
}
},
+ toggleChatIcon: function(enabled) {
+ if (enabled) {
+ document.getElementById("broadcaster-chat-icon-disabled")
+ .removeAttribute("disabled"); // UI update (enables!)
+
+ this.toggleChatIconBlink(
+ firetray.Utils.prefService.getBoolPref("chat_icon_blink"));
+
+ } else {
+ document.getElementById("broadcaster-chat-icon-disabled")
+ .setAttribute("disabled", "true"); // UI update
+ }
+ },
+
+ toggleChatIconBlink: function(enabled) {
+ this.disableElementsRecursive(document.getElementById("ui_chat_icon_blink_style"), !enabled);
+ },
+
chooseAppIconFile: function() {
let updateIcon = firetray.Handler.setIconImageDefault.bind(firetray.Handler);
this._chooseIconFile("app_icon_custom_filename");
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index b66577c..78db2b1 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -14,6 +14,7 @@
<broadcasterset>
<broadcaster id="broadcaster-notification-disabled" disabled="false" />
+ <broadcaster id="broadcaster-chat-icon-disabled" disabled="false" />
</broadcasterset>
<prefpane id="pref-pane-windows" label="&windows_options;"
@@ -307,13 +308,36 @@
<preferences>
<preference id="pref_chat_icon_enable" name="extensions.firetray.chat_icon_enable" type="bool" />
+ <preference id="pref_chat_icon_blink" name="extensions.firetray.chat_icon_blink" type="bool" />
+ <preference id="pref_chat_icon_blink_style" name="extensions.firetray.chat_icon_blink_style" type="int" />
</preferences>
<vbox align="left" flex="1">
<checkbox id="ui_chat_icon_enable" preference="pref_chat_icon_enable"
label="&chat_icon_enable.label;"
- accesskey="&chat_icon_enable.accesskey;"/>
+ accesskey="&chat_icon_enable.accesskey;"
+ oncommand="firetrayUIOptions.toggleChatIcon(this.checked)"/>
+
+ <checkbox id="ui_chat_icon_blink" preference="pref_chat_icon_blink"
+ label="&chat_icon_blink.label;"
+ accesskey="&chat_icon_blink.accesskey;"
+ tooltiptext="&chat_icon_blink.tooltip;"
+ oncommand="firetrayUIOptions.toggleChatIconBlink(this.checked)"
+ observes="broadcaster-chat-icon-disabled" />
+
+ <radiogroup id="ui_chat_icon_blink_style" preference="pref_chat_icon_blink_style">
+ <hbox align="center" flex="1">
+ <label control="ui_chat_icon_blink_style" observes="broadcaster-chat-icon-disabled"
+ value="&chat_icon_blink_style.label;" accesskey="&chat_icon_blink_style.accesskey;" />
+ <radio id="ui_chat_icon_blink_style_normal" label="&chat_icon_blink_style_normal;"
+ oncommand="firetrayUIOptions.updateChatBlinkSettings()"
+ observes="broadcaster-chat-icon-disabled"/>
+ <radio id="ui_chat_icon_blink_style_cross_fade" label="&chat_icon_blink_style_cross_fade;"
+ oncommand="firetrayUIOptions.updateChatBlinkSettings()"
+ observes="broadcaster-chat-icon-disabled"/>
+ </hbox>
+ </radiogroup>
</vbox>
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index dea845b..8c6e370 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -90,3 +90,11 @@
<!ENTITY chat_icon_enable.label "Enable chat icon">
<!ENTITY chat_icon_enable.accesskey "E">
+<!ENTITY chat_icon_blink.label "Chat icon blinks on new messages">
+<!ENTITY chat_icon_blink.accesskey "C">
+<!ENTITY chat_icon_blink.tooltip "when private message or cited in a channel">
+
+<!ENTITY chat_icon_blink_style.label "Blink style">
+<!ENTITY chat_icon_blink_style.accesskey "B">
+<!ENTITY chat_icon_blink_style_normal "Simple">
+<!ENTITY chat_icon_blink_style_cross_fade "Cross-fade">
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index ec954fc..6fea825 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -22,6 +22,8 @@ pref("extensions.firetray.show_icon_on_hide", false);
pref("extensions.firetray.scroll_hides", true);
pref("extensions.firetray.scroll_mode", "down_hides");
pref("extensions.firetray.chat_icon_enable", true);
+pref("extensions.firetray.chat_icon_blink", true);
+pref("extensions.firetray.chat_icon_blink_style", 0);
pref("extensions.firetray.message_count_type", 0);
pref("extensions.firetray.mail_notification_enabled", true);
diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm
index d1aea37..19a96ea 100644
--- a/src/modules/FiretrayChat.jsm
+++ b/src/modules/FiretrayChat.jsm
@@ -19,6 +19,7 @@ firetray.Chat = {
ids: {},
length: function(){return Object.keys(this.ids).length;}
},
+ get isBlinking () {return (this.shouldAcknowledgeConvs.length() > 0);},
init: function() {
if (this.initialized) {
@@ -122,21 +123,33 @@ firetray.Chat = {
startGetAttentionMaybe: function(conv) {
log.debug('startGetAttentionMaybe conv.id='+conv.id);
- if (this.shouldAcknowledgeConvs.ids[conv.id]) return; // multiple messages
+ if (!firetray.Utils.prefService.getBoolPref("chat_icon_blink")) return;
let convIsCurrentlyShown =
this.isConvCurrentlyShown(conv, firetray.Handler.findActiveWindow());
log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
if (convIsCurrentlyShown) return; // don't blink when conv tab already on top
- this.shouldAcknowledgeConvs.ids[conv.id] = conv;
- log.debug(conv.id+' added to shouldAcknowledgeConvs');
- log.debug('shouldAcknowledgeConvs.length='+this.shouldAcknowledgeConvs.length());
+ this.startGetAttention(conv);
- if (this.shouldAcknowledgeConvs.length() > 1) return; // already calling attention
+ this.shouldAcknowledgeConvs.ids[conv.id] = conv;
+ log.debug(conv.id+' added to shouldAcknowledgeConvs, length='+this.shouldAcknowledgeConvs.length());
+ },
+ startGetAttention: function(conv) {
+ log.debug("startGetAttention");
this.setUrgencyMaybe(conv);
- firetray.ChatStatusIcon.startIconBlinking();
+
+ log.info("this.isBlinking="+this.isBlinking);
+ if (this.isBlinking) return;
+ let blinkStyle = firetray.Utils.prefService.getIntPref("chat_icon_blink_style");
+ log.debug("chat_icon_blink_style="+blinkStyle);
+ if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL)
+ firetray.ChatStatusIcon.startIconBlinking();
+ else if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE)
+ firetray.ChatStatusIcon.startCrossFading();
+ else
+ throw new Error("Undefined chat icon blink style.");
},
/**
@@ -144,14 +157,13 @@ firetray.Chat = {
*/
stopGetAttentionMaybe: function(xid) {
log.debug("stopGetAttentionMaybe");
- let shouldAcknowledgeConvsLength = this.shouldAcknowledgeConvs.length();
- log.debug("shouldAcknowledgeConvsLength="+shouldAcknowledgeConvsLength);
- if (!shouldAcknowledgeConvsLength) return;
+ log.debug("shouldAcknowledgeConvsLength="+this.shouldAcknowledgeConvs.length());
+ if (!this.isBlinking) return; // instead of pref chat_icon_blink — if pref was just unset
let selectedConv = this.getSelectedConv(xid);
if (!selectedConv) return;
- for (convId in this.shouldAcknowledgeConvs.ids) {
+ for (let convId in this.shouldAcknowledgeConvs.ids) {
log.debug(convId+" == "+selectedConv.id);
if (convId == selectedConv.id) {
delete this.shouldAcknowledgeConvs.ids[convId];
@@ -159,11 +171,21 @@ firetray.Chat = {
}
}
- if(this.shouldAcknowledgeConvs.length() === 0) {
- log.debug("do stop icon blinking !!!");
- firetray.ChatStatusIcon.setUrgency(xid, false);
+ if (this.shouldAcknowledgeConvs.length() === 0)
+ this.stopGetAttention(xid);
+ },
+
+ stopGetAttention: function(xid) {
+ log.debug("do stop icon blinking !!!");
+ firetray.ChatStatusIcon.setUrgency(xid, false);
+
+ let blinkStyle = firetray.Utils.prefService.getIntPref("chat_icon_blink_style");
+ if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL)
firetray.ChatStatusIcon.stopIconBlinking();
- }
+ else if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE)
+ firetray.ChatStatusIcon.stopCrossFading();
+ else
+ throw new Error("Undefined chat icon blink style.");
},
onSelect: function(event) {
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 4b39800..b30a1bf 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -153,7 +153,7 @@ firetray.Handler = {
firetray.Utils.removeAllObservers(this);
- firetray.MailChatPrefListener.register(false);
+ firetray.MailChatPrefListener.unregister(false);
firetray.PrefListener.unregister();
this.appStarted = false;
@@ -209,7 +209,7 @@ firetray.Handler = {
firetray.Utils.timer(FIRETRAY_DELAY_STARTUP_MILLISECONDS,
Ci.nsITimer.TYPE_ONE_SHOT, function() {
firetray.Handler.appStarted = true;
- log.debug("*** appStarted ***");
+ log.info("*** appStarted ***");
});
},
@@ -462,6 +462,34 @@ firetray.PrefListener = new PrefListener(
firetray.Handler.toggleChat(firetray.Handler.isChatEnabled());
break;
+ case 'chat_icon_blink':
+ if (!firetray.Utils.prefService.getBoolPref('chat_icon_blink') &&
+ firetray.Chat.isBlinking) {
+ /* FIXME: stopGetAttention() needs a window id. For now just pass the
+ active window */
+ firetray.Chat.stopGetAttention(firetray.Handler.findActiveWindow());
+ }
+ break;
+
+ case 'chat_icon_blink_style':
+ if (!(firetray.Utils.prefService.getBoolPref('chat_icon_blink') &&
+ firetray.Chat.isBlinking))
+ break;
+
+ switch (firetray.Utils.prefService.getIntPref("chat_icon_blink_style")) {
+ case FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL:
+ firetray.ChatStatusIcon.stopCrossFading();
+ firetray.ChatStatusIcon.startIconBlinking();
+ break;
+ case FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE:
+ firetray.ChatStatusIcon.stopIconBlinking();
+ firetray.ChatStatusIcon.startCrossFading();
+ break;
+ default:
+ throw new Error("Undefined chat icon blink style.");
+ }
+ break;
+
default:
}
});
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 41190bd..0b15664 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -15,6 +15,8 @@ var EXPORTED_SYMBOLS =
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS",
"FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS",
"FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD", "FIRETRAY_MESSAGE_COUNT_TYPE_NEW",
+ "FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
+ "FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE",
"FIRETRAY_APP_DB" ];
const Cc = Components.classes;
@@ -50,6 +52,9 @@ const FIRETRAY_DELAY_STARTUP_MILLISECONDS = 500;
const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000;
+const FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL = 0;
+const FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE = 1;
+
const FIRETRAY_APP_DB = {
firefox: {
diff --git a/src/modules/ctypes/linux/gdk.jsm b/src/modules/ctypes/linux/gdk.jsm
index b665499..473e92c 100644
--- a/src/modules/ctypes/linux/gdk.jsm
+++ b/src/modules/ctypes/linux/gdk.jsm
@@ -55,7 +55,10 @@ Cu.import("resource://firetray/ctypes/linux/x11.jsm");
function gdk_defines(lib) {
this.GdkInterpType = ctypes.int; // enum
- this.GDK_INTERP_NEAREST = 0;
+ this.GDK_INTERP_NEAREST = 0;
+ this.GDK_INTERP_TILES = 1;
+ this.GDK_INTERP_BILINEAR = 2;
+ this.GDK_INTERP_HYPE = 3;
this.GdkFilterReturn = ctypes.int; // enum
this.GDK_FILTER_CONTINUE = 0;
this.GDK_FILTER_TRANSLATE = 1;
diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm
index daa0ea1..a8fd670 100644
--- a/src/modules/linux/FiretrayChatStatusIcon.jsm
+++ b/src/modules/linux/FiretrayChatStatusIcon.jsm
@@ -91,7 +91,7 @@ firetray.ChatStatusIcon = {
* EXPERIMENTAL fancy blinking.
* TODO: how to wait for last fade in to restore themedIconNameCurrent
*/
- crossFade: function() {
+ startCrossFading: function() {
/* borrowed from mozmill utils.js*/
function sleep(milliseconds) {
@@ -176,6 +176,11 @@ firetray.ChatStatusIcon = {
});
},
+ stopCrossFading: function() {
+ this.timers['cross-fade'].cancel();
+ this.setIconImage(firetray.ChatStatusIcon.themedIconNameCurrent);
+ },
+
startIconBlinking: function() { // gtk_status_icon_set_blinking() deprecated
this.on = true;
firetray.ChatStatusIcon.timers['blink'] = firetray.Utils.timer(
@@ -236,6 +241,6 @@ firetray.ChatStatusIcon = {
firetray.Chat.stopGetAttentionMaybe(xid);
}
- // FIXME: TODO: onclick/activate -> chatHandler.showCurrentConversation()
+ // TODO: onclick/activate -> chatHandler.showCurrentConversation()
}; // firetray.ChatStatusIcon
diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm
index 87d9ea9..faa3ba7 100644
--- a/src/modules/linux/FiretrayStatusIcon.jsm
+++ b/src/modules/linux/FiretrayStatusIcon.jsm
@@ -328,7 +328,7 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
gobject.g_object_unref(buf);
// merge the rendered text on top
- gdk.gdk_pixbuf_composite(bufAlpha,dest,0,0,w,h,0,0,1,1,gdk.GDK_INTERP_NEAREST,255);
+ gdk.gdk_pixbuf_composite(bufAlpha,dest,0,0,w,h,0,0,1,1,gdk.GDK_INTERP_BILINEAR,255);
gobject.g_object_unref(bufAlpha);
gtk.gtk_status_icon_set_from_pixbuf(firetray.StatusIcon.trayIcon, dest);
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index 8909af0..ba9a643 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -607,7 +607,7 @@ firetray.Window = {
if (visibilityRate < 1)
firetray.Handler.showAllWindows();
- for(var key in firetray.Handler.windows);
+ for(var key in firetray.Handler.windows); // FIXME: this is not the proper way for finding the last registered window !
firetray.Window.activate(key);
}
--
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