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 33c4c8ff12c57fd24b29db6aafc246aea7a523e2..62bb8d82888c6296820bd96a70d4b4ca96969c85 100755 (executable)
@@ -61,4 +61,4 @@ fi
 
 # add -jsconsole for debugging
 
-$xulrunner --app $app_ini -jsconsole
+$xulrunner --app $app_ini
index cf4927af4a961069b679135d1e86436104db96ad..1b0e960ff7d45f614f585c04cb27b9585529e5d2 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 b83b843387245b61e6908c031b8b49702798b0b8..0ca532df4ff2f53648e0d2109c28a334882421d6 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 b71edf46a5043e3dcefbfa075d78c28947ff7b4a..1c2eda0efbc3a587c44743ebfddd29678ecca394 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">