[Pkg-mozext-commits] [firetray] 317/399: option to hide only last window (#24)

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 90ee9f834b44733102c83fa0e7453e20dd395f38
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Mon Sep 10 15:00:25 2012 +0200

    option to hide only last window (#24)
---
 src/chrome/content/options.js        |    5 +++--
 src/chrome/content/options.xul       |    5 +++++
 src/chrome/content/overlay.js        |   17 +++++++++++------
 src/chrome/locale/en-US/options.dtd  |    3 +++
 src/defaults/preferences/prefs.js    |    1 +
 src/modules/linux/FiretrayWindow.jsm |    4 +++-
 6 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index da5841f..312bb8f 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -108,8 +108,9 @@ var firetrayUIOptions = {
     let hides_on_close    = document.getElementById("ui_hides_on_close").checked;
     let hides_on_minimize = document.getElementById("ui_hides_on_minimize").checked;
     log.debug("hides_on_close="+hides_on_close+", hides_on_minimize="+hides_on_minimize);
-    document.getElementById('ui_hides_single_window').disabled =
-      !(hides_on_close || hides_on_minimize);
+    let doDisable = !(hides_on_close || hides_on_minimize);
+    document.getElementById('ui_hides_single_window').disabled = doDisable;
+    document.getElementById('ui_hides_last_only').disabled = doDisable;
   },
 
   updateScrollOptions: function() {
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 8caab65..268d8c6 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -23,6 +23,7 @@
       <preference id="pref_hides_on_close" name="extensions.firetray.hides_on_close" type="bool"/>
       <preference id="pref_hides_on_minimize" name="extensions.firetray.hides_on_minimize" type="bool"/>
       <preference id="pref_hides_single_window" name="extensions.firetray.hides_single_window" type="bool"/>
+      <preference id="pref_hides_last_only" name="extensions.firetray.hides_last_only" type="bool"/>
       <preference id="pref_start_hidden" name="extensions.firetray.start_hidden" type="bool"/>
       <preference id="pref_show_activates" name="extensions.firetray.show_activates" type="bool"/>
       <preference id="pref_remember_desktop" name="extensions.firetray.remember_desktop" type="bool"/>
@@ -41,6 +42,10 @@
                 label="&hides_single_window.label;"
                 accesskey="&hides_single_window.accesskey;"
                 tooltiptext="&hides_single_window.tooltip;"/>
+      <checkbox id="ui_hides_last_only" preference="pref_hides_last_only"
+                label="&hides_last_only.label;"
+                accesskey="&hides_last_only.accesskey;"
+                tooltiptext="&hides_last_only.tooltip;"/>
       <checkbox id="ui_start_hidden" preference="pref_start_hidden"
                 label="&start_hidden.label;"
                 accesskey="&start_hidden.accesskey;"/>
diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js
index 4641999..7eac7b8 100644
--- a/src/chrome/content/overlay.js
+++ b/src/chrome/content/overlay.js
@@ -31,12 +31,13 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
     return true;
   },
 
+
+  /* NOTE: don't do firetray.Handler.initialized=false here, otherwise after a
+   window close, a new window will create a new handler (and hence, a new tray
+   icon) */
   onQuit: function(win) {
     firetray.Handler.unregisterWindow(win);
-
-    /* NOTE: don't do firetray.Handler.initialized=false here, otherwise after
-     a window close, a new window will create a new handler (and hence, a new
-     tray icon) */
+    log.info("windowsCount="+firetray.Handler.windowsCount+", visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
     log.debug('Firetray UNLOADED !');
   },
 
@@ -52,9 +53,13 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
       throw new TypeError('originalTarget not a ChromeWindow');
 
     let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
-    let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
-    log.debug('hides_on_close: '+hides_on_close+', hides_single_window='+hides_single_window);
+    log.debug('hides_on_close: '+hides_on_close);
     if (hides_on_close) {
+      let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
+      let hides_last_only = firetray.Utils.prefService.getBoolPref('hides_last_only');
+      log.debug('hides_single_window='+hides_single_window+', windowsCount='+firetray.Handler.windowsCount);
+      if (hides_last_only && (firetray.Handler.windowsCount > 1)) return;
+
       if (hides_single_window) {
         firetray.Handler.hideWindow(firetrayChrome.winId);
       } else
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index 4cbb6f4..7d5f4b0 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -16,6 +16,9 @@
 <!ENTITY hides_single_window.label "Hide windows individually">
 <!ENTITY hides_single_window.tooltip "not all windows at once">
 <!ENTITY hides_single_window.accesskey "H">
+<!ENTITY hides_last_only.label "Only last window can be hidden">
+<!ENTITY hides_last_only.tooltip "other windows will be closed (terminated)">
+<!ENTITY hides_last_only.accesskey "O">
 <!ENTITY start_hidden.label "Start application hidden to tray">
 <!ENTITY start_hidden.accesskey "S">
 <!ENTITY show_activates.label "Activate restored windows">
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index e7ad22d..6ae0be9 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -7,6 +7,7 @@ pref("extensions.firetray.firstrun", true);
 pref("extensions.firetray.hides_on_close", true);
 pref("extensions.firetray.hides_on_minimize", true);
 pref("extensions.firetray.hides_single_window", true);
+pref("extensions.firetray.hides_last_only", true);
 pref("extensions.firetray.start_hidden", false);
 pref("extensions.firetray.show_activates", false);
 pref("extensions.firetray.remember_desktop", false);
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index b100492..067af89 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -206,9 +206,11 @@ firetray.Window = {
       throw new DeleteError();
     firetray.Handler.gtkWindows.remove(xid);
     firetray.Handler.gdkWindows.remove(xid);
-    firetray.PopupMenu.removeWindowItem(xid);
+    firetray.Handler.windowsCount -= 1;
     firetray.Handler.visibleWindowsCount -= 1;
 
+    firetray.PopupMenu.removeWindowItem(xid);
+
     log.debug("window "+xid+" unregistered");
     return true;
   },

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