[Pkg-mozext-commits] [firetray] 23/399: * remember and correct window positions when hiding/showing * fix: prevent multiple handler/icon creations * closing a window hides all windows * add option for 'close_hides' (work in progress)

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:07 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 6e2ce65512c4382c20cb8aacc034f738f32decb4
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Mon Aug 15 22:39:25 2011 +0200

    * remember and correct window positions when hiding/showing
    * fix: prevent multiple handler/icon creations
    * closing a window hides all windows
    * add option for 'close_hides' (work in progress)
---
 README.md                           |    4 ++++
 TODO                                |    5 +++--
 src/chrome/content/options.js       |   33 +--------------------------
 src/chrome/content/options.xul      |   42 +++++------------------------------
 src/chrome/content/overlay.js       |   34 ++++++++++++++++++++++------
 src/chrome/locale/en-US/options.dtd |   17 ++++----------
 src/defaults/preferences/prefs.js   |    6 +----
 src/install.rdf                     |    2 +-
 src/modules/MoztHandler.jsm         |   38 +++++++++++++++++++++++++------
 9 files changed, 78 insertions(+), 103 deletions(-)

diff --git a/README.md b/README.md
index 78c2459..d493af8 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,5 @@
 rewrite of **Firetray** with js-ctypes
+
+## KNOWN BUGS ##
+
+* windows aren't restored with the same z-order, but there is no means to correct that under Linux: https://bugzilla.mozilla.org/show_bug.cgi?id=156333
diff --git a/TODO b/TODO
index e3b1431..81b2339 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,5 @@
-* BUG: windows aren't restored at the same position, or with the same z-order
-https://developer.mozilla.org/en/nsIWindowMediator#getZOrderXULWindowEnumerator%28%29
+* fix 'close_hides' option behavior
+
+* add 'quit' to icon menu + add option UI for close_all_tabs
 
 * make multi-platform. At least have js-ctypes library call dependant on OS detection. (best would be to have the OS-dependant modules loaded at startup) 
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index d215a8a..e17fe80 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -5,40 +5,9 @@ Components.utils.import("resource://moztray/commons.js");
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
-moztray.UIOptions = {
+mozt.UIOptions = {
 
   onLoad: function() {
-    this.toggleDisable_All(moztray.Utils.prefService.getBoolPref('enabled'));
-    this.toggleCheck_BypassIssuerUnknown(
-      document.getElementById('ui_bypass_self_signed').checked);
-  },
-
-  toggleDisable_All: function(enabledChecked) {
-    document.getElementById('ui_add_temporary_exceptions').disabled = !enabledChecked;
-    document.getElementById('ui_notify').disabled = !enabledChecked;
-    this.toggleDisable_BypassErrors(enabledChecked);
-   },
-
-  toggleDisable_BypassErrors: function(checked) {
-    var certErrorCondChildren = document.getElementById('ui_bypass_errors')
-      .childNodes;
-    for (var i = 0; i < certErrorCondChildren.length; i++) {
-      var node = certErrorCondChildren[i];
-      node.disabled = !checked;
-     }
-
-    if (checked)
-      this.toggleCheck_BypassIssuerUnknown(
-        document.getElementById('ui_bypass_self_signed').checked);
-  },
-
-  toggleCheck_BypassIssuerUnknown: function(selfSignedChecked) {
-    if (selfSignedChecked) {
-      document.getElementById('ui_bypass_issuer_unknown').checked = selfSignedChecked;
-      document.getElementById('ui_bypass_issuer_unknown').disabled = true;
-    } else {
-      document.getElementById('ui_bypass_issuer_unknown').disabled = false;
-    }
   },
 
 };
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 6f0d586..08865f3 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -4,51 +4,21 @@
 <prefwindow id="moztray-preferences"
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
             title="&prefwindow.title;"
-            onload= "moztray.UIOptions.onLoad()">
+            onload= "mozt.UIOptions.onLoad()">
 
   <script type="application/x-javascript" src="options.js" />
 
   <prefpane id="pane1" label="&pane1.title;">
 
     <preferences>
-      <preference id="pref_bool_enabled"
-                  name="extensions.moztray.enabled" type="bool"/>
-      <preference id="pref_bool_add_temporary_exceptions"
-                  name="extensions.moztray.add_temporary_exceptions" type="bool"/>
-      <preference id="pref_bool_notify"
-                  name="extensions.moztray.notify" type="bool"/>
-      <preference id="pref_bool_bypass_issuer_unknown"
-                  name="extensions.moztray.bypass_issuer_unknown" type="bool"/>
-      <preference id="pref_bool_bypass_self_signed"
-                  name="extensions.moztray.bypass_self_signed" type="bool"/>
+      <preference id="pref_bool_close_hides"
+                  name="extensions.moztray.close_hides" type="bool"/>
     </preferences>
 
     <groupbox>
-      <caption>
-      <checkbox id="ui_enabled" preference="pref_bool_enabled"
-                label="&bool_enabled.label;"
-                accesskey="&bool_enabled.accesskey;"
-                onclick="moztray.UIOptions.toggleDisable_All(!this.checked); // checked=before click"/>
-      </caption>
-      <checkbox id="ui_add_temporary_exceptions"
-                preference="pref_bool_add_temporary_exceptions"
-                label="&bool_add_temporary_exceptions.label;"
-                accesskey="&bool_add_temporary_exceptions.accesskey;"/>
-      <checkbox id="ui_notify" preference="pref_bool_notify"
-                label="&bool_notify.label;"
-                accesskey="&bool_notify.accesskey;"/>
-      <groupbox id="ui_bypass_errors">
-        <caption label="&bypass_errors;"/>
-        <checkbox id="ui_bypass_issuer_unknown"
-                  preference="pref_bool_bypass_issuer_unknown"
-                  label="&bool_bypass_issuer_unknown.label;"
-                  accesskey="&bool_bypass_issuer_unknown.accesskey;"/>
-        <checkbox id="ui_bypass_self_signed"
-                  preference="pref_bool_bypass_self_signed"
-                  label="&bool_bypass_self_signed.label;"
-                  accesskey="&bool_bypass_self_signed.accesskey;"
-                  onclick="moztray.UIOptions.toggleCheck_BypassIssuerUnknown(!this.checked);"/>
-      </groupbox>
+      <checkbox id="ui_close_hides" preference="pref_bool_close_hides"
+                label="&bool_close_hides.label;"
+                accesskey="&bool_close_hides.accesskey;"/>
     </groupbox>
 
   </prefpane>
diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js
index d762366..4b90288 100644
--- a/src/chrome/content/overlay.js
+++ b/src/chrome/content/overlay.js
@@ -5,7 +5,7 @@ Components.utils.import("resource://moztray/MoztHandler.jsm");
 
 mozt.Main = {
 
-  onLoad: function() {
+  onLoad: function(e) {
     // initialization code
     this.strings = document.getElementById("moztray-strings");
 
@@ -22,16 +22,31 @@ mozt.Main = {
     if (!mozt.Handler.initialized)
       var initOK = mozt.Handler.init();
 
+    // prevent window closing.
+    if (mozt.Utils.prefService.getBoolPref('close_hides'))
+      window.addEventListener(
+        'close', function(event){mozt.Main.onClose(event);}, true);
+
     mozt.Debug.debug('Moztray LOADED: ' + initOK);
     return true;
   },
 
-  onQuit: function() {
+  onQuit: function(e) {
     // Remove observer
     mozt.Utils.prefService.removeObserver("", this);
 
     mozt.Debug.debug('Moztray UNLOADED !');
-    mozt.Handler.initialized = false;
+    /*
+     *  NOTE: don't mozt.Handler.initialized=false here, otherwise after a
+     *  window close, a new window will create a new handler (and hence, a new
+     *  tray icon)
+     */
+  },
+
+  onClose: function(event) {
+    mozt.Debug.debug('Moztray CLOSE');
+    mozt.Handler.showHideToTray();
+    event.preventDefault();
   },
 
   observe: function(subject, topic, data) {
@@ -40,10 +55,15 @@ mozt.Main = {
     mozt.Debug.debug('Pref changed: '+data);
 
     switch(data) {
-    // case 'enabled':
-    //   var enable = mozt.Utils.prefService.getBoolPref('enabled');
-    //   this._toggle(enable);
-    //   break;
+    case 'close_hides':         // prevent window closing.
+      // TODO: apply to all windows !!
+      if (mozt.Utils.prefService.getBoolPref('close_hides'))
+        window.addEventListener(
+          'close', function(event){mozt.Main.onClose(event);}, true);
+      else
+        window.removeEventListener(
+          'close', function(event){mozt.Main.onClose(event);}, true);
+      break;
     }
   },
 
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index c0e0c1d..d538f99 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -1,13 +1,4 @@
-<!ENTITY prefwindow.title "Skip Cert Error preferences">
-<!ENTITY pane1.title "Skip Cert Error preferences">
-<!ENTITY bool_enabled.label "Enable bypass">
-<!ENTITY bool_enabled.accesskey "E">
-<!ENTITY bool_add_temporary_exceptions.label "Add the exceptions as temporary">
-<!ENTITY bool_add_temporary_exceptions.accesskey "T">
-<!ENTITY bool_notify.label "Notifications">
-<!ENTITY bool_notify.accesskey "N">
-<!ENTITY bypass_errors "Bypass error when cert is:">
-<!ENTITY bool_bypass_issuer_unknown.label "from unknown issuer">
-<!ENTITY bool_bypass_issuer_unknown.accesskey "I">
-<!ENTITY bool_bypass_self_signed.label "self-signed">
-<!ENTITY bool_bypass_self_signed.accesskey "G">
+<!ENTITY prefwindow.title "MozTray preferences">
+<!ENTITY pane1.title "MozTray preferences">
+<!ENTITY bool_close_hides.label "Closing windows hides to tray">
+<!ENTITY bool_close_hides.accesskey "C">
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index ad89c64..00bf151 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -2,11 +2,7 @@
 pref("extensions.moztray at foudil.fr.description", "chrome://moztray/locale/overlay.properties");
 
 // Extension prefs
-pref("extensions.moztray.enabled", true);
-pref("extensions.moztray.add_temporary_exceptions", true);
-pref("extensions.moztray.notify", true);
-pref("extensions.moztray.bypass_issuer_unknown", true);
-pref("extensions.moztray.bypass_self_signed", true);
+pref("extensions.moztray.close_hides", true);
 
 // Set the environment settings
 pref("browser.ssl_override_behavior", 2);
diff --git a/src/install.rdf b/src/install.rdf
index ca6d5e0..6d119f9 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -10,7 +10,7 @@
     <em:contributor>Hua Luo, Francesco Solero (Firetray original authors)</em:contributor>
     <em:homepageURL>https://github.com/foudfou/moztray</em:homepageURL>
     <em:description>A system tray extension for linux.</em:description>
-    <!-- <em:optionsURL>chrome://moztray/content/options.xul</em:optionsURL> -->
+    <em:optionsURL>chrome://moztray/content/options.xul</em:optionsURL>
     <em:iconURL>chrome://moztray/skin/icon32.png</em:iconURL>
     <em:targetPlatform>Linux</em:targetPlatform> <!-- only Linux supported for now -->
 
diff --git a/src/modules/MoztHandler.jsm b/src/modules/MoztHandler.jsm
index 8393fd1..5b507ee 100644
--- a/src/modules/MoztHandler.jsm
+++ b/src/modules/MoztHandler.jsm
@@ -85,11 +85,16 @@ mozt.Handler = {
   showHideToTray: function(a1, a2, a3) {
     mozt.Debug.debug("showHideToTray");
 
-    try {
+    /*
+     * we update _handledDOMWindows only when hiding, because remembered{X,Y}
+     * properties are attached to them, and we suppose there won't be
+     * created/delete windows when all are hidden.
+     *
+     * NOTE: this may not be a good design if we want to show/hide one window
+     * at a time...
+     */
+    if (!this._windowsHidden)   // hide
       this._updateHandledDOMWindows();
-    } catch (x) {
-      mozt.Debug.debug(x);
-    }
     mozt.Debug.debug("nb Windows: " + this._handledDOMWindows.length);
 
     for(let i=0; i<this._handledDOMWindows.length; i++) {
@@ -100,13 +105,29 @@ mozt.Handler = {
       mozt.Debug.debug("bw.visibility: " + bw.visibility);
       try {
         if (this._windowsHidden) { // show
+
+          // correct position
+          let x = this._handledDOMWindows[i].rememberedX;
+          let y = this._handledDOMWindows[i].rememberedY;
+          mozt.Debug.debug("set bw.position: " + x + ", " + y);
+          bw.setPosition(x, y);
+
           bw.visibility = true;
+
         } else {                // hide
-          bw.visibility = false;
+
+          // remember position
           let x = {}, y = {};
           bw.getPosition(x, y);
-          mozt.Debug.debug("bw.position: " + x.value + ", " + y.value);
+          mozt.Debug.debug("remember bw.position: " + x.value + ", " + y.value);
+          this._handledDOMWindows[i].rememberedX = x.value;
+          this._handledDOMWindows[i].rememberedY = y.value;
+          // var windowID = win.QueryInterface(Ci.nsIInterfaceRequestor)
+          //   .getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+
+          bw.visibility = false;
         }
+
       } catch (x) {
         mozt.Debug.debug(x);
       }
@@ -134,6 +155,9 @@ mozt.Handler = {
       // Cu.import("resource://moztray/MoztHandler-Linux.jsm");
     }
 
+    // init all handled windows
+    this._updateHandledDOMWindows();
+
     try {
 
       // instanciate tray icon
@@ -145,7 +169,7 @@ mozt.Handler = {
                                                      iconFilename);
 
       // set tooltip.
-      // TODO: produces:
+      // GTK bug:
       // (firefox-bin:5302): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
       // (thunderbird-bin:5380): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
       LibGtkStatusIcon.gtk_status_icon_set_tooltip_text(this.tray_icon,

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