[Pkg-mozext-commits] [firetray] 188/399: * option to include subfolders (notably needed for new messages count) * preference UI fixing

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:40 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 354abdf32c739cc446e9d0301c6492ab601e1eb5
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sun Mar 4 22:19:35 2012 +0100

    * option to include subfolders (notably needed for new messages count)
    * preference UI fixing
---
 src/chrome/content/options.js       |   49 +++++++++++++++++------------------
 src/chrome/content/options.xul      |   13 +++++++---
 src/chrome/locale/en-US/options.dtd |    4 ++-
 src/defaults/preferences/prefs.js   |    1 +
 src/modules/FiretrayHandler.jsm     |    1 +
 src/modules/FiretrayMessaging.jsm   |   20 +++++++++++---
 6 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 862ba55..fc195cd 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -56,13 +56,21 @@ var firetrayUIOptions = {
     targetNode.hidden = hiddenval;
   },
 
-  disableGroup: function(group, disableval) {
+  disableChildren: function(group, disableval) {
     try {
       for (let i=0, len=group.childNodes.length; i<len ; ++i)
         group.childNodes[i].disabled = disableval;
     } catch(e) {}
   },
 
+  disableElementsRecursive: function(group, disableval) {
+    let descendants = firetray.Utils.XPath(group, 'descendant::*');
+    try {
+      for (let i=0, len=descendants.length; i<len ; ++i)
+        descendants[i].disabled = disableval;
+    } catch(e) {}
+  },
+
   updateWindowAndIconOptions: function() {
     let hides_on_close    = document.getElementById("ui_hides_on_close").checked;
     let hides_on_minimize = document.getElementById("ui_hides_on_minimize").checked;
@@ -73,14 +81,14 @@ var firetrayUIOptions = {
 
   updateScrollOptions: function() {
     let scroll_hides = document.getElementById("ui_scroll_hides").checked;
-    this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
+    this.disableChildren(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
   },
 
   initMailControls: function() {
     this.populateExcludedFoldersList();
     this.populateTreeAccountsOrServerTypes();
-    this.initNotificationSettings();
     this.initMessageCountSettings();
+    this.initNotificationSettings();
   },
 
   initNotificationSettings: function() {
@@ -111,7 +119,7 @@ var firetrayUIOptions = {
     let radioMessageCountType = document.getElementById("ui_message_count_type");
     let prefMsgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
     radioMessageCountType.selectedIndex = this.radioGetIndexByValue(radioMessageCountType, prefMsgCountType);
-    this.disableMessageCountMaybe(prefMsgCountType);
+    // this.disableMessageCountMaybe(prefMsgCountType); // done in toggleNotifications()
   },
 
   radioGetIndexByValue: function(radio, value) {
@@ -121,6 +129,7 @@ var firetrayUIOptions = {
   },
 
   updateNotificationSettings: function() {
+    LOG("updateNotificationSettings");
     let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
     let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
     firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
@@ -137,39 +146,29 @@ var firetrayUIOptions = {
 
   disableNotificationMaybe: function(notificationSetting) {
     let iconTextColor = document.getElementById("icon_text_color");
-    this.disableGroup(iconTextColor,
+    this.disableChildren(iconTextColor,
                       (notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
 
     let customIconGroup = document.getElementById("custom_mail_icon");
-    this.disableGroup(customIconGroup,
+    this.disableChildren(customIconGroup,
                       (notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
   },
 
   disableMessageCountMaybe: function(msgCountType) {
     LOG("disableMessageCountMaybe: "+msgCountType);
-    let doDisable = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
+    let msgCountTypeIsNewMessages = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
 
-    let radioNotificationUnreadCount = document.getElementById("ui_radio_mail_notification_unread_count");
-    radioNotificationUnreadCount.disabled = doDisable;
+    let notificationUnreadCount = document.getElementById("ui_mail_notification_unread_count");
+    this.disableElementsRecursive(notificationUnreadCount, msgCountTypeIsNewMessages);
 
-    let iconTextColor = document.getElementById("icon_text_color");
-    this.disableGroup(iconTextColor, doDisable);
-
-    if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
-      let radioNotificationNewmailIcon = document.getElementById("ui_radio_mail_notification_newmail_icon");
-      this.simulateClick(radioNotificationNewmailIcon);
+    let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
+    let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
+    if (msgCountTypeIsNewMessages && (mailNotificationType === FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT)) {
+      radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
+      firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
     }
   },
 
-  simulateClick: function(target) {
-    var evt = document.createEvent("MouseEvents");
-    evt.initMouseEvent("click", true, true, window,
-                       0, 0, 0, 0, 0, false, false, false, false, 0, null);
-    var canceled = !target.dispatchEvent(evt);
-    if(canceled)
-      ERROR("could not fire click on "+target);
-  },
-
   toggleNotifications: function(enabled) {
     if (enabled) {
       document.getElementById("broadcaster-notification-disabled")
@@ -304,7 +303,7 @@ var firetrayUIOptions = {
       }
 
     } else if (event.attrName == "label") { // text
-      // TODO: move row to new rank
+      WARN("NOT IMPLEMENTED YET: move row to new rank"); // TODO
     }
 
     this._userChangeValueTree(event);
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 6fe63a3..5725e46 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -30,6 +30,7 @@
       <preference id="pref_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
       <preference id="pref_mail_notification_enabled" name="extensions.firetray.mail_notification_enabled" type="bool" />
       <preference id="pref_message_count_type" name="extensions.firetray.message_count_type" type="int" />
+      <preference id="pref_folder_count_recursive" name="extensions.firetray.folder_count_recursive" type="bool" />
       <preference id="pref_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
       <preference id="pref_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
     </preferences>
@@ -116,7 +117,7 @@
             </caption>
 
             <radiogroup id="ui_radiogroup_mail_notification">
-              <hbox>
+              <hbox id="ui_mail_notification_unread_count">
                 <radio id="ui_radio_mail_notification_unread_count" label="&mail_notification_unread_count.label;"
                        accesskey="&mail_notification_unread_count.accesskey;"
                        oncommand="firetrayUIOptions.updateNotificationSettings()"
@@ -137,7 +138,7 @@
               <hbox>
                 <radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;"
                        accesskey="&mail_notification_custom_mail_icon.accesskey;"
-                       oncommand="firetrayUIOptions.updateNotificationSettings()" 
+                       oncommand="firetrayUIOptions.updateNotificationSettings()"
                        observes="broadcaster-notification-disabled" />
                 <hbox id="custom_mail_icon" align="center" flex="1" >
                   <textbox id="custom_mail_icon_filename" preference="pref_custom_mail_icon"
@@ -152,6 +153,12 @@
 
           </groupbox>
 
+          <checkbox id="ui_folder_count_recursive"
+                    label="&folder_count_recursive.label;"
+                    accesskey="&folder_count_recursive.accesskey;"
+                    preference="pref_folder_count_recursive"
+                    observes="broadcaster-notification-disabled"/>
+
           <!-- NOTE: groupbox and caption don't have a 'disabled' attribute !! -->
           <groupbox id="unread_count_folder_exceptions" flex="1">
             <!-- label extracted from caption so we can disable it -->
@@ -204,7 +211,7 @@
 
           </vbox>
         </tabpanel>
-        
+
       </tabpanels>
     </tabbox>
 
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index 681d826..02cb828 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -36,6 +36,8 @@
 <!ENTITY mail_notification_enabled.accesskey "a">
 <!ENTITY mail_notification_type.label "Mail notification type">
 <!ENTITY mail_notification_type.tooltip "aka. Biff">
+<!ENTITY folder_count_recursive.label "Include subfolders">
+<!ENTITY folder_count_recursive.accesskey "f">
 <!ENTITY mail_notification_unread_count.label "display new message count">
 <!ENTITY mail_notification_unread_count.accesskey "U">
 <!ENTITY mail_notification_newmail_icon.label "display newmail icon">
@@ -49,7 +51,7 @@
 <!ENTITY message_count_type "message count type :">
 <!ENTITY message_count_type_unread "unread messages">
 <!ENTITY message_count_type_new "new messages">
-<!ENTITY message_count_type_new.tooltip "new messages since a folder was last visited">
+<!ENTITY message_count_type_new.tooltip "new messages since a folder was last visited.">
 
 <!ENTITY unread_count_folder_exceptions.label "Included special folders">
 <!ENTITY unread_count_folder_exceptions.tooltip "Included special folders for unread message count">
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index e24b252..2a5ea2f 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -18,6 +18,7 @@ pref("extensions.firetray.scroll_hides", true);
 pref("extensions.firetray.scroll_mode", "down_hides");
 
 pref("extensions.firetray.message_count_type", 0);
+pref("extensions.firetray.folder_count_recursive", true);
 pref("extensions.firetray.mail_notification_enabled", true);
 pref("extensions.firetray.mail_notification_type", 0);
 pref("extensions.firetray.icon_text_color", "#000000");
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 9dfc4f6..aae3ebb 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -373,6 +373,7 @@ firetray.PrefListener = new PrefListener(
       firetray.Handler.showHideIcon();
       break;
     case 'message_count_type':
+    case 'folder_count_recursive':
       firetray.Messaging.updateMsgCount();
       break;
     default:
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 85ed2f6..0cef528 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -85,7 +85,6 @@ firetray.Messaging = {
     updateMsgCount: function(item, property, oldValue, newValue) {
       let excludedFoldersFlags = firetray.Utils.prefService.getIntPref("excluded_folders_flags");
       let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
-      LOG("msgCountType="+msgCountType);
 
       if (!(item.flags & excludedFoldersFlags)) {
         let prop = property.toString();
@@ -180,11 +179,11 @@ firetray.Messaging = {
 
         let rootFolder = accountServer.rootFolder; // nsIMsgFolder
         if (rootFolder.hasSubFolders) {
-          let subFolders = rootFolder.subFolders; // nsIMsgFolder
+          let subFolders = rootFolder.subFolders;
           while(subFolders.hasMoreElements()) {
             let folder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
             if (!(folder.flags & excludedFoldersFlags)) {
-              newMsgCount = folderCountFunction(folder, newMsgCount);
+              newMsgCount = this.folderCount(folderCountFunction,folder, newMsgCount);
             }
           }
         }
@@ -196,9 +195,22 @@ firetray.Messaging = {
     return newMsgCount;
   },
 
+  folderCount: function(folderCountFunction, folder, newMsgCount) {
+    if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
+      LOG("hasSubFolders");
+      let subFolders = folder.subFolders;
+      while(subFolders.hasMoreElements()) {
+        let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
+        newMsgCount = this.folderCount(folderCountFunction, subFolder, newMsgCount);
+      }
+    }
+    newMsgCount = folderCountFunction(folder, newMsgCount);
+    return newMsgCount;
+  },
+
   unreadMsgCountIterate: function(folder, accumulator) {
     let folderCountFunctionName = 'getNumUnread';
-    let folderUnreadMsgCount = folder[folderCountFunctionName](true); // includes subfolders
+    let folderUnreadMsgCount = folder[folderCountFunctionName](false); // do not include subfolders
     LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
     return accumulator + folderUnreadMsgCount;
   },

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