mirror of
https://github.com/moparisthebest/FireTray
synced 2024-08-13 15:53:47 -04:00
showSingleWindow() and hideSingleWindow() now defined per window (needed for start_hidden)
This commit is contained in:
parent
2789844b06
commit
7efe604b9c
@ -17,18 +17,15 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
||||
let init = firetray.Handler.initialized || firetray.Handler.init();
|
||||
|
||||
LOG("ONLOAD"); firetray.Handler.dumpWindows();
|
||||
firetray.Handler.registerWindow(win);
|
||||
let winId = firetray.Handler.registerWindow(win);
|
||||
|
||||
if (firetray.Handler.inMailApp && firetray.Messaging.initialized)
|
||||
firetray.Messaging.updateMsgCount();
|
||||
|
||||
win.addEventListener('close', firetrayChrome.onClose, true);
|
||||
|
||||
if (!firetray.Handler.appStarted
|
||||
&& firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
||||
if (firetray.Handler.windows[winId].startHidden) {
|
||||
LOG('start_hidden');
|
||||
let winId = firetray.Handler.getWindowIdFromChromeWindow(win);
|
||||
LOG('winId='+winId);
|
||||
firetray.Handler.hideSingleWindow(winId);
|
||||
}
|
||||
|
||||
|
@ -109,14 +109,6 @@ firetray.Handler = {
|
||||
VersionChange.setReinstallHook(welcome);
|
||||
VersionChange.watch();
|
||||
|
||||
if (firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
||||
firetray.Handler.showSingleWindow = firetray.Window.showSingleStatelessOnce;
|
||||
firetray.Handler.hideSingleWindow = firetray.Window.hideSingleStatelessOnce;
|
||||
} else {
|
||||
firetray.Handler.showSingleWindow = firetray.Window.showSingleStateful;
|
||||
firetray.Handler.hideSingleWindow = firetray.Window.hideSingleStateful;
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
return true;
|
||||
},
|
||||
@ -358,7 +350,7 @@ firetray.PrefListener = new PrefListener(
|
||||
LOG('Pref changed: '+name);
|
||||
switch (name) {
|
||||
case 'hides_single_window':
|
||||
firetray.Handler.updatePopupMenu();
|
||||
firetray.Handler.showHidePopupMenuItems();
|
||||
break;
|
||||
case 'show_icon_on_hide':
|
||||
firetray.Handler.showHideIcon();
|
||||
|
@ -151,6 +151,9 @@ firetray.PopupMenu = {
|
||||
},
|
||||
|
||||
showSingleWindowItem: function(xid) {
|
||||
if (!this.windowItemsHandled())
|
||||
return;
|
||||
|
||||
LOG("showSingleWindowItem");
|
||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||
this.showItem(menuItemWindow);
|
||||
@ -173,13 +176,15 @@ firetray.PopupMenu = {
|
||||
this.hideSingleWindowItemAndSeparator(xid);
|
||||
},
|
||||
|
||||
// PopupMenu.hideItem(firetray.Handler.gtkPopupMenuWindowItems.get(xid))
|
||||
hideSingleWindowItemAndSeparator: function(xid) {
|
||||
this.hideSingleWindowItem(xid);
|
||||
this.hideWindowSeparator();
|
||||
},
|
||||
|
||||
hideSingleWindowItemAndSeparatorMaybe: function(xid) {
|
||||
if (!this.windowItemsHandled())
|
||||
return;
|
||||
|
||||
this.hideSingleWindowItem(xid);
|
||||
if (firetray.Handler.visibleWindowsCount === firetray.Handler.windowsCount)
|
||||
this.hideWindowSeparator();
|
||||
@ -202,19 +207,20 @@ firetray.PopupMenu = {
|
||||
hideWindowSeparator: function() {
|
||||
LOG("hiding menuSeparatorWindows");
|
||||
gtk.gtk_widget_hide(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
||||
},
|
||||
|
||||
showHideWindowItems: function() {
|
||||
if (this.windowItemsHandled())
|
||||
this.showAllWindowItemsOnlyVisibleWindows();
|
||||
else
|
||||
this.hideAllWindowItems();
|
||||
},
|
||||
|
||||
windowItemsHandled: function() {
|
||||
return (firetray.Handler.inBrowserApp &&
|
||||
firetray.Utils.prefService.getBoolPref('hides_single_window'));
|
||||
}
|
||||
|
||||
}; // firetray.PopupMenu
|
||||
|
||||
|
||||
firetray.Handler.popupMenuWindowItemsHandled = function() {
|
||||
return (firetray.Handler.inBrowserApp &&
|
||||
firetray.Utils.prefService.getBoolPref('hides_single_window'));
|
||||
};
|
||||
|
||||
firetray.Handler.updatePopupMenu = function() {
|
||||
if (firetray.Handler.popupMenuWindowItemsHandled())
|
||||
firetray.PopupMenu.showAllWindowItemsOnlyVisibleWindows();
|
||||
else
|
||||
firetray.PopupMenu.hideAllWindowItems();
|
||||
};
|
||||
firetray.Handler.showHidePopupMenuItems = firetray.PopupMenu.showHideWindowItems;
|
||||
|
@ -189,20 +189,19 @@ firetray.Window = {
|
||||
},
|
||||
|
||||
showSingleStateful: function(xid) {
|
||||
LOG("show xid="+xid);
|
||||
LOG("showSingleStateful xid="+xid);
|
||||
|
||||
// try to restore previous state. TODO: z-order respected ?
|
||||
firetray.Window.restorePositionAndSize(xid);
|
||||
firetray.Window.restoreStates(xid);
|
||||
|
||||
// better visual effect if visibility set here instead of before
|
||||
firetray.Handler.windows[xid].baseWin.visibility = true; // show
|
||||
firetray.Window.setVisibility(xid, true);
|
||||
|
||||
firetray.Window.restoreDesktop(xid); // after show
|
||||
firetray.Window.activate(xid);
|
||||
|
||||
firetray.Window.setVisibility(xid, true);
|
||||
|
||||
if (firetray.Handler.popupMenuWindowItemsHandled())
|
||||
firetray.PopupMenu.hideSingleWindowItemAndSeparatorMaybe(xid);
|
||||
firetray.PopupMenu.hideSingleWindowItemAndSeparatorMaybe(xid);
|
||||
firetray.Handler.showHideIcon();
|
||||
},
|
||||
showSingleStatelessOnce: function(xid) {
|
||||
@ -210,11 +209,10 @@ firetray.Window = {
|
||||
|
||||
firetray.Window.setVisibility(xid, true);
|
||||
|
||||
if (firetray.Handler.popupMenuWindowItemsHandled())
|
||||
firetray.PopupMenu.hideSingleWindowItemAndSeparatorMaybe(xid);
|
||||
firetray.PopupMenu.hideSingleWindowItemAndSeparatorMaybe(xid);
|
||||
firetray.Handler.showHideIcon();
|
||||
|
||||
firetray.Handler.showSingleWindow = firetray.Window.showSingleStateful;
|
||||
firetray.Handler.windows[xid].show = firetray.Window.showSingleStateful; // reset
|
||||
},
|
||||
|
||||
// NOTE: we keep using high-level cross-plat BaseWindow.visibility (instead of
|
||||
@ -229,8 +227,7 @@ firetray.Window = {
|
||||
|
||||
firetray.Window.setVisibility(xid, false);
|
||||
|
||||
if (firetray.Handler.popupMenuWindowItemsHandled())
|
||||
firetray.PopupMenu.showSingleWindowItem(xid);
|
||||
firetray.PopupMenu.showSingleWindowItem(xid);
|
||||
firetray.Handler.showHideIcon();
|
||||
},
|
||||
/**
|
||||
@ -243,11 +240,10 @@ firetray.Window = {
|
||||
|
||||
firetray.Window.setVisibility(xid, false);
|
||||
|
||||
if (firetray.Handler.popupMenuWindowItemsHandled())
|
||||
firetray.PopupMenu.showSingleWindowItem(xid);
|
||||
firetray.PopupMenu.showSingleWindowItem(xid);
|
||||
firetray.Handler.showHideIcon();
|
||||
|
||||
firetray.Handler.hideSingleWindow = firetray.Window.hideSingleStateful;
|
||||
firetray.Handler.windows[xid].hide = firetray.Window.hideSingleStateful; // reset
|
||||
},
|
||||
|
||||
savePositionAndSize: function(xid) {
|
||||
@ -459,9 +455,12 @@ firetray.Window = {
|
||||
|
||||
getWindowTitle: function(xid) {
|
||||
let title = firetray.Handler.windows[xid].baseWin.title;
|
||||
LOG("baseWin.title="+title);
|
||||
let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appNameOriginal);
|
||||
if (tailIndex !== -1)
|
||||
return title.substring(0, tailIndex)
|
||||
return title.substring(0, tailIndex);
|
||||
else if (title === "Mozilla "+firetray.Handler.appNameOriginal)
|
||||
return title;
|
||||
else
|
||||
return null;
|
||||
},
|
||||
@ -554,12 +553,22 @@ firetray.Handler.registerWindow = function(win) {
|
||||
} catch (x) {
|
||||
firetray.Window.unregisterWindowByXID(xid);
|
||||
ERROR(x);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!firetray.Handler.appStarted &&
|
||||
firetray.Utils.prefService.getBoolPref('start_hidden')) {
|
||||
this.windows[xid].startHidden = true;
|
||||
this.windows[xid].hide = firetray.Window.hideSingleStatelessOnce;
|
||||
this.windows[xid].show = firetray.Window.showSingleStatelessOnce;
|
||||
} else {
|
||||
this.windows[xid].startHidden = false;
|
||||
this.windows[xid].hide = firetray.Window.hideSingleStateful;
|
||||
this.windows[xid].show = firetray.Window.showSingleStateful;
|
||||
}
|
||||
|
||||
LOG("AFTER"); firetray.Handler.dumpWindows();
|
||||
|
||||
return true;
|
||||
return xid;
|
||||
};
|
||||
|
||||
firetray.Handler.unregisterWindow = function(win) {
|
||||
@ -568,6 +577,16 @@ firetray.Handler.unregisterWindow = function(win) {
|
||||
return firetray.Window.unregisterWindowByXID(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.showSingleWindow = function(xid) {
|
||||
LOG("showSingleWindow xid="+xid);
|
||||
this.windows[xid].show(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.hideSingleWindow = function(xid) {
|
||||
LOG("hideSingleWindow xid="+xid);
|
||||
this.windows[xid].hide(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
||||
LOG("showHideAllWindows: "+userData);
|
||||
// NOTE: showHideAllWindows being a callback, we need to use
|
||||
|
Loading…
Reference in New Issue
Block a user