зеркало из https://github.com/mozilla/pjs.git
Start landing a new pref panel which will allow you to install themes in thunderbird. Still needs some testing, so I won't be turning this on.
This commit is contained in:
Родитель
1f6decb074
Коммит
2b172368b8
|
@ -0,0 +1,294 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Doron Rosenberg.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
* Blake Ross <blaker@netscape.com>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
|
||||
var gShowDescription = false;
|
||||
var gData;
|
||||
|
||||
try {
|
||||
var chromeRegistry = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService();
|
||||
if (chromeRegistry)
|
||||
chromeRegistry = chromeRegistry.QueryInterface(Components.interfaces.nsIXULChromeRegistry);
|
||||
}
|
||||
catch(e) {}
|
||||
|
||||
function Startup()
|
||||
{
|
||||
gData = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-themes.xul"];
|
||||
var list = document.getElementById( "skinsList" );
|
||||
if ("loaded" in gData && "themeIndex" in gData) {
|
||||
list.selectedIndex = gData.themeIndex;
|
||||
return;
|
||||
}
|
||||
gData.loaded = true;
|
||||
parent.hPrefWindow.registerOKCallbackFunc( applySkin );
|
||||
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
|
||||
var theme = null;
|
||||
try {
|
||||
theme = kPrefSvc.getComplexValue("general.skins.selectedSkin",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
} catch (e) {
|
||||
}
|
||||
var matches;
|
||||
for (var i = 0; i < list.childNodes.length; ++i) {
|
||||
var child = list.childNodes[i];
|
||||
var name = child.getAttribute("name");
|
||||
if (name) {
|
||||
if (!theme)
|
||||
matches = chromeRegistry.isSkinSelected(name, true) == Components.interfaces.nsIChromeRegistry.FULL;
|
||||
else
|
||||
matches = name == theme;
|
||||
if (matches) {
|
||||
list.selectItem(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var navbundle = document.getElementById("bundle_navigator");
|
||||
var showSkinsDescription = navbundle.getString("showskinsdescription");
|
||||
if( showSkinsDescription == "false" )
|
||||
{
|
||||
gShowDescription = false;
|
||||
var description = document.getElementById("description");
|
||||
while (description.hasChildNodes())
|
||||
description.removeChild(description.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
function applySkin()
|
||||
{
|
||||
var data = parent.hPrefWindow.wsm.dataManager.pageData["chrome://communicator/content/pref/pref-themes.xul"];
|
||||
if (data.name == null)
|
||||
return;
|
||||
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
|
||||
var theme = null;
|
||||
try {
|
||||
theme = kPrefSvc.getComplexValue("general.skins.selectedSkin",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (theme == data.name) return;
|
||||
|
||||
try {
|
||||
var reg = Components.classes["@mozilla.org/chrome/chrome-registry;1"].getService();
|
||||
if (reg)
|
||||
reg = reg.QueryInterface(Components.interfaces.nsIXULChromeRegistry);
|
||||
}
|
||||
catch(e) {}
|
||||
|
||||
var inUse = reg.isSkinSelected(data.name, true);
|
||||
if (!theme && inUse == Components.interfaces.nsIChromeRegistry.FULL) return;
|
||||
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
str.data = data.name;
|
||||
|
||||
kPrefSvc.setComplexValue("general.skins.selectedSkin", Components.interfaces.nsISupportsString, str);
|
||||
|
||||
// shut down quicklaunch so the next launch will have the new skin
|
||||
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
|
||||
appShell = appShell.QueryInterface(Components.interfaces.nsIAppShellService);
|
||||
try {
|
||||
appShell.nativeAppSupport.isServerMode = false;
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService();
|
||||
strBundleService = strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
|
||||
var navbundle = strBundleService.createBundle("chrome://navigator/locale/navigator.properties");
|
||||
var brandbundle = strBundleService.createBundle("chrome://global/locale/brand.properties");
|
||||
|
||||
if (promptService && navbundle && brandbundle) {
|
||||
var dialogTitle = navbundle.GetStringFromName("switchskinstitle");
|
||||
var brandName = brandbundle.GetStringFromName("brandShortName");
|
||||
var msg = navbundle.formatStringFromName("switchskins", [brandName], 1);
|
||||
promptService.alert(window, dialogTitle, msg);
|
||||
}
|
||||
}
|
||||
|
||||
function uninstallSkin()
|
||||
{
|
||||
var list = document.getElementById("skinsList");
|
||||
var selectedSkinItem = list.selectedItems[0];
|
||||
var skinName = selectedSkinItem.getAttribute("name");
|
||||
var inUse = chromeRegistry.isSkinSelected(skinName, true);
|
||||
chromeRegistry.uninstallSkin(skinName, true);
|
||||
if (inUse)
|
||||
chromeRegistry.refreshSkins();
|
||||
list.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function themeSelect()
|
||||
{
|
||||
var list = document.getElementById("skinsList");
|
||||
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
var prefbundle = document.getElementById("bundle_prefutilities");
|
||||
|
||||
var selectedItem = list.selectedItems.length ? list.selectedItems[0] : null;
|
||||
if (selectedItem && selectedItem.getAttribute("skin") == "true") {
|
||||
var themeName = selectedItem.getAttribute("displayName");
|
||||
var skinName = selectedItem.getAttribute("name");
|
||||
gData.name = skinName;
|
||||
gData.themeIndex = list.selectedIndex;
|
||||
|
||||
var oldTheme;
|
||||
try {
|
||||
oldTheme = !chromeRegistry.checkThemeVersion(skinName);
|
||||
}
|
||||
catch(e) {
|
||||
oldTheme = false;
|
||||
}
|
||||
|
||||
var nameField = document.getElementById("displayName");
|
||||
var author = document.getElementById("author");
|
||||
var image = document.getElementById("previewImage");
|
||||
var descText = document.createTextNode(selectedItem.getAttribute("description"));
|
||||
var description = document.getElementById("description");
|
||||
var uninstallButton = document.getElementById("uninstallSkin");
|
||||
var uninstallLabel = prefbundle.getString("uninstallThemePrefix");
|
||||
|
||||
while (description.hasChildNodes())
|
||||
description.removeChild(description.firstChild);
|
||||
|
||||
nameField.setAttribute("value", themeName);
|
||||
author.setAttribute("value", selectedItem.getAttribute("author"));
|
||||
image.setAttribute("src", selectedItem.getAttribute("image"));
|
||||
|
||||
// XXX - this sucks and should only be temporary.
|
||||
var selectedSkin = "";
|
||||
try {
|
||||
const kPrefSvcContractID = "@mozilla.org/preferences;1";
|
||||
const kPrefSvcIID = Components.interfaces.nsIPref;
|
||||
const kPrefSvc = Components.classes[kPrefSvcContractID].getService(kPrefSvcIID);
|
||||
selectedSkin = kPrefSvc.CopyCharPref("general.skins.selectedSkin");
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
if (!oldTheme) {
|
||||
if( gShowDescription )
|
||||
description.appendChild(descText);
|
||||
|
||||
var locType = selectedItem.getAttribute("loctype");
|
||||
uninstallButton.disabled = (selectedSkin == skinName) || (locType == "install");
|
||||
|
||||
uninstallLabel = uninstallLabel.replace(/%theme_name%/, themeName);
|
||||
uninstallButton.label = uninstallLabel;
|
||||
}
|
||||
else {
|
||||
var brandbundle = document.getElementById("bundle_brand");
|
||||
|
||||
uninstallLabel = uninstallLabel.replace(/%theme_name%/, themeName);
|
||||
uninstallButton.label = uninstallLabel;
|
||||
|
||||
uninstallButton.disabled = selectedSkin == skinName;
|
||||
|
||||
var newText = prefbundle.getString("oldTheme");
|
||||
newText = newText.replace(/%theme_name%/, themeName);
|
||||
|
||||
newText = newText.replace(/%brand%/g, brandbundle.getString("brandShortName"));
|
||||
|
||||
if( gShowDescription ) {
|
||||
descText = document.createTextNode(newText);
|
||||
description.appendChild(descText);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
uninstallButton.disabled = true;
|
||||
gData.name = null;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// functions to support installing of themes in thunderbird
|
||||
///////////////////////////////////////////////////////////////
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
function installSkin()
|
||||
{
|
||||
// 1) Prompt the user for the location of the theme to install. Eventually we'll support web locations too.
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, document.getElementById("installSkin").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK)
|
||||
{
|
||||
dump(fp.file.path + '\n');
|
||||
installTheme(fp.file.path);
|
||||
}
|
||||
}
|
||||
|
||||
// shamlessly rip code from the firbird theme site for installing themes given a url
|
||||
|
||||
// Functions needed for JAR install
|
||||
// Author: Alan Starr 20021210
|
||||
function installTheme(filePath)
|
||||
{
|
||||
var file = '';
|
||||
file = 'file:///' + escape(filePath.replace(/\\/g,'/'));
|
||||
InstallTrigger.installChrome(InstallTrigger.SKIN, file, getName(file));
|
||||
}
|
||||
|
||||
// Finds the name of the theme from the filename
|
||||
function getName(raw)
|
||||
{
|
||||
var grabFileStart = raw.lastIndexOf('/');
|
||||
var grabFileEnd = raw.lastIndexOf('.');
|
||||
if (grabFileStart >= grabFileEnd)
|
||||
return 'Invalid file name';
|
||||
else
|
||||
return raw.substring(grabFileStart + 1,grabFileEnd);
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape 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/NPL/
|
||||
|
||||
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 Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://communicator/skin/pref/pref.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY % themesDTD SYSTEM "chrome://communicator/locale/pref/pref-themes.dtd" >
|
||||
%themesDTD;
|
||||
<!ENTITY % regionDTD SYSTEM "chrome://global-region/locale/region.dtd" >
|
||||
%regionDTD;
|
||||
]>
|
||||
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
onload="parent.initPanel('chrome://communicator/content/pref/pref-themes.xul'); Startup()"
|
||||
headertitle="&lHeader;">
|
||||
|
||||
<stringbundle id="bundle_prefutilities"
|
||||
src="chrome://communicator/locale/pref/prefutilities.properties"/>
|
||||
<stringbundle id="bundle_brand"
|
||||
src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="bundle_navigator"
|
||||
src="chrome://navigator/locale/navigator.properties"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/pref/pref-themes.js"/>
|
||||
|
||||
<description>&skinIntro.label;</description>
|
||||
|
||||
<description>&installedThemes.label;</description>
|
||||
|
||||
<listbox id="skinsList" datasources="rdf:chrome"
|
||||
onselect="themeSelect();"
|
||||
ref="urn:mozilla:skin:root" rows="5">
|
||||
<template>
|
||||
<rule>
|
||||
<listitem uri="..." skin="true"
|
||||
label="rdf:http://www.mozilla.org/rdf/chrome#displayName"
|
||||
author="rdf:http://www.mozilla.org/rdf/chrome#author"
|
||||
displayName="rdf:http://www.mozilla.org/rdf/chrome#displayName"
|
||||
name="rdf:http://www.mozilla.org/rdf/chrome#name"
|
||||
description="rdf:http://www.mozilla.org/rdf/chrome#description"
|
||||
image="rdf:http://www.mozilla.org/rdf/chrome#image"
|
||||
loctype="rdf:http://www.mozilla.org/rdf/chrome#locType"/>
|
||||
</rule>
|
||||
</template>
|
||||
</listbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<hbox id="previewImageContainer" class="inset">
|
||||
<vbox flex="1">
|
||||
|
||||
<label class="header" id="displayName" value=""/>
|
||||
|
||||
<hbox>
|
||||
<label value="&author.label;"/>
|
||||
<label id="author"/>
|
||||
</hbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<hbox>
|
||||
<image style="margin-left: 4px; margin-bottom: 4px;" id="previewImage"/>
|
||||
<spring flex="1"/>
|
||||
<vbox>
|
||||
<spring flex="1"/>
|
||||
<button id="uninstallSkin" label="&uninstallSkin.label;" oncommand="uninstallSkin();"
|
||||
accesskey="&uninstallSkin.accesskey;"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
</hbox>
|
||||
|
||||
<label id="description"/>
|
||||
<separator class="thin"/>
|
||||
<description>&newThemeDescription.label;</description>
|
||||
<separator class="thin"/>
|
||||
<hbox align="start">
|
||||
<html:a class="themesLink" id="themesLink" href="&getNewThemesURL;"
|
||||
style="padding-left: 4px; display: block;">&getNewThemes.label;</html:a>
|
||||
<spring flex="1"/>
|
||||
<button id="installSkin" label="&installSkin.label;" accesskey="&installSkin.accesskey;" filepickertitle="&installPicker.title;" oncommand="installSkin();"/>
|
||||
</hbox>
|
||||
</page>
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
<!--LOCALIZATION NOTE : FILE Theme management prefs -->
|
||||
<!ENTITY lHeader "Themes">
|
||||
|
||||
<!ENTITY skinIntro.label "Selecting a new theme changes the look of buttons, dialog boxes, menus, toolbars, and other items. It does not change the way these items function.">
|
||||
<!ENTITY installedThemes.label "Theme to use:">
|
||||
|
||||
<!ENTITY selectSkin.label "Apply Theme">
|
||||
<!ENTITY selectSkin.accesskey "a">
|
||||
|
||||
<!ENTITY uninstallSkin.label "Uninstall Theme">
|
||||
<!ENTITY uninstallSkin.accesskey "U">
|
||||
|
||||
<!ENTITY general.label "General">
|
||||
<!ENTITY preview.label "Preview Image">
|
||||
<!ENTITY author.label "Author">
|
||||
|
||||
<!ENTITY newThemesCaption.label "New Themes">
|
||||
|
||||
<!ENTITY getNewThemes.label "Download new themes">
|
||||
|
||||
<!ENTITY newThemeDescription.label "In order to install a new theme for Mozilla Thunderbird, you must first download the theme using a browser." >
|
||||
<!ENTITY installSkin.label "Install Theme">
|
||||
<!ENTITY installSkin.accesskey "I">
|
||||
|
||||
<!ENTITY installPicker.title "Select a theme to install">
|
Загрузка…
Ссылка в новой задаче