Bug 444161 - Migrate SeaMonkey's Cache preferences to new pref window

r=iann sr=neil
This commit is contained in:
Manuel Reimer 2008-09-06 01:41:44 +01:00
Родитель 1125b39be1
Коммит bac30149ba
4 изменённых файлов: 186 добавлений и 129 удалений

Просмотреть файл

@ -1,80 +1,102 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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):
* Diego Biurrun <diego@biurrun.de>
* Manuel Reimer <Manuel.Reimer@gmx.de>
*
* 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
* 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 ***** */
const nsIFilePicker = Components.interfaces.nsIFilePicker;
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsIProperties = Components.interfaces.nsIProperties;
const kCacheParentDirPref = "browser.cache.disk.parent_directory";
var gFolderField;
var gCacheParentDirectory;
function Startup()
// because the cache is in kilobytes, and the UI is in megabytes.
function ReadCacheDiskCapacity()
{
var prefWindow = parent.hPrefWindow;
gFolderField = document.getElementById("browserCacheDiskCacheFolder");
var pref = document.getElementById("browser.cache.disk.capacity");
return pref.value >> 10;
}
gCacheParentDirectory = prefWindow.getPref("localfile", kCacheParentDirPref);
if (gCacheParentDirectory == "!/!ERROR_UNDEFINED_PREF!/!")
function WriteCacheDiskCapacity(aField)
{
return aField.value << 10;
}
function ReadCacheFolder(aField)
{
var pref = document.getElementById("browser.cache.disk.parent_directory");
var file = pref.value;
if (!file)
{
try
{
// no disk cache folder pref set; default to profile directory
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(nsIProperties);
.getService(Components.interfaces.nsIProperties);
if (dirSvc.has("ProfLD"))
gCacheParentDirectory = dirSvc.get("ProfLD", nsILocalFile);
file = dirSvc.get("ProfLD", Components.interfaces.nsILocalFile);
else
gCacheParentDirectory = dirSvc.get("ProfD", nsILocalFile);
}
catch (ex)
{
gCacheParentDirectory = null;
file = dirSvc.get("ProfD", Components.interfaces.nsILocalFile);
}
catch (ex) {}
}
// if both pref and dir svc fail leave this field blank else show directory
if (gCacheParentDirectory)
gFolderField.value = (/Mac/.test(navigator.platform)) ? gCacheParentDirectory.leafName : gCacheParentDirectory.path;
document.getElementById("chooseDiskCacheFolder").disabled =
prefWindow.getPrefIsLocked(kCacheParentDirPref);
if (file)
{
aField.file = file;
aField.label = (/Mac/.test(navigator.platform)) ? file.leafName : file.path;
}
}
function prefCacheSelectFolder()
function CacheSelectFolder()
{
var pref = document.getElementById("browser.cache.disk.parent_directory");
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
var prefWindow = parent.hPrefWindow;
var prefutilitiesBundle = document.getElementById("bundle_prefutilities");
var title = prefutilitiesBundle.getString("cachefolder");
fp.init(window, title, nsIFilePicker.modeGetFolder);
fp.displayDirectory = gCacheParentDirectory;
fp.displayDirectory = pref.value;
fp.appendFilters(nsIFilePicker.filterAll);
var ret = fp.show();
if (ret == nsIFilePicker.returnOK) {
var localFile = fp.file.QueryInterface(nsILocalFile);
prefWindow.setPref("localfile", kCacheParentDirPref, localFile);
gFolderField.value = (/Mac/.test(navigator.platform)) ? fp.file.leafName : fp.file.path;
gCacheParentDirectory = fp.file;
}
if (fp.show() == nsIFilePicker.returnOK)
pref.value = fp.file;
}
function prefClearCache(aType)
function ClearDiskAndMemCache()
{
var classID = Components.classes["@mozilla.org/network/cache-service;1"];
var cacheService = classID.getService(Components.interfaces.nsICacheService);
cacheService.evictEntries(aType);
}
function prefClearDiskAndMemCache()
{
prefClearCache(Components.interfaces.nsICache.STORE_ANYWHERE);
Components.classes["@mozilla.org/network/cache-service;1"]
.getService(Components.interfaces.nsICacheService)
.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
}

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -22,6 +22,7 @@
Contributor(s):
Diego Biurrun <diego@biurrun.de>
Manuel Reimer <Manuel.Reimer@gmx.de>
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"),
@ -38,88 +39,121 @@
***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE page [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!ENTITY % prefCacheDTD SYSTEM "chrome://communicator/locale/pref/pref-cache.dtd" >
<!ENTITY % prefCacheDTD SYSTEM "chrome://communicator/locale/pref/pref-cache.dtd">
%prefCacheDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://communicator/content/pref/pref-cache.xul');"
headertitle="&pref.cache.title;">
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="cache_pane"
label="&pref.cache.title;"
script="chrome://communicator/content/pref/pref-cache.js">
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["browserCacheDiskCache", "browserCacheCheckDocFrequency", "enablePrefetch"];
function GetFields(pageData) {
// because the cache is in kilobytes, and the UI is in megabytes.
pageData.browserCacheDiskCache.value <<= 10;
return null;
}
function SetFields(pageData) {
pageData.browserCacheDiskCache.value >>= 10;
return true;
}
]]>
</script>
<stringbundle id="bundle_prefutilities"
src="chrome://communicator/locale/pref/prefutilities.properties"/>
<script type="application/x-javascript" src="chrome://communicator/content/pref/pref-cache.js"/>
<preferences>
<preference id="browser.cache.disk.capacity"
name="browser.cache.disk.capacity"
type="int"/>
<preference id="pref.advanced.cache.disable_button.clear_disk"
name="pref.advanced.cache.disable_button.clear_disk"
type="bool"/>
<preference id="browser.cache.check_doc_frequency"
name="browser.cache.check_doc_frequency"
type="int"/>
<preference id="network.prefetch-next"
name="network.prefetch-next"
type="bool"/>
<preference id="browser.cache.disk.parent_directory"
name="browser.cache.disk.parent_directory"
type="file"/>
</preferences>
<groupbox>
<caption label="&pref.cache.caption;"/>
<description>&cachePara;</description>
<stringbundle id="bundle_prefutilities"
src="chrome://communicator/locale/pref/prefutilities.properties"/>
<hbox align="center">
<label value="&diskCache.label;" accesskey="&diskCache.accesskey;" control="browserCacheDiskCache"/>
<textbox id="browserCacheDiskCache" size="5" preftype="int"
prefstring="browser.cache.disk.capacity" prefattribute="value"/>
<label value="&mbytes;"/>
<button label="&clearDiskCache.label;" accesskey="&clearDiskCache.accesskey;"
oncommand="prefClearDiskAndMemCache();"
id="clearDiskCache"
prefstring="pref.advanced.cache.disable_button.clear_disk"/>
</hbox>
<groupbox>
<caption label="&pref.cache.caption;"/>
<description>&cachePara;</description>
<vbox>
<label value="&diskCacheFolder.label;"/>
<hbox align="center">
<textbox id="browserCacheDiskCacheFolder" flex="1" readonly="true" class="uri-element"/>
<button label="&chooseDiskCacheFolder.label;" accesskey="&chooseDiskCacheFolder.accesskey;"
oncommand="prefCacheSelectFolder();" id="chooseDiskCacheFolder"/>
<label id="browserCacheDiskCacheBefore"
value="&diskCache.label;"
accesskey="&diskCache.accesskey;"
control="browserCacheDiskCache"/>
<textbox id="browserCacheDiskCache"
size="5"
type="number"
aria-labelledby="browserCacheDiskCacheBefore browserCacheDiskCache browserCacheDiskCacheAfter"
preference="browser.cache.disk.capacity"
onsyncfrompreference="return document.getElementById('cache_pane').ReadCacheDiskCapacity();"
onsynctopreference="return document.getElementById('cache_pane').WriteCacheDiskCapacity(this);"/>
<label id="browserCacheDiskCacheAfter"
value="&mbytes;"/>
<button label="&clearDiskCache.label;"
accesskey="&clearDiskCache.accesskey;"
oncommand="ClearDiskAndMemCache();"
id="clearDiskCache"
preference="pref.advanced.cache.disable_button.clear_disk"/>
</hbox>
</vbox>
<description>&diskCacheFolderExplanation;</description>
<separator class="thin"/>
<description>&docCache;</description>
<hbox align="start">
<radiogroup id="browserCacheCheckDocFrequency" orient="horizontal" prefstring="browser.cache.check_doc_frequency">
<vbox flex="1">
<radio value="1" label="&everyTimeRadio.label;" accesskey="&everyTimeRadio.accesskey;"/>
<radio value="3" label="&autoRadio.label;" accesskey="&autoRadio.accesskey;"/>
</vbox>
<vbox flex="1">
<radio value="0" label="&oncePsessionRadio.label;" accesskey="&oncePsessionRadio.accesskey;"/>
<radio value="2" label="&neverRadio.label;" accesskey="&neverRadio.accesskey;"/>
</vbox>
</radiogroup>
</hbox>
<vbox>
<label value="&diskCacheFolder.label;"/>
<hbox align="center">
<filefield id="browserCacheDiskCacheFolder"
flex="1"
preference="browser.cache.disk.parent_directory"
preference-editable="true"
onsyncfrompreference="return document.getElementById('cache_pane').ReadCacheFolder(this);"/>
<button label="&chooseDiskCacheFolder.label;"
accesskey="&chooseDiskCacheFolder.accesskey;"
oncommand="CacheSelectFolder();"
id="chooseDiskCacheFolder">
<observes element="browserCacheDiskCacheFolder"
attribute="disabled"/>
</button>
</hbox>
</vbox>
<description>&diskCacheFolderExplanation;</description>
</groupbox>
<separator class="thin"/>
<groupbox id="prefetch">
<caption id="prefetchLabel" label="&prefetchTitle.label;"/>
<vbox id="prefetchBox" align="start">
<checkbox id="enablePrefetch" label="&enablePrefetch.label;" accesskey="&enablePrefetch.accesskey;"
prefstring="network.prefetch-next" />
<!-- <vbox class="indent" flex="1">
<description>&prefetchDesc.label;</description>
</vbox> -->
</vbox>
</groupbox>
</page>
<description>&docCache;</description>
<hbox align="start">
<radiogroup id="browserCacheCheckDocFrequency"
orient="horizontal"
preference="browser.cache.check_doc_frequency">
<vbox flex="1">
<radio value="1"
label="&everyTimeRadio.label;"
accesskey="&everyTimeRadio.accesskey;"/>
<radio value="3"
label="&autoRadio.label;"
accesskey="&autoRadio.accesskey;"/>
</vbox>
<vbox flex="1">
<radio value="0"
label="&oncePsessionRadio.label;"
accesskey="&oncePsessionRadio.accesskey;"/>
<radio value="2"
label="&neverRadio.label;"
accesskey="&neverRadio.accesskey;"/>
</vbox>
</radiogroup>
</hbox>
</groupbox>
<groupbox id="prefetch">
<caption id="prefetchLabel" label="&prefetchTitle.label;"/>
<vbox id="prefetchBox" align="start">
<checkbox id="enablePrefetch"
label="&enablePrefetch.label;"
accesskey="&enablePrefetch.accesskey;"
preference="network.prefetch-next"/>
</vbox>
</groupbox>
</prefpane>
</overlay>

Просмотреть файл

@ -206,10 +206,11 @@
<treeitem id="keynavItem" label="&keynav.label;"
prefpane="keynav_pane" helpTopic="advanced_pref_keyboard_nav"
url="chrome://communicator/content/pref/pref-keynav.xul"/>
<!--
<treeitem label="&cache.label;"
<treeitem id="cacheItem"
label="&cache.label;"
prefpane="cache_pane"
helpTopic="advanced_pref_cache"
url="chrome://communicator/content/pref/pref-cache.xul"/>
-->
<treeitem id="proxiesItem"
label="&proxies.label;"
prefpane="proxies_pane"

Просмотреть файл

@ -162,7 +162,7 @@
</treeitem>
<treeitem>
<treerow>
<treecell url="chrome://communicator/content/pref/pref-cache.xul" label="&cache.label;"/>
<treecell label="(Migrated: &cache.label;)"/>
</treerow>
</treeitem>
<treeitem id="proxiesItem">