[Pkg-mozext-commits] [firetray] 85/399: * options: make icon text color a preference * options: possibility to disable icon notification

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:19 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 3c881dbb9d32eb9ac08b02d2952a067ee1291710
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sun Nov 6 17:42:43 2011 +0100

    * options: make icon text color a preference
    * options: possibility to disable icon notification
---
 src/chrome/content/options.js       |   24 ++++++++++++++++++------
 src/chrome/content/options.xul      |    7 +++++++
 src/chrome/content/overlay.js       |    2 +-
 src/chrome/locale/en-US/options.dtd |    2 ++
 src/defaults/preferences/prefs.js   |    1 +
 src/modules/FiretrayHandler.jsm     |    7 +++----
 src/modules/FiretrayMessaging.jsm   |    9 ++++++---
 src/modules/commons.js              |   12 +++++++++---
 8 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 2090257..9c4bee2 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -14,7 +14,6 @@ if ("undefined" == typeof(firetray)) {
   var firetray = {};
 };
 
-const NOTIFICATION_CUSTOM_ICON = 3;
 const TREEROW_ACCOUNT_OR_SERVER_TYPE_NAME     = 0;
 const TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED = 1;
 const TREEROW_ACCOUNT_OR_SERVER_TYPE_ORDER    = 2;
