From 2928af4b7cdebc406f26dd77dec78fa0e0e21413 Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Sat, 8 Oct 2005 14:16:08 +0000 Subject: [PATCH] Bug 311508 - If the prefwindow is modal, 'Use Current Pages' should use the prefwindow opener as the current pages rather than the last focused browser window. r=mconnor. --- browser/components/preferences/general.js | 46 +++++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/browser/components/preferences/general.js b/browser/components/preferences/general.js index d579bb3e24dd..258318a4f4a7 100644 --- a/browser/components/preferences/general.js +++ b/browser/components/preferences/general.js @@ -21,6 +21,7 @@ # # Contributor(s): # Ben Goodger +# Asaf Romano # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -41,9 +42,16 @@ var gGeneralPane = { setHomePageToCurrentPage: function () { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); + var win; + if (document.documentElement.instantApply) { + // If we're in instant-apply mode, use the most recent browser window + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + win = wm.getMostRecentWindow("navigator:browser"); + } + else + win = window.opener; + if (win) { var homePageField = document.getElementById("browserStartupHomepage"); var newVal = ""; @@ -117,23 +125,38 @@ var gGeneralPane = { init: function () { this._pane = document.getElementById("paneGeneral"); - + + this._updateUseCurrentButton(); + if (document.documentElement.instantApply) + window.addEventListener("focus", this._updateUseCurrentButton, false); + }, + + _updateUseCurrentButton: function () { var useButton = document.getElementById("browserUseCurrent"); - - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - if (win) { + + var win; + if (document.documentElement.instantApply) { + // If we're in instant-apply mode, use the most recent browser window + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + win = wm.getMostRecentWindow("navigator:browser"); + } + else + win = window.opener; + + if (win && win.document.documentElement + .getAttribute("windowtype") == "navigator:browser") { + useButton.disabled = false; + var tabbrowser = win.document.getElementById("content"); if (tabbrowser.browsers.length > 1) useButton.label = useButton.getAttribute("label2"); } else { - // prefwindow wasn't opened from a browser window, so no current page useButton.disabled = true; } }, - + showConnections: function () { document.documentElement.openSubDialog("chrome://browser/content/preferences/connection.xul", @@ -171,4 +194,3 @@ var gGeneralPane = { } #endif }; -