mirror of
https://github.com/moparisthebest/FireTray
synced 2025-03-11 14:59:41 -04:00
* 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)
This commit is contained in:
parent
46e0e2c5b6
commit
6e2ce65512
@ -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
|
||||
|
5
TODO
5
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)
|
||||
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -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">
|
||||
|
@ -2,11 +2,7 @@
|
||||
pref("extensions.moztray@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);
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user