From af3c147c73180649db2a0f4326741a78637325e9 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Fri, 3 Apr 2009 22:10:32 +0200 Subject: [PATCH] make error console and add-ons window available from menus and don't launch with error console by default any more --- mandelbrot | 2 +- .../chrome/mandelbrot/content/mandelbrot.js | 60 +++++++++++++++++++ .../chrome/mandelbrot/content/mandelbrot.xul | 4 ++ .../mandelbrot/locales/en-US/mandelbrot.dtd | 2 + 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/mandelbrot b/mandelbrot index 33c4c8f..62bb8d8 100755 --- a/mandelbrot +++ b/mandelbrot @@ -61,4 +61,4 @@ fi # add -jsconsole for debugging -$xulrunner --app $app_ini -jsconsole +$xulrunner --app $app_ini diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index cf4927a..1b0e960 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -458,6 +458,29 @@ function setAlgorithm(algoID) { gPref.setCharPref("mandelbrot.use_algorithm", algoID); } +function addonsManager(aPane) { + var theEM = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow("Extension:Manager"); + if (theEM) { + theEM.focus(); + if (aPane) + theEM.showView(aPane); + return; + } + + const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; + const EMFEATURES = "all,dialog=no"; + if (aPane) + window.openDialog(EMURL, "", EMFEATURES, aPane); + else + window.openDialog(EMURL, "", EMFEATURES); +} + +function errorConsole() { + toOpenWindowByType("global:console", "chrome://global/content/console.xul"); +} + /***** helper functions from external sources *****/ // function below is based on http://developer.mozilla.org/en/docs/Code_snippets:Canvas @@ -493,3 +516,40 @@ function quitApp(aForceQuit) { Components.interfaces.nsIAppStartup.eAttemptQuit; appStartup.quit(quitSeverity); } + +// functions below are from comm-central/suite/common/tasksOverlay.js +function toOpenWindow(aWindow) { + try { + // Try to focus the previously focused window e.g. message compose body + aWindow.document.commandDispatcher.focusedWindow.focus(); + } catch (e) { + // e.g. full-page plugin or non-XUL document; just raise the top window + aWindow.focus(); + } +} + +function toOpenWindowByType(inType, uri, features) { + // don't do several loads in parallel + if (uri in window) + return; + + var topWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow(inType); + if ( topWindow ) + toOpenWindow( topWindow ); + else { + // open the requested window, but block it until it's fully loaded + function newWindowLoaded(event) { + // make sure that this handler is called only once + window.removeEventListener("unload", newWindowLoaded, false); + window[uri].removeEventListener("load", newWindowLoaded, false); + delete window[uri]; + } + // remember the newly loading window until it's fully loaded + // or until the current window passes away + window[uri] = window.openDialog(uri, "", features || "all,dialog=no"); + window[uri].addEventListener("load", newWindowLoaded, false); + window.addEventListener("unload", newWindowLoaded, false); + } +} diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.xul b/xulapp/chrome/mandelbrot/content/mandelbrot.xul index b83b843..0ca532d 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.xul +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.xul @@ -98,6 +98,10 @@ + + diff --git a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd index b71edf4..1c2eda0 100644 --- a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd +++ b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd @@ -58,3 +58,5 @@ + + -- 2.35.3