@@ -75,18 +74,31 @@ firetray.UIOptions = {
     let radioMailNotify = document.getElementById("radiogroup_mail_notification");
     let prefMailNotification = firetray.Utils.prefService.getIntPref("mail_notification");
     radioMailNotify.selectedIndex = prefMailNotification;
-    let customIconGroup = document.getElementById("custom_mail_icon");
-    this.disableGroup(customIconGroup,
-                      (prefMailNotification !== NOTIFICATION_CUSTOM_ICON));
+    this._disableNotificationMaybe(radioMailNotify.selectedIndex);
   },
 
   updateNotificationSettings: function() {
     let radioMailNotify = document.getElementById("radiogroup_mail_notification");
+    let notificationSetting = radioMailNotify.selectedIndex;
     let prefMailNotification =
-      firetray.Utils.prefService.setIntPref("mail_notification", radioMailNotify.selectedIndex);
+      firetray.Utils.prefService.setIntPref("mail_notification", notificationSetting);
+    this._disableNotificationMaybe(notificationSetting);
+
+    if (notificationSetting === NOTIFICATION_DISABLED)
+      firetray.Messaging.disable();
+    else
+      firetray.Messaging.enable();
+
+  },
+
+  _disableNotificationMaybe: function(notificationSetting) {
+    let iconTextColor = document.getElementById("icon_text_color");
+    this.disableGroup(iconTextColor,
+                      (notificationSetting !== NOTIFICATION_UNREAD_MESSAGE_COUNT));
+
     let customIconGroup = document.getElementById("custom_mail_icon");
     this.disableGroup(customIconGroup,
-                      (radioMailNotify.selectedIndex !== NOTIFICATION_CUSTOM_ICON));
+                      (notificationSetting !== NOTIFICATION_CUSTOM_ICON));
   },
 
   chooseMailIconFile: function() {
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index e1b17a2..71c42ec 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -13,6 +13,7 @@
     <preferences>
       <preference id="pref_bool_hides_on_close" name="extensions.firetray.hides_on_close" type="bool"/>
       <preference id="pref_bool_hides_on_minimize" name="extensions.firetray.hides_on_minimize" type="bool"/>
+      <preference id="pref_string_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
       <preference id="pref_string_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
       <preference id="pref_string_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
     </preferences>
@@ -66,6 +67,12 @@
             </radiogroup>
           </groupbox>
 
+          <hbox id="icon_text_color" align="center">
+            <label value="&icon_text_color;" accesskey="&icon_text_color.accesskey;"/>
+            <colorpicker id="btn_icon_text_color" type="button"
+                         preference="pref_string_icon_text_color" />
+          </hbox>
+
           <hbox id="custom_mail_icon" align="center" flex="1" >
             <textbox id="custom_mail_icon_filename" preference="pref_string_custom_mail_icon"
                      hidden="FALSE" flex="1" />
diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js
index b7c086a..cad2ccd 100644
--- a/src/chrome/content/overlay.js
+++ b/src/chrome/content/overlay.js
@@ -30,7 +30,7 @@ firetray.Main = {
     let init = firetray.Handler.initialized || firetray.Handler.init();
 
     // update unread messages count
-    if (firetray.Handler.inMailApp)
+    if (firetray.Handler.inMailApp && firetray.Messaging.enabled)
       firetray.Messaging.updateUnreadMsgCount();
 
     // prevent window closing.
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index aaad682..c4d3941 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -24,6 +24,8 @@
 <!ENTITY mail_notification_newmail_icon.accesskey "N">
 <!ENTITY mail_notification_custom_mail_icon "display custom icon">
 <!ENTITY mail_notification_custom_mail_icon.accesskey "I">
+<!ENTITY icon_text_color "Icon text color">
+<!ENTITY icon_text_color.accesskey "T">
 <!ENTITY choose "Choose">
 <!ENTITY choose.accesskey "O">
 
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 486acb9..49c0e6f 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -10,6 +10,7 @@ pref("extensions.firetray.hides_on_close", true);
 pref("extensions.firetray.hides_on_minimize", true);
 
 pref("extensions.firetray.mail_notification", 1);
+pref("extensions.firetray.icon_text_color", "#000000");
 pref("extensions.firetray.custom_mail_icon", "");
 // exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts
 pref("extensions.firetray.mail_accounts", '{ "serverTypes": {"pop3":{"order":1,"excluded":false}, "imap":{"order":1,"excluded":false}, "movemail":{"order":2,"excluded":true}, "none":{"order":3,"excluded":false}, "rss":{"order":4,"excluded":true}, "nntp":{"order":5,"excluded":true}}, "excludedAccounts": [] }'); // JSON
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index be30224..6c7954b 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -176,14 +176,13 @@ firetray.Handler = {
       this.inMailApp = true;
       try {
         Cu.import("resource://firetray/FiretrayMessaging.jsm");
-        firetray.Messaging.enable();
+        let prefMailNotification = firetray.Utils.prefService.getIntPref("mail_notification");
+        if (prefMailNotification !== NOTIFICATION_DISABLED)
+          firetray.Messaging.enable();
       } catch (x) {
         ERROR(x);
         return false;
       }
-
-      // init unread messages count
-      firetray.Messaging.updateUnreadMsgCount();
     }
     LOG('inMailApp: '+this.inMailApp);
 
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 052d391..0881734 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -19,7 +19,6 @@ const FLDR_UNINTERESTING =
   Ci.nsMsgFolderFlags.SentMail |
   Ci.nsMsgFolderFlags.Templates |
   Ci.nsMsgFolderFlags.Trash;
-const ICON_TEXT_COLOR = "#00000";
 
 /**
  * firetray namespace.
@@ -31,10 +30,11 @@ if ("undefined" == typeof(firetray)) {
 
 firetray.Messaging = {
   _unreadMsgCount: 0,
+  enabled: false,
 
   enable: function() {
     if (this.enabled) {
-      WARN("Trying to enable more than once");
+      LOG("Messaging already enabled");
       return;
     }
 
@@ -45,6 +45,7 @@ firetray.Messaging = {
                                                mailSessionNotificationFlags);
 
     this.enabled = true;
+    this.updateUnreadMsgCount();
   },
 
   disable: function() {
@@ -52,6 +53,7 @@ firetray.Messaging = {
       return;
 
     MailServices.mailSession.RemoveFolderListener(this);
+    firetray.IconLinux.setImageDefault();
 
     this.enabled = false;
   },
@@ -111,7 +113,8 @@ firetray.Messaging = {
       firetray.IconLinux.setImageDefault();
       firetray.IconLinux.setTooltipDefault();
     } else if (this._unreadMsgCount > 0) {
-      firetray.IconLinux.setText(this._unreadMsgCount.toString(), ICON_TEXT_COLOR);
+      let prefIconTextColor = firetray.Utils.prefService.getCharPref("icon_text_color");
+      firetray.IconLinux.setText(this._unreadMsgCount.toString(), prefIconTextColor);
       let localizedMessage = PluralForm.get(
         this._unreadMsgCount,
         firetray.Utils.strings.GetStringFromName("tooltip.unread_messages"))
diff --git a/src/modules/commons.js b/src/modules/commons.js
index a3505d7..4ff52bf 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -1,9 +1,10 @@
 /* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 var EXPORTED_SYMBOLS =
-  [ "firetray", "Cc", "Ci", "Cu", "LOG", "WARN", "ERROR",
-    "FIREFOX_ID", "THUNDERBIRD_ID", "SEAMONKEY_ID",
-    "XPath", "isArray" ];
+  [ "firetray", "Cc", "Ci", "Cu", "LOG", "WARN", "ERROR", "FIREFOX_ID",
+    "THUNDERBIRD_ID", "SEAMONKEY_ID", "XPath", "isArray",
+    "NOTIFICATION_DISABLED", "NOTIFICATION_UNREAD_MESSAGE_COUNT",
+    "NOTIFICATION_NEWMAIL_ICON", "NOTIFICATION_CUSTOM_ICON" ];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
@@ -18,6 +19,11 @@ const SUNBIRD_ID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
 const SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
 const CHATZILLA_ID = "{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}";
 
+const NOTIFICATION_DISABLED = 0;
+const NOTIFICATION_UNREAD_MESSAGE_COUNT = 1;
+const NOTIFICATION_NEWMAIL_ICON = 2;
+const NOTIFICATION_CUSTOM_ICON = 3;
+
 /**
  * firetray namespace.
  */

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