make error console and add-ons window available from menus and don't launch with...
authorRobert Kaiser <robert@notebook.(none)>
Fri, 3 Apr 2009 20:10:32 +0000 (22:10 +0200)
committerRobert Kaiser <robert@notebook.(none)>
Fri, 3 Apr 2009 20:10:32 +0000 (22:10 +0200)
mandelbrot
xulapp/chrome/mandelbrot/content/mandelbrot.js
xulapp/chrome/mandelbrot/content/mandelbrot.xul
xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd

index 33c4c8f..62bb8d8 100755 (executable)
@@ -61,4 +61,4 @@ fi
 
 # add -jsconsole for debugging
 
-$xulrunner --app $app_ini -jsconsole
+$xulrunner --app $app_ini
index cf4927a..1b0e960 100644 (file)
@@ -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);
+  }
+}
index b83b843..0ca532d 100644 (file)
               <menuitem type="radio" name="algorithm" value="oo" label="&algoOO.label;"/>
             </menupopup>
           </menu>
+          <menuitem id="errorConsole" label="&errorConsole.label;"
+                    oncommand="errorConsole();"/>
+          <menuitem id="addonsMgr" label="&addonsManager.label;"
+                    oncommand="addonsManager();"/>
         </menupopup>
       </menu>
     </menubar>
index b71edf4..1c2eda0 100644 (file)
@@ -58,3 +58,5 @@
 <!ENTITY algoMenu.label   "Algorithm">
 <!ENTITY algoNumeric.label "Numeric">
 <!ENTITY algoOO.label     "Object-Oriented">
+<!ENTITY errorConsole.label "Error Console">
+<!ENTITY addonsManager.label "Add-ons Manager">