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

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

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

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

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