Browse Source

b=475147, r=mfinkle, Changes to custom pref pane support

matthew@allpeers.com 15 years ago
parent
commit
87538d36ff

+ 1 - 2
runtime/chrome/content/preferences/connection.xul

@@ -44,8 +44,7 @@
 
 <overlay id="AdvancedPaneOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
-  <prefpane id="paneAdvanced"
-            helpTopic="prefs-connection-settings">
+  <prefpane id="paneAdvanced">
 
     <preferences>
       <preference id="network.proxy.type"         name="network.proxy.type"         type="int" onchange="WebRunnerAdvancedPrefs.proxyTypeChanged();"/>

+ 0 - 3
runtime/chrome/content/preferences/content.js

@@ -24,9 +24,6 @@
 
 /* Development of this Contribution was supported by Yahoo! Inc. */
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
 // Stolen/adapted from browser/components/preferences/content.js
 var WebRunnerContentPrefs =
 {

+ 37 - 2
runtime/chrome/content/preferences/preferences.js

@@ -1,3 +1,6 @@
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
 Components.utils.import("resource://prism-runtime/modules/WebAppProperties.jsm");
 
 var WebRunnerPrefs =
@@ -8,14 +11,46 @@ var WebRunnerPrefs =
     prefXUL.append("prefs.xul");
 
     if (prefXUL.exists()) {
+      var prefProperties = WebAppProperties.getAppRoot();
+      prefProperties.append("preferences");
+      prefProperties.append("prefs.properties");
+      
+      var label;
+      if (prefProperties.exists()) {
+        var bundle = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
+        bundle = bundle.createBundle("resource://webapp/preferences/prefs.properties");
+        label = bundle.GetStringFromName("pane.label");
+      }
+      else {
+        label = WebAppProperties.name;
+      }
+    
       var prefPane = document.createElement("prefpane");
       prefPane.id = "paneWebApp";
-      prefPane.setAttribute("label", WebAppProperties.name);
+      prefPane.setAttribute("label", label);
       prefPane.src = "resource://webapp/preferences/prefs.xul";
       prefPane.image = "resource://webapp/preferences/prefs.png";
       
       var prefWindow = document.getElementById("BrowserPreferences");
-      prefWindow.addPane(prefPane);
+
+      prefWindow.insertBefore(prefPane, prefWindow.firstChild);
+      var radio = document.createElement("radio");
+      radio.setAttribute("pane", prefPane.id);
+      radio.setAttribute("label", prefPane.label);
+      // Expose preference group choice to accessibility APIs as an unchecked list item
+      // The parent group is exposed to accessibility APIs as a list
+      radio.setAttribute("src", prefPane.image);
+      radio.style.listStyleImage = prefPane.style.listStyleImage;
+      var selector = document.getAnonymousElementByAttribute(prefWindow, "anonid", "selector");
+      selector.insertBefore(radio, selector.firstChild);
+
+      if ("arguments" in window && window.arguments[0] && document.getElementById(window.arguments[0]) && document.getElementById(window.arguments[0]).nodeName == "prefpane") {
+        prefWindow.showPane(document.getElementById(window.arguments[0]));
+      }
+      else
+      {
+        prefWindow.showPane(prefPane);
+      }
     }
   }
 };

+ 0 - 8
runtime/chrome/content/preferences/preferences.xul

@@ -43,14 +43,6 @@
 <?xml-stylesheet href="chrome://mozapps/content/preferences/preferences.css"?>
 <?xml-stylesheet href="chrome://webrunner/skin/preferences/preferences.css"?>
 
-<!-- XXX This should be in applications.xul, but bug 393953 means putting it
-   - there causes the Applications pane not to work the first time you open
-   - the Preferences dialog in a browsing session, so we work around the problem
-   - by putting it here instead.
-   -->
-<!-- <?xml-stylesheet href="chrome://browser/content/preferences/handlers.css"?>
-<?xml-stylesheet href="chrome://browser/skin/preferences/applications.css"?> -->
-
 <!DOCTYPE prefwindow [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 <!ENTITY % preferencesDTD SYSTEM "chrome://webrunner/locale/preferences/preferences.dtd">

+ 9 - 0
runtime/modules/HostUI.jsm

@@ -33,6 +33,7 @@ EXPORTED_SYMBOLS = ["HostUI"];
  */
 var HostUI = {
   _document : null,
+  _window :   null,
 
   log : function(aMsg) {
     var console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
@@ -43,6 +44,14 @@ var HostUI = {
     return this._document.getElementById("browser_content");
   },
   
+  showAbout : function() {
+    this._window.openDialog("chrome://webrunner/content/about.xul", "about", "centerscreen,modal");
+  },
+  
+  showPreferences : function(paneToShow) {
+    this._window.openDialog("chrome://webrunner/content/preferences/preferences.xul", "preferences", "chrome,extrachrome,dialog=no,centerscreen,toolbar,modal", paneToShow);
+  },
+  
   showAlert : function(aImage, aTitle, aMsg) {
     var alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
     alerts.showAlertNotification(aImage, aTitle, aMsg, false, "", null);