[Pkg-mozext-commits] [firetray] 223/399: * fix pref UI: disable themed icon names if not selected * refactoring

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:47 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 1f480af971b98b0eaac53d8dc8fdedead073abc0
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Mon Apr 9 01:01:01 2012 +0200

    * fix pref UI: disable themed icon names if not selected
    * refactoring
---
 src/chrome/content/options.js            |   50 +++++++++++++++++++++++-------
 src/chrome/content/options.xul           |   48 +++++++++++++++-------------
 src/modules/FiretrayHandler.jsm          |    4 +--
 src/modules/FiretrayMessaging.jsm        |    4 +--
 src/modules/linux/FiretrayStatusIcon.jsm |   22 +++++--------
 5 files changed, 77 insertions(+), 51 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 0618d63..c9c73f0 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -67,6 +67,15 @@ var firetrayUIOptions = {
         children[i].disabled = disableval;
     } catch(e) {}
   },
+  disableNChildren: function(group, nth, disableval) {
+    try {
+      let children = group.childNodes;
+      if (nth>children.length) throw new RangeError();
+      for (let i=0; i<nth ; ++i) {
+        children[i].disabled = disableval;
+      }
+    } catch(e) {}
+  },
 
   disableElementsRecursive: function(group, disableval) {
     let descendants = firetray.Utils.XPath(group, 'descendant::*');
@@ -144,16 +153,23 @@ var firetrayUIOptions = {
   },
 
   disableIconTypeMaybe: function(appIconType) {
-    let customIconGroup = document.getElementById("custom_app_icon");
-    this.disableChildren(customIconGroup,
+    let appIconCustomGroup = document.getElementById("app_icon_custom");
+    this.disableChildren(appIconCustomGroup,
       (appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
+
+    let appIconDefaultGroup = document.getElementById("app_icon_default");
+    this.disableNChildren(appIconDefaultGroup, 2,
+      (appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_THEMED));
   },
 
   initMailControls: function() {
     this.populateExcludedFoldersList();
     this.populateTreeAccountsOrServerTypes();
+
     this.initMessageCountSettings();
     this.initNotificationSettings();
+
+    this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
   },
 
   initNotificationSettings: function() {
@@ -170,9 +186,7 @@ var firetrayUIOptions = {
     let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
     let prefMailNotificationType = firetray.Utils.prefService.getIntPref("mail_notification_type");
     radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, prefMailNotificationType);
-    this.disableNotificationMaybe(prefMailNotificationType);
-
-    this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
+    // this.disableNotificationMaybe(prefMailNotificationType); // done in toggleNotifications()
   },
 
   initMessageCountSettings: function() {
@@ -210,13 +224,19 @@ var firetrayUIOptions = {
   },
 
   disableNotificationMaybe: function(notificationSetting) {
+    F.LOG("disableNotificationMaybe: "+notificationSetting);
+
     let iconTextColor = document.getElementById("icon_text_color");
     this.disableChildren(iconTextColor,
-                      (notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
+      (notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
+
+    let newMailIconNames = document.getElementById("newmail_icon_names");
+    this.disableNChildren(newMailIconNames, 2,
+      (notificationSetting !== FIRETRAY_NOTIFICATION_NEWMAIL_ICON));
 
     let customIconGroup = document.getElementById("custom_mail_icon");
     this.disableChildren(customIconGroup,
-                      (notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
+      (notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
   },
 
   disableMessageCountMaybe: function(msgCountType) {
@@ -230,6 +250,8 @@ var firetrayUIOptions = {
     let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
     if (msgCountTypeIsNewMessages && (mailNotificationType === FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT)) {
       radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
+      let newMailIconNames = document.getElementById("newmail_icon_names");
+      this.disableNChildren(newMailIconNames, 2, false);
       firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
     }
   },
@@ -238,17 +260,21 @@ var firetrayUIOptions = {
     if (enabled) {
       document.getElementById("broadcaster-notification-disabled")
         .removeAttribute("disabled"); // UI update (enables!)
-      firetray.Messaging.init();
+      if (!firetray.Messaging.initialized) firetray.Messaging.init();
       firetray.Messaging.updateMsgCount();
+
+      let prefMailNotificationType = firetray.Utils.prefService.getIntPref("mail_notification_type");
+      this.disableNotificationMaybe(prefMailNotificationType);
+
+      let radioMessageCountType = document.getElementById("ui_message_count_type");
+      let messageCountType = +radioMessageCountType.getItemAtIndex(radioMessageCountType.selectedIndex).value;
+      this.disableMessageCountMaybe(messageCountType);
+
     } else {
       document.getElementById("broadcaster-notification-disabled")
         .setAttribute("disabled", "true"); // UI update
       firetray.Messaging.shutdown();
     }
-
-    let radioMessageCountType = document.getElementById("ui_message_count_type");
-    let messageCountType = +radioMessageCountType.getItemAtIndex(radioMessageCountType.selectedIndex).value;
-    this.disableMessageCountMaybe(messageCountType);
   },
 
   chooseAppIconFile: function() {
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 5c86e66..8a2bde2 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -84,21 +84,23 @@
               <vbox align="left" flex="1">
                 <label class="header">&app_icon_type;</label>
 
-                <hbox>
+                <hbox id="ui_app_icon_type_default_group">
                   <radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;"
                          accesskey="&app_icon_themed.accesskey;" tooltiptext="&icon_themed.tooltip;" />
-                  <textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
-                           onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
-                  <textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
-                           onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
-                  <textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
-                           onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
-                           disabled="true"/>
+                  <hbox id="app_icon_default" align="center" flex="1" >
+                    <textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
+                             onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
+                    <textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
+                             onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
+                    <textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
+                             onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
+                             disabled="true"/>
+                  </hbox>
                 </hbox>
                 <hbox id="ui_app_icon_type_custom_group">
                   <radio id="ui_app_icon_type_custom" label="&app_icon_custom.label;"
                          accesskey="&app_icon_custom.accesskey;" />
-                  <hbox id="custom_app_icon" align="center" flex="1" >
+                  <hbox id="app_icon_custom" align="center" flex="1" >
                     <textbox id="app_icon_custom_filename" preference="pref_app_icon_filename" flex="1" />
                     <button id="app_icon_custom_select" label="&choose;"
                             accesskey="&choose.accesskey;"
@@ -176,18 +178,20 @@
                        oncommand="firetrayUIOptions.updateNotificationSettings()"
                        observes="broadcaster-notification-disabled"
                        tooltiptext="&icon_themed.tooltip;" />
-                <textbox id="radio_mail_notification_newmail_icon_name1" size="12"
-                         placeholder="&app_icon_themed_name;" flex="1"
-                         observes="broadcaster-notification-disabled"
-                         onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
-                <textbox id="radio_mail_notification_newmail_icon_name2" size="12"
-                         placeholder="&app_icon_themed_name;" flex="1"
-                         observes="broadcaster-notification-disabled"
-                         onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
-                <textbox id="radio_mail_notification_newmail_icon_name3" size="12"
-                         placeholder="&app_icon_themed_name;" flex="1"
-                         onchange="firetrayUIOptions.updateNewMailIconNames(this);"
-                         disabled="true"/>
+                <hbox id="newmail_icon_names">
+                  <textbox id="radio_mail_notification_newmail_icon_name1" size="12"
+                           placeholder="&app_icon_themed_name;" flex="1"
+                           observes="broadcaster-notification-disabled"
+                           onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
+                  <textbox id="radio_mail_notification_newmail_icon_name2" size="12"
+                           placeholder="&app_icon_themed_name;" flex="1"
+                           observes="broadcaster-notification-disabled"
+                           onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
+                  <textbox id="radio_mail_notification_newmail_icon_name3" size="12"
+                           placeholder="&app_icon_themed_name;" flex="1"
+                           onchange="firetrayUIOptions.updateNewMailIconNames(this);"
+                           disabled="true"/>
+                </hbox>
               </hbox>
               <hbox>
                 <radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;"
@@ -196,9 +200,11 @@
                        observes="broadcaster-notification-disabled" />
                 <hbox id="custom_mail_icon" align="center" flex="1" >
                   <textbox id="custom_mail_icon_filename" preference="pref_custom_mail_icon"
+                           observes="broadcaster-notification-disabled"
                            onchange="firetray.Messaging.updateMsgCount();" flex="1" />
                   <button id="custom_mail_icon_select" label="&choose;"
                           accesskey="&choose.accesskey;"
+                          observes="broadcaster-notification-disabled"
                           oncommand="firetrayUIOptions.chooseMailIconFile()" />
                 </hbox>
               </hbox>
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 6f702a8..04e76f3 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -171,9 +171,9 @@ firetray.Handler = {
   },
 
   // these get overridden in OS-specific Icon/Window handlers
-  setIconImage: function(icon) {},
-  setIconImageFromFile: function(filename) {},
   setIconImageDefault: function() {},
+  setIconImageNewMail: function() {},
+  setIconImageFromFile: function(filename) {},
   setIconText: function(text, color) {},
   setIconTooltip: function(localizedMessage) {},
   setIconTooltipDefault: function() {},
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index d4741ff..a4687db 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -28,7 +28,7 @@ firetray.Messaging = {
 
   init: function() {
     if (this.initialized) {
-      F.LOG("Messaging already initialized");
+      F.WARN("Messaging already initialized");
       return;
     }
     F.LOG("Enabling Messaging");
@@ -179,7 +179,7 @@ firetray.Messaging = {
         firetray.Handler.setIconText(newMsgCount.toString(), prefIconTextColor);
         break;
       case FIRETRAY_NOTIFICATION_NEWMAIL_ICON:
-        firetray.Handler.setIconImage(firetray.StatusIcon.themedIconNewMail);
+        firetray.Handler.setIconImageNewMail();
         break;
       case FIRETRAY_NOTIFICATION_CUSTOM_ICON:
         let prefCustomIconPath = firetray.Utils.prefService.getCharPref("custom_mail_icon");
diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm
index c8be041..660c8a5 100644
--- a/src/modules/linux/FiretrayStatusIcon.jsm
+++ b/src/modules/linux/FiretrayStatusIcon.jsm
@@ -181,13 +181,6 @@ firetray.StatusIcon = {
                                         filename);
   },
 
-  setIconImageFromName: function(iconName) {
-    if (!firetray.StatusIcon.trayIcon)
-      F.ERROR("Icon missing");
-    F.LOG(iconName);
-    gtk.gtk_status_icon_set_from_icon_name(firetray.StatusIcon.trayIcon, iconName);
-  },
-
   setIconImageFromGIcon: function(gicon) {
     if (!firetray.StatusIcon.trayIcon || !gicon)
       F.ERROR("Icon missing");
@@ -197,23 +190,24 @@ firetray.StatusIcon = {
 
 }; // firetray.StatusIcon
 
-
-firetray.Handler.setIconImage = firetray.StatusIcon.setIconImageFromGIcon;
-
-firetray.Handler.setIconImageFromFile = firetray.StatusIcon.setIconImageFromFile;
-
 firetray.Handler.setIconImageDefault = function() {
   if (!firetray.StatusIcon.themedIconApp)
     throw "Default application themed icon not set";
   let appIconType = firetray.Utils.prefService.getIntPref("app_icon_type");
   if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_THEMED)
-    firetray.Handler.setIconImage(firetray.StatusIcon.themedIconApp);
+    firetray.StatusIcon.setIconImageFromGIcon(firetray.StatusIcon.themedIconApp);
   else if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM) {
     let appIconFilename = firetray.Utils.prefService.getCharPref("app_icon_filename");
-    firetray.Handler.setIconImageFromFile(appIconFilename);
+    firetray.StatusIcon.setIconImageFromFile(appIconFilename);
   }
 };
 
+firetray.Handler.setIconImageNewMail = function() {
+  firetray.StatusIcon.setIconImageFromGIcon(firetray.StatusIcon.themedIconNewMail);
+};
+
+firetray.Handler.setIconImageFromFile = firetray.StatusIcon.setIconImageFromFile;
+
 // GTK bug: Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
 firetray.Handler.setIconTooltip = function(toolTipStr) {
   if (!firetray.StatusIcon.trayIcon)

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