[Pkg-mozext-commits] [firetray] 212/399: * refactoring * fix consistence in preference UI (filepickers' disabling)

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:45 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 e19930b654a9bae83144eecb53e2a45321d84112
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Thu Mar 15 18:24:38 2012 +0100

    * refactoring
    * fix consistence in preference UI (filepickers' disabling)
    
    We still need to find out why the order in g_themed_icon_new_from_names is not
    respected.
---
 src/chrome/content/options.js            |   23 ++++++++++-----
 src/chrome/content/options.xul           |   20 +++++++------
 src/chrome/locale/en-US/options.dtd      |    2 +-
 src/modules/ctypes/linux/gobject.jsm     |    5 ++--
 src/modules/linux/FiretrayStatusIcon.jsm |   46 +++++++++++++++++++++++-------
 5 files changed, 68 insertions(+), 28 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 8ba26a2..bd4c21c 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -31,7 +31,8 @@ var firetrayUIOptions = {
     this.updateScrollOptions();
     this.initAppIconType();
     this.initAppIconNames();
-    this.initNewMailIconNames();
+    if (firetray.Handler.inMailApp)
+      this.initNewMailIconNames();
   },
 
   onQuit: function(e) {
@@ -85,17 +86,20 @@ var firetrayUIOptions = {
       FIRETRAY_APPLICATION_ICON_TYPE_THEMED;
     document.getElementById("ui_app_icon_type_custom").value =
       FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM;
-    document.getElementById("ui_app_icon_type").selectedIndex =
-      firetray.Utils.prefService.getIntPref("app_icon_type");
+
+    let prefAppIconType = firetray.Utils.prefService.getIntPref("app_icon_type");
+    document.getElementById("ui_app_icon_type").selectedIndex = prefAppIconType;
+
+    this.disableIconTypeMaybe(prefAppIconType);
   },
 
   initAppIconNames: function() {
     this.initIconNames(firetray.StatusIcon.prefAppIconNames,
-      "app_icon_type_themed_name", firetray.Handler.appNameOriginal.toLowerCase());
+      "app_icon_type_themed_name", firetray.StatusIcon.defaultAppIconName);
   },
   initNewMailIconNames: function() {
     this.initIconNames("new_mail_icon_names",
-      "radio_mail_notification_newmail_icon_name", "mail-unread");
+      "radio_mail_notification_newmail_icon_name", firetray.StatusIcon.defaultNewMailIconName);
   },
 
   initIconNames: function(prefIconNames, uiIconNameId, defaultIconName) {
@@ -125,13 +129,18 @@ var firetrayUIOptions = {
       let textbox = document.getElementById(uiIconNameId+i);
       let val = textbox.value.trim();
       LOG("val="+val);
-      if (val)
-        iconNames.push(val);
+      if (val) iconNames.push(val);
     }
     LOG("iconNames="+iconNames);
     firetray.Utils.setArrayPref(prefIconNames, iconNames);
   },
 
+  disableIconTypeMaybe: function(appIconType) {
+    let customIconGroup = document.getElementById("custom_app_icon");
+    this.disableGroup(customIconGroup,
+                      (appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
+  },
+
   initMailControls: function() {
     this.populateExcludedFoldersList();
     this.populateTreeAccountsOrServerTypes();
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index da14b1c..d40eac4 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -74,13 +74,14 @@
         <tabpanel id="icon_tabpanel" flex="1">
           <vbox pack="start" align="left" flex="1">
 
-            <radiogroup id="ui_app_icon_type" preference="pref_app_icon_type">
+            <radiogroup id="ui_app_icon_type" preference="pref_app_icon_type"
+                        oncommand="firetrayUIOptions.disableIconTypeMaybe(this.selectedIndex);">
               <vbox align="left" flex="1">
                 <label class="header">&app_icon_type;</label>
 
                 <hbox>
                   <radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;"
-                         accesskey="&app_icon_themed.accesskey;" tooltiptext="&app_icon_themed.tooltip;" />
+                         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;"
@@ -89,13 +90,15 @@
                            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;" />
-                  <textbox id="app_icon_custom_filename" preference="pref_app_icon_filename" flex="1" />
-                  <button id="app_icon_custom_select" label="&choose;"
-                          accesskey="&choose.accesskey;"
-                          oncommand="firetrayUIOptions.chooseAppIconFile()" />
+                  <hbox id="custom_app_icon" 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;"
+                            oncommand="firetrayUIOptions.chooseAppIconFile()" />
+                  </hbox>
                 </hbox>
 
               </vbox>
@@ -166,7 +169,8 @@
                 <radio id="ui_radio_mail_notification_newmail_icon" label="&mail_notification_newmail_icon.label;"
                        accesskey="&mail_notification_newmail_icon.accesskey;"
                        oncommand="firetrayUIOptions.updateNotificationSettings()"
-                       observes="broadcaster-notification-disabled" />
+                       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"
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index b66c15d..00257ef 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -27,7 +27,7 @@
 <!ENTITY app_icon_themed.label "Default themed">
 <!ENTITY app_icon_themed.accesskey "D">
 <!ENTITY app_icon_themed_name "icon-name">
-<!ENTITY app_icon_themed.tooltip "Icon names provided by graphical environment">
+<!ENTITY icon_themed.tooltip "Icon names provided by graphical environment">
 <!ENTITY app_icon_custom.label "Custom">
 <!ENTITY app_icon_custom.accesskey "u">
 
diff --git a/src/modules/ctypes/linux/gobject.jsm b/src/modules/ctypes/linux/gobject.jsm
index 82d82f1..eb773be 100644
--- a/src/modules/ctypes/linux/gobject.jsm
+++ b/src/modules/ctypes/linux/gobject.jsm
@@ -6,7 +6,7 @@
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
- * 
+ *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
@@ -34,7 +34,7 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
- * 
+ *
  * ***** END LICENSE BLOCK ***** */
 
 var EXPORTED_SYMBOLS = [ "gobject", "glib" ];
@@ -140,6 +140,7 @@ function gobject_defines(lib) {
     return this.g_signal_connect_data(instance, detailed_signal, handler, data, null, this.G_CONNECT_AFTER);
   };
 
+  lib.lazy_bind("g_free", ctypes.void_t, this.gpointer);
   lib.lazy_bind("g_object_unref", ctypes.void_t, this.gpointer);
   lib.lazy_bind("g_list_free", ctypes.void_t, this.GList.ptr);
   lib.lazy_bind("g_list_length", this.guint, this.GList.ptr);
diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm
index 78e135e..868490d 100644
--- a/src/modules/linux/FiretrayStatusIcon.jsm
+++ b/src/modules/linux/FiretrayStatusIcon.jsm
@@ -31,8 +31,13 @@ firetray.StatusIcon = {
   themedIconApp: null,
   themedIconNewMail: null,
   prefAppIconNames: null,
+  prefNewMailIconNames: null,
+  defaultAppIconName: null,
+  defaultNewMailIconName: null,
 
   init: function() {
+    this.defineIconNames();
+
     try {
       this.GTK_THEME_ICON_PATH = firetray.Utils.chromeToPath("chrome://firetray/skin/linux/icons");
       LOG(this.GTK_THEME_ICON_PATH);
@@ -68,23 +73,44 @@ firetray.StatusIcon = {
     this.initialized = false;
   },
 
+  defineIconNames: function() {
+    this.prefAppIconNames = (function() {
+      if (firetray.Handler.inMailApp) {
+        return "app_mail_icon_names";
+      } else if (firetray.Handler.inBrowserApp) {
+        return "app_browser_icon_names";
+      } else {
+        return "app_default_icon_names";
+      }
+    })();
+    this.defaultAppIconName = firetray.Handler.appNameOriginal.toLowerCase();
+
+    this.prefNewMailIconNames = "new_mail_icon_names";
+    this.defaultNewMailIconName = "mail-unread";
+  },
+
   loadThemedIcons: function() {
     if (firetray.Handler.inMailApp) {
-      let newMailIconNames = firetray.Utils.getArrayPref("new_mail_icon_names");
-      newMailIconNames.push("mail-unread"); // SMELL
+      let newMailIconNames = this.getNewMailIconNames();
+      if (this.themedIconNewMail) gobject.g_object_unref(this.themedIconNewMail);
       this.themedIconNewMail = this.initThemedIcon(newMailIconNames);
-
-      this.prefAppIconNames = "app_mail_icon_names";
-    } else if (firetray.Handler.inBrowserApp) {
-      this.prefAppIconNames = "app_browser_icon_names";
-    } else {
-      this.prefAppIconNames = "app_default_icon_names";
     }
-    let appIconNames = firetray.Utils.getArrayPref(this.prefAppIconNames);
-    appIconNames.push(firetray.Handler.appNameOriginal.toLowerCase());
+    let appIconNames = this.getAppIconNames();
+    if (this.themedIconApp) gobject.g_object_unref(this.themedIconApp);
     this.themedIconApp = this.initThemedIcon(appIconNames);
   },
 
+  getAppIconNames: function() {
+    let appIconNames = firetray.Utils.getArrayPref(this.prefAppIconNames);
+    appIconNames.push(this.defaultAppIconName);
+    return appIconNames;
+  },
+  getNewMailIconNames: function() {
+    let newMailIconNames = firetray.Utils.getArrayPref(this.prefNewMailIconNames);
+    newMailIconNames.push(this.defaultNewMailIconName);
+    return newMailIconNames;
+  },
+
   initThemedIcon: function(names) {
     if (!isArray(names)) throw new TypeError();
     LOG("themedIconNames="+names);

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