mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 264675 Make sure we respect locked prefs throughout UI
p=me r=neil.parkwaycc.co.uk sr=dveditz
This commit is contained in:
parent
f20be6918a
commit
ad161fa4cb
@ -4,49 +4,41 @@
|
||||
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const nsIFile = Components.interfaces.nsIFile;
|
||||
const nsIProperties = Components.interfaces.nsIProperties;
|
||||
const kCacheParentDirPref = "browser.cache.disk.parent_directory";
|
||||
|
||||
var gFolderField;
|
||||
|
||||
function Startup()
|
||||
{
|
||||
var path = null;
|
||||
var pref = null;
|
||||
try
|
||||
{
|
||||
pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
path = pref.getComplexValue(kCacheParentDirPref, nsILocalFile);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
// parent_directory pref not set; path is null so we'll failover
|
||||
// to filling in the parent_directory as the profile directory
|
||||
}
|
||||
var prefWindow = parent.hPrefWindow;
|
||||
gFolderField = document.getElementById("browserCacheDiskCacheFolder");
|
||||
|
||||
if (!path)
|
||||
var dir = prefWindow.getPref("localfile", kCacheParentDirPref);
|
||||
if (dir == "!/!ERROR_UNDEFINED_PREF!/!")
|
||||
{
|
||||
try
|
||||
{
|
||||
// no disk cache folder found; default to profile directory
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(nsIProperties);
|
||||
var ifile = dirSvc.get("ProfD", nsIFile);
|
||||
path = ifile.QueryInterface(nsILocalFile);
|
||||
.getService(nsIProperties);
|
||||
dir = dirSvc.get("ProfD", nsILocalFile);
|
||||
|
||||
// now remember the new assumption
|
||||
if (pref)
|
||||
pref.setComplexValue(kCacheParentDirPref, nsILocalFile, path);
|
||||
prefWindow.setPref("localfile", kCacheParentDirPref, dir);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dir = null;
|
||||
}
|
||||
}
|
||||
|
||||
// if both pref and dir svc fail leave this field blank else show path
|
||||
if (path)
|
||||
document.getElementById("browserCacheDiskCacheFolder").value =
|
||||
path.path;
|
||||
// if both pref and dir svc fail leave this field blank else show directory
|
||||
if (dir)
|
||||
gFolderField.value = (/Mac/.test(navigator.platform)) ? dir.leafName : dir.path;
|
||||
|
||||
document.getElementById("chooseDiskCacheFolder").disabled =
|
||||
prefWindow.getPrefIsLocked(kCacheParentDirPref);
|
||||
}
|
||||
|
||||
|
||||
@ -54,31 +46,25 @@ function prefCacheSelectFolder()
|
||||
{
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||
.createInstance(nsIFilePicker);
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var prefWindow = parent.hPrefWindow;
|
||||
var prefutilitiesBundle = document.getElementById("bundle_prefutilities");
|
||||
var title = prefutilitiesBundle.getString("cachefolder");
|
||||
|
||||
fp.init(window, title, nsIFilePicker.modeGetFolder);
|
||||
try
|
||||
{
|
||||
var initialDir = pref.getComplexValue(kCacheParentDirPref, nsILocalFile);
|
||||
if (initialDir)
|
||||
fp.displayDirectory = initialDir;
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
// ignore exception: file picker will open at default location
|
||||
}
|
||||
|
||||
var initialDir = prefWindow.getPref("localfile", kCacheParentDirPref);
|
||||
|
||||
// Pref should always be set but just in case...
|
||||
if (initialDir != "!/!ERROR_UNDEFINED_PREF!/!")
|
||||
fp.displayDirectory = initialDir;
|
||||
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
var ret = fp.show();
|
||||
|
||||
if (ret == nsIFilePicker.returnOK) {
|
||||
var localFile = fp.file.QueryInterface(nsILocalFile);
|
||||
var viewable = fp.file.path;
|
||||
var folderField = document.getElementById("browserCacheDiskCacheFolder");
|
||||
folderField.value = viewable;
|
||||
pref.setComplexValue(kCacheParentDirPref, nsILocalFile, localFile)
|
||||
prefWindow.setPref("localfile", kCacheParentDirPref, localFile);
|
||||
gFolderField.value = (/Mac/.test(navigator.platform)) ? fp.file.leafName : fp.file.path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s): Aaron Leventhal
|
||||
* Asaf Romano
|
||||
* Ian Neal
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,7 +39,6 @@
|
||||
|
||||
const kTabToLinks = 4
|
||||
const kTabToForms = 2;
|
||||
parent.hPrefWindow.registerOKCallbackFunc(saveKeyNavPrefs);
|
||||
var gData;
|
||||
|
||||
function Startup()
|
||||
@ -46,21 +46,22 @@ function Startup()
|
||||
gData = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-keynav.xul"];
|
||||
|
||||
if (!/Mac/.test(navigator.platform)) {
|
||||
parent.hPrefWindow.registerOKCallbackFunc(saveKeyNavPrefs);
|
||||
if (!("tabNavPref" in gData)) {
|
||||
// Textboxes are always part of the tab order
|
||||
gData.tabNavPref = parent.hPrefWindow.getPref('int', 'accessibility.tabfocus') | 1;
|
||||
gData.tabNavLocked = parent.hPrefWindow.getPrefIsLocked('accessibility.tabfocus');
|
||||
}
|
||||
document.getElementById('tabNavigationLinks').setChecked((gData.tabNavPref & kTabToLinks) != 0);
|
||||
document.getElementById('tabNavigationForms').setChecked((gData.tabNavPref & kTabToForms) != 0);
|
||||
var tabNavigationLinks = document.getElementById('tabNavigationLinks');
|
||||
tabNavigationLinks.checked = ((gData.tabNavPref & kTabToLinks) != 0);
|
||||
tabNavigationLinks.disabled = gData.tabNavLocked;
|
||||
var tabNavigationForms = document.getElementById('tabNavigationForms');
|
||||
tabNavigationForms.checked = ((gData.tabNavPref & kTabToForms) != 0);
|
||||
tabNavigationForms.disabled = gData.tabNavLocked;
|
||||
}
|
||||
else
|
||||
document.getElementById('tabNavigationPrefs').setAttribute("hidden", true);
|
||||
|
||||
if (!("linksOnlyPref" in gData))
|
||||
gData.linksOnlyPref = parent.hPrefWindow.getPref('bool', 'accessibility.typeaheadfind.linksonly')? 1: 0;
|
||||
|
||||
var radioGroup = document.getElementById('findAsYouTypeAutoWhat');
|
||||
radioGroup.selectedIndex = gData.linksOnlyPref;
|
||||
setLinksOnlyDisabled();
|
||||
}
|
||||
|
||||
@ -68,15 +69,15 @@ function setLinksOnlyDisabled()
|
||||
{
|
||||
try {
|
||||
document.getElementById('findAsYouTypeAutoWhat').disabled =
|
||||
(document.getElementById('findAsYouTypeEnableAuto').checked == false);
|
||||
(!document.getElementById('findAsYouTypeEnableAuto').checked ||
|
||||
parent.hPrefWindow.getPrefIsLocked('accessibility.typeaheadfind.linksonly'));
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
|
||||
function saveKeyNavPrefs()
|
||||
{
|
||||
var data = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-keynav.xul"];
|
||||
if (!/Mac/.test(navigator.platform))
|
||||
parent.hPrefWindow.setPref("int", "accessibility.tabfocus", data.tabNavPref);
|
||||
parent.hPrefWindow.setPref("bool", "accessibility.typeaheadfind.linksonly", data.linksOnlyPref == 1);
|
||||
var data = parent.hPrefWindow.wsm.dataManager
|
||||
.pageData["chrome://communicator/content/pref/pref-keynav.xul"];
|
||||
parent.hPrefWindow.setPref("int", "accessibility.tabfocus", data.tabNavPref);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s): Aaron Leventhal
|
||||
- Ian Neal
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -49,8 +50,8 @@
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var _elementIDs = ["findAsYouTypeEnableAuto", "findAsYouTypeSound",
|
||||
"findAsYouTypeTimeout"];
|
||||
var _elementIDs = ["findAsYouTypeEnableAuto", "findAsYouTypeAutoWhat",
|
||||
"findAsYouTypeSound", "findAsYouTypeTimeout"];
|
||||
]]>
|
||||
</script>
|
||||
|
||||
@ -72,11 +73,11 @@
|
||||
<checkbox id="findAsYouTypeEnableAuto" label="&findAsYouTypeEnableAuto.label;"
|
||||
prefstring="accessibility.typeaheadfind.autostart"
|
||||
oncommand="setLinksOnlyDisabled();"/>
|
||||
<radiogroup id="findAsYouTypeAutoWhat" style="margin-left: 2em"
|
||||
oncommand="gData.linksOnlyPref = this.selectedIndex;">
|
||||
<radio value="0" label="&findAsYouTypeAutoText.label;"
|
||||
<radiogroup id="findAsYouTypeAutoWhat" class="indent"
|
||||
preftype="bool" prefstring="accessibility.typeaheadfind.linksonly">
|
||||
<radio value="false" label="&findAsYouTypeAutoText.label;"
|
||||
accesskey="&findAsYouTypeAutoText.accesskey;"/>
|
||||
<radio value="1" label="&findAsYouTypeAutoLinks.label;"
|
||||
<radio value="true" label="&findAsYouTypeAutoLinks.label;"
|
||||
accesskey="&findAsYouTypeAutoLinks.accesskey;"/>
|
||||
</radiogroup>
|
||||
<description>&findAsYouTypeTip.label;</description>
|
||||
|
@ -24,6 +24,7 @@
|
||||
bryner@brianryner.com
|
||||
sspitzer@netscape.com
|
||||
Peter Weilbacher <mozilla@weilbacher.org>
|
||||
Ian Neal <bugzilla@arlen.demon.co.uk>
|
||||
|
||||
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"),
|
||||
@ -62,46 +63,31 @@
|
||||
"mousewheelHorizWithAltKeyAction", "mousewheelWithAltKeyNumchars", "mousewheelWithAltKeySysNumchars",
|
||||
"mousewheelHorizWithCtrlKeyAction", "mousewheelWithCtrlKeyNumchars", "mousewheelWithCtrlKeySysNumchars",
|
||||
"mousewheelHorizWithShiftKeyAction", "mousewheelWithShiftKeyNumchars", "mousewheelWithShiftKeySysNumchars"];
|
||||
|
||||
|
||||
function switchPage( aElement )
|
||||
{
|
||||
var deck = document.getElementById( "modifierDeck" );
|
||||
deck.setAttribute( "selectedIndex", aElement.selectedItem.value );
|
||||
}
|
||||
|
||||
function doEnableElement( aEventTarget, aElementID )
|
||||
{
|
||||
var aElement = document.getElementById( aElementID );
|
||||
if( aEventTarget.checked == true )
|
||||
aElement.setAttribute( "disabled", "true" );
|
||||
else
|
||||
aElement.removeAttribute( "disabled" );
|
||||
}
|
||||
|
||||
|
||||
function Startup()
|
||||
{
|
||||
var fields = ["mousewheelWithNoKeyNumlines", "mousewheelWithAltKeyNumlines", "mousewheelWithCtrlKeyNumlines", "mousewheelWithShiftKeyNumlines",
|
||||
"mousewheelWithNoKeyNumchars", "mousewheelWithAltKeyNumchars", "mousewheelWithCtrlKeyNumchars", "mousewheelWithShiftKeyNumchars"];
|
||||
var checkboxes = ["mousewheelWithNoKeySysNumlines", "mousewheelWithAltKeySysNumlines", "mousewheelWithCtrlKeySysNumlines", "mousewheelWithShiftKeySysNumlines",
|
||||
"mousewheelWithNoKeySysNumchars", "mousewheelWithAltKeySysNumchars", "mousewheelWithCtrlKeySysNumchars", "mousewheelWithShiftKeySysNumchars"];
|
||||
for( var i = 0; i < checkboxes.length; i++ )
|
||||
{
|
||||
var currEl = document.getElementById( checkboxes[i] );
|
||||
doEnableElement( currEl, fields[i] );
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < checkboxes.length; i++)
|
||||
enableField(document.getElementById(checkboxes[i]), fields[i], false);
|
||||
}
|
||||
|
||||
function enableField(aCheckbox, aNodeID, setFocus)
|
||||
{
|
||||
var el = document.getElementById(aNodeID);
|
||||
if (aCheckbox.checked)
|
||||
el.setAttribute("disabled", "true");
|
||||
else
|
||||
el.removeAttribute("disabled");
|
||||
function enableField(aCheckbox, aNodeID, setFocus)
|
||||
{
|
||||
var el = document.getElementById(aNodeID);
|
||||
el.disabled = aCheckbox.checked || parent.hPrefWindow.getPrefIsLocked(el.getAttribute("prefstring"));
|
||||
|
||||
if (!el.disabled && setFocus)
|
||||
el.focus();
|
||||
}
|
||||
if (!el.disabled && setFocus)
|
||||
el.focus();
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
Contributor(s):
|
||||
Joe Hewitt <hewitt@netscape.com>
|
||||
Ian Neal <bugzilla@arlen.demon.co.uk>
|
||||
|
||||
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"),
|
||||
@ -53,10 +54,11 @@
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
setCheck("cbxAutoFill", window.arguments[0]);
|
||||
setCheck("cbxShowPopup", window.arguments[1]);
|
||||
setCheck("cbxShowSearch", window.arguments[2]);
|
||||
setCheck("cbxMatchOnlyTyped", window.arguments[3]);
|
||||
setCheck("cbxAutoFill", window.arguments[0], window.arguments[4]);
|
||||
setCheck("cbxShowPopup", window.arguments[1], window.arguments[5]);
|
||||
setCheck("cbxShowSearch", window.arguments[2], window.arguments[6]);
|
||||
setCheck("cbxMatchOnlyTyped", window.arguments[3], window.arguments[7]);
|
||||
gShowSearchLocked = (window.arguments[6] == "true");
|
||||
|
||||
updateImage("AutoFill");
|
||||
updateImage("ShowPopup");
|
||||
@ -80,12 +82,10 @@
|
||||
return document.getElementById(aName).checked;
|
||||
}
|
||||
|
||||
function setCheck(aName, aTruth)
|
||||
function setCheck(aName, aTruth, aDisabled)
|
||||
{
|
||||
if (aTruth == "true")
|
||||
document.getElementById(aName).setAttribute("checked", "true");
|
||||
else
|
||||
document.getElementById(aName).removeAttribute("checked");
|
||||
document.getElementById(aName).checked = (aTruth == "true");
|
||||
document.getElementById(aName).disabled = (aDisabled == "true");
|
||||
}
|
||||
|
||||
function updateImage(aImg)
|
||||
@ -107,7 +107,7 @@
|
||||
{
|
||||
var spChecked = document.getElementById("cbxShowPopup").checked;
|
||||
var showSearch = document.getElementById("cbxShowSearch");
|
||||
showSearch.disabled = !spChecked;
|
||||
showSearch.disabled = !spChecked || gShowSearchLocked;
|
||||
}
|
||||
|
||||
function doHelpButton() {
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Diego Biurrun <diego@biurrun.de>
|
||||
* Ian Neal <bugzilla@arlen.demon.co.uk>
|
||||
*
|
||||
* 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"),
|
||||
@ -59,7 +60,11 @@ function showACAdvanced()
|
||||
document.getElementById("browserUrlbarAutoFill").getAttribute("value"),
|
||||
document.getElementById("browserUrlbarShowPopup").getAttribute("value"),
|
||||
document.getElementById("browserUrlbarShowSearch").getAttribute("value"),
|
||||
document.getElementById("browserUrlbarMatchOnlyTyped").getAttribute("value"));
|
||||
document.getElementById("browserUrlbarMatchOnlyTyped").getAttribute("value"),
|
||||
document.getElementById("browserUrlbarAutoFill").getAttribute("disabled"),
|
||||
document.getElementById("browserUrlbarShowPopup").getAttribute("disabled"),
|
||||
document.getElementById("browserUrlbarShowSearch").getAttribute("disabled"),
|
||||
document.getElementById("browserUrlbarMatchOnlyTyped").getAttribute("disabled"));
|
||||
}
|
||||
|
||||
function receiveACPrefs(aAutoFill, aShowPopup, aShowSearch, aAutoType)
|
||||
|
@ -4,7 +4,7 @@
|
||||
<!DOCTYPE page SYSTEM "chrome://communicator/locale/pref/pref-smartupdate.dtd" >
|
||||
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-smartupdate.xul'); initUpdateNotifications();"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-smartupdate.xul');"
|
||||
headertitle="&lHeader;">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
@ -12,37 +12,16 @@
|
||||
var _elementIDs = ["XPInstallEnabled", "updateNotificationsEnabled",
|
||||
"updateFrequency"];
|
||||
|
||||
function initUpdateNotifications()
|
||||
function Startup()
|
||||
{
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
if (!prefs.getBoolPref("update_notifications.enabled"))
|
||||
{
|
||||
// disable frequency radiogroup
|
||||
var freqWeekly = document.getElementById("freqWeekly");
|
||||
var freqMonthly = document.getElementById("freqMonthly");
|
||||
freqWeekly.setAttribute("disabled", "true");
|
||||
freqMonthly.setAttribute("disabled", "true");
|
||||
}
|
||||
toggleFrequency();
|
||||
}
|
||||
|
||||
function toggleFrequency()
|
||||
{
|
||||
var enabled = document.getElementById("updateNotificationsEnabled");
|
||||
var freqWeekly = document.getElementById("freqWeekly");
|
||||
var freqMonthly = document.getElementById("freqMonthly");
|
||||
if (enabled.getAttribute("checked") == "true")
|
||||
{
|
||||
// enable frequency radiogroup
|
||||
freqWeekly.removeAttribute("disabled");
|
||||
freqMonthly.removeAttribute("disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
// disable frequency radiogroup
|
||||
freqWeekly.setAttribute("disabled", "true");
|
||||
freqMonthly.setAttribute("disabled", "true");
|
||||
}
|
||||
document.getElementById("updateFrequency").disabled =
|
||||
!document.getElementById("updateNotificationsEnabled").checked ||
|
||||
parent.hPrefWindow.getPrefIsLocked("update_notifications.provider.0.frequency");
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user