[Pkg-mozext-commits] [firetray] 319/399: * fix double Messaging init when toggleNotifications() in pref UI * fix multiple pref UI bugs due to obsolete ref to "pane1"

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:06 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 1ec5ccf950a791ae2dcc73c3232a8636ad08fd71
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Tue Sep 11 23:53:07 2012 +0200

    * fix double Messaging init when toggleNotifications() in pref UI
    * fix multiple pref UI bugs due to obsolete ref to "pane1"
---
 src/chrome/content/options.js       |   30 ++++++++++++++++--------------
 src/chrome/locale/en-US/options.dtd |    1 -
 src/modules/commons.js              |    3 ++-
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 312bb8f..8b4a20f 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -287,12 +287,10 @@ var firetrayUIOptions = {
     }
   },
 
-  toggleNotifications: function(enabled) {
+  toggleNotifications: function(enabled) { // Messaging init/shutdown done in PrefListener
     if (enabled) {
       document.getElementById("broadcaster-notification-disabled")
         .removeAttribute("disabled"); // UI update (enables!)
-      if (!firetray.Messaging.initialized) firetray.Messaging.init();
-      firetray.Messaging.updateIcon();
 
       let prefMailNotificationType = firetray.Utils.prefService.getIntPref("mail_notification_type");
       this.disableNotificationMaybe(prefMailNotificationType);
@@ -304,23 +302,20 @@ var firetrayUIOptions = {
     } else {
       document.getElementById("broadcaster-notification-disabled")
         .setAttribute("disabled", "true"); // UI update
-      firetray.Messaging.shutdown();
     }
   },
 
   chooseAppIconFile: function() {
-    var filepath = document.getElementById("app_icon_custom_filename");
-    this._chooseIconFile(filepath);
+    this._chooseIconFile("app_icon_custom_filename");
     firetray.Handler.setIconImageDefault();
   },
 
   chooseMailIconFile: function() {
-    var filepath = document.getElementById("custom_mail_icon_filename");
-    this._chooseIconFile(filepath);
+    this._chooseIconFile("custom_mail_icon_filename");
     firetray.Messaging.updateIcon();
   },
 
-  _chooseIconFile: function(iconFilename) {
+  _chooseIconFile: function(elementId, prefpaneId) {
 	  const nsIFilePicker = Ci.nsIFilePicker;
 	  var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
 	  filePicker.init(window, "Select Icon", nsIFilePicker.modeOpen); // FIXME: i18n
@@ -328,12 +323,20 @@ var firetrayUIOptions = {
 
 	  var rv = filePicker.show();
 	  if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
-		  iconFilename.value = filePicker.file.path;
-		  var prefpane = document.getElementById("pane1");
-		  prefpane.userChangedValue(iconFilename);
+      let filenameElt = document.getElementById(elementId);
+		  filenameElt.value = filePicker.file.path;
+      let prefpane = this.getAncestorPrefpane(filenameElt);
+		  prefpane.userChangedValue(filenameElt);
 	  }
   },
 
+  getAncestorPrefpane: function(elt) {
+    let prefpanes = firetray.Utils.XPath(elt, 'ancestor::xul:prefpane');
+    if (prefpanes.length !== 1)
+      throw new RangeError("not single prefpane found for '"+elt.getAttribute("id")+"'");
+    return prefpanes[0];
+  },
+
   /**
    * NOTE: folder exceptions for unread messages count are *stored* in
    * preferences as excluded, but *shown* as "not included"
@@ -412,7 +415,7 @@ var firetrayUIOptions = {
   _userChangeValueTree: function(event) {
     if (event.attrName == "label") log.debug("label changed!");
     if (event.attrName == "value") log.debug("value changed!");
-    document.getElementById("pane1")
+    document.getElementById("pref-pane-mail")
       .userChangedValue(document.getElementById("ui_tree_mail_accounts"));
 
     firetray.Messaging.updateMsgCountWithCb();
@@ -447,7 +450,6 @@ var firetrayUIOptions = {
   // FIXME: tree not updated if accounts or favorite added/removed
   populateTreeAccountsOrServerTypes: function() {
     let that = this;
-    let prefPane = document.getElementById("pane1");
 
     let mailAccounts = firetray.Utils.getObjPref("mail_accounts");
     let serverTypes = mailAccounts["serverTypes"];
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index 7d5f4b0..dea845b 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -1,6 +1,5 @@
 <!-- if you need multiline/carriage return, use a .properties -->
 <!ENTITY prefwindow.title "FireTray preferences">
-<!ENTITY pane1.title "FireTray preferences">
 
 <!ENTITY NOT_IMPLEMENTED_YET "NOT IMPLEMENTED YET">
 
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 33281e0..cf95310 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -200,7 +200,7 @@ firetray.Utils = {
       return result.booleanValue;
     case XPathResult.STRING_TYPE:
       return result.stringValue;
-    } // else XPathResult.UNORDERED_NODE_ITERATOR_TYPE
+    } // else XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
 
     var list = [];
     try {
@@ -221,6 +221,7 @@ firetray.Utils = {
       log.error(x);
     }
 
+    log.debug("len="+list.length);
     return list;
   },
 

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