Bug 202388 runtime switch between system prefs and mozilla prefs.

sr=alecf.
This commit is contained in:
bolian.yin%sun.com 2006-05-17 02:35:46 +00:00
parent e670617eb7
commit 52dbc11d56
3 changed files with 56 additions and 6 deletions

View File

@ -52,7 +52,12 @@ function nsPrefWindow( frame_id )
this.cancelHandlers = [];
this.okHandlers = [];
// if there is a system pref switch
this.pagePrefChanged = false;
// the set of pages, which are updated after a system pref switch
this.pagePrefUpdated = [];
// set up window
this.onload();
}
@ -253,7 +258,10 @@ nsPrefWindow.prototype =
break;
}
if( value != this.getPref( preftype, itemObject.prefstring ) )
// the pref is not saved, if the pref value is not
// changed or the pref is locked.
if( !this.getPrefIsLocked(itemObject.prefstring) &&
(value != this.getPref( preftype, itemObject.prefstring)))
{
this.setPref( preftype, itemObject.prefstring, value );
}
@ -313,9 +321,15 @@ nsPrefWindow.prototype =
var header = document.getElementById("header");
header.setAttribute("title",
window.frames[this.contentFrame].document.documentElement.getAttribute("headertitle"));
if( !(aPageTag in this.wsm.dataManager.pageData) )
// update widgets states when it is first loaded, or there are
// system pref switch. (i.e., to refect the changed lock status).
if(!(aPageTag in this.wsm.dataManager.pageData) ||
(this.pagePrefChanged && (!(aPageTag in this.pagePrefUpdated))))
{
var prefElements = window.frames[this.contentFrame].document.getElementsByAttribute( "prefstring", "*" );
if (this.pagePrefChanged)
this.pagePrefUpdated[aPageTag] = [];
this.wsm.dataManager.pageData[aPageTag] = [];
for( var i = 0; i < prefElements.length; i++ )
{

View File

@ -35,11 +35,12 @@
<script type="application/x-javascript">
<![CDATA[
var panel = "chrome://communicator/content/pref/pref-advanced.xul";
var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress"];
var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress", "systemPrefCheck"];
function Startup() {
ftpCheck(false);
turboCheck();
sysPrefCheck();
}
function ftpCheck(setFocus) {
@ -132,6 +133,27 @@
nativeAppSupport.isServerMode = parent.isTurboEnabled;
}
}
function sysPrefCheck() {
var frame = document.getElementById("systemPrefs");
try {
var appShell = Components.classes["@mozilla.org/system-preference-service;1"].getService(Components.interfaces.nsIPrefBranch);
}
catch(e)
{
frame.setAttribute("hidden", "true");
return;
}
frame.setAttribute("hidden", "false");
}
function sysPrefUpdate() {
var checkObj = document.getElementById("systemPrefCheck");
var prefstring = checkObj.getAttribute( "prefstring" );
parent.hPrefWindow.pref.SetBoolPref(prefstring, checkObj.checked);
parent.hPrefWindow.pagePrefChanged = true;
parent.hPrefWindow.pagePrefUpdated = [];
}
]]>
</script>
@ -165,7 +187,16 @@
</vbox>
</vbox>
</groupbox>
<groupbox id="systemPrefs">
<caption id="systemPrefCaption" label="&systemPrefCaption.label;"/>
<vbox id="systemPrefBox" align="start">
<checkbox id="systemPrefCheck" label="&systemPrefCheck.label;" accesskey="&systemPrefCheck.accesskey;"
prefstring="config.use_system_prefs"
oncommand="sysPrefUpdate();"/>
<vbox class="indent" flex="1">
<description>&systemPrefDescription.label;</description>
</vbox>
</vbox>
</groupbox>
</page>

View File

@ -26,3 +26,8 @@
<!ENTITY jvm.name "Version">
<!ENTITY jvm.home "Path">
<!ENTITY systemPrefCaption.label "System Preferences">
<!ENTITY systemPrefCheck.label "Use Preferences from System">
<!ENTITY systemPrefCheck.accesskey "s">
<!ENTITY systemPrefDescription.label "Check this item to inherit preferences from the system. The system settings will override the &brandShortName; preferences">