RetroZilla/xpfe/components/prefwindow/resources/content/win/platformPrefOverlay.xul
2015-10-20 23:03:22 -04:00

227 lines
9.4 KiB
XML

<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 1998-1999
the Initial Developer. All Rights Reserved.
Contributor(s):
Ben Goodger <ben@netscape.com>
Bill Law <law@netscape.com>
Alternatively, the contents of this file may be used under the terms of
either of the GNU General Public License Version 2 or later (the "GPL"),
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!ENTITY % platformPrefOverlayDTD SYSTEM "chrome://communicator-platform/locale/pref/platformPrefOverlay.dtd">
%platformPrefOverlayDTD;
]>
<overlay id="platformPreferencesOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- Windows integration is (obviously) only applicable on Windows. -->
<treechildren id="advancedChildren">
<treeitem id="winhooks">
<treerow>
<treecell url="chrome://communicator/content/pref/pref-winhooks.xul" label="&winhooks.label;"/>
</treerow>
</treeitem>
</treechildren>
<!-- Add "set default browser" button to Navigator panel. -->
<hbox id="pref-nav-platform-extensions">
<groupbox flex="1">
<caption label="&defaultBrowserGroup.label;"/>
<deck id="defaultBrowserDeck" flex="1">
<!-- We use a deck for the three cases:
o If not already the default, then use child 0 (with button enabled)
o If already the default, then use child 1 (with disabled button).
o If the user has already pushed the "Set As Default" button, then use child 2
(with different text and a disabled button).
-->
<vbox flex="1">
<description>&makeDefaultText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
oncommand="makeDefault()"/>
<spacer flex="1"/>
</hbox>
</vbox>
<vbox flex="1">
<description>&alreadyDefaultText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
disabled="true"/>
<spacer flex="1"/>
</hbox>
</vbox>
<vbox flex="1">
<description pack="start">&defaultPendingText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
disabled="true"/>
<spacer flex="1"/>
</hbox>
</vbox>
</deck>
</groupbox>
</hbox>
<script type="application/x-javascript">
<![CDATA[
// This overlay is pulled into multiple places. We only want this
// code to kick in when we're overlaid onto pref-navigator.xul. And,
// we don't want to conflict with code within other files. So,
// we use anonymous functions throughout.
if (document.documentElement.id == "pref-navigator") {
// "Install" the SetFields function. This will be
// called whenever the Navigator pane is shown.
window.SetFields = function( pageData ) {
// Determine if we have been selected as the default browser
// already, and enable/disable the "Set As Default" button
// accordingly.
// We store our state info in the same place as the code in
// pref-winhooks.js uses so that this panel and the
// Advanced/System panel are kept in synch.
if (!("winHooks" in parent)) {
// Neither the Advanced/System panel nor this panel has
// appeared. Initialize the state information.
parent.winHooks = new Object;
// Get winhooks service.
parent.winHooks.winhooks = Components.classes[ "@mozilla.org/winhooks;1" ]
.getService( Components.interfaces.nsIWindowsHooks );
// Extract current settings (these are what the user has checked on
// the Advanced/System panel).
parent.winHooks.prefs = parent.winHooks.winhooks.settings;
}
// Ensure our additional state info is set.
if (!("makeDefaultPending" in parent.winHooks)) {
parent.winHooks.makeDefaultPending = false;
}
// Figure out which <deck> child should be activated.
// Default is child 0 (with button enabled).
var deckState = 0;
// Start by checking http/https/ftp and html/xhtml/xml.
var prefs = parent.winHooks.prefs;
if (prefs.isHandlingHTTP &&
prefs.isHandlingHTTPS &&
prefs.isHandlingFTP &&
prefs.isHandlingHTML &&
prefs.isHandlingXHTML &&
prefs.isHandlingXML) {
// The user *wants* us to be the default, apparently. This means
// that the deck *might* be in one of the other two states (with
// button disabled), depending on whether the registry matches.
// We test the registry settings using a scratch copy of the
// settings because we don't care about some of them, but we
// don't want to mess up the user's choices from the
// Advanced/System panel.
var testSettings = parent.winHooks.winhooks.settings;
// Test that these are set.
testSettings.isHandlingHTTP = true;
testSettings.isHandlingHTTPS = true;
testSettings.isHandlingFTP = true;
testSettings.isHandlingHTML = true;
testSettings.isHandlingXHTML = true;
testSettings.isHandlingXML = true;
// Ignore the rest.
testSettings.isHandlingCHROME = false;
testSettings.isHandlingGOPHER = false;
testSettings.isHandlingJPEG = false;
testSettings.isHandlingGIF = false;
testSettings.isHandlingMNG = false;
testSettings.isHandlingPNG = false;
testSettings.isHandlingBMP = false;
testSettings.isHandlingICO = false;
testSettings.isHandlingXUL = false;
// Now test whether the registry matches that.
if ( testSettings.registryMatches ) {
// Disable the button. The only remaining question
// is what text appears alongside it. That will
// vary depending on whether the user has pressed
// the "Set As Default" button already.
if ( parent.winHooks.makeDefaultPending ) {
deckState = 2;
} else {
deckState = 1;
}
}
}
// Now, switch the deck to the appropriate state.
document.getElementById("defaultBrowserDeck").selectedIndex = deckState;
// Return true to tell caller to process the standard pref fields.
return true;
}
// "Install" the makeDefault function;
window.makeDefault = function() {
// Extract current settings (these are what the
// user has checked on the Advanced/System panel).
var settings = parent.winHooks.prefs;
// Turn on all "default browser" settings.
settings.isHandlingHTTP = true;
settings.isHandlingHTTPS = true;
settings.isHandlingFTP = true;
settings.isHandlingHTML = true;
settings.isHandlingXHTML = true;
settings.isHandlingXML = true;
// Register callback that will be called when and if the
// user presses the OK button.
parent.hPrefWindow.registerOKCallbackFunc( function () {
// Apply the settings.
parent.winHooks.winhooks.settings = parent.winHooks.prefs;
} );
// Flip the deck to the "make-default pending" state.
document.getElementById("defaultBrowserDeck").selectedIndex = 2;
// Remember this state when next displayed.
parent.winHooks.makeDefaultPending = true;
}
}
]]>
</script>
</overlay>