Bug 342560: preference panel for tags (SM 1.1s band-aid patch; trunk version to stay in sync); r=IanN, sr=neil

This commit is contained in:
mnyromyr%tprac.de 2006-08-10 21:24:47 +00:00
Родитель 24e2648fe2
Коммит cab0995d08
5 изменённых файлов: 134 добавлений и 142 удалений

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

@ -93,7 +93,7 @@
</treeitem>
<treeitem>
<treerow>
<treecell url="chrome://messenger/content/pref-labels.xul" label="&labels.label;"/>
<treecell url="chrome://messenger/content/pref-labels.xul" label="&tags.label;"/>
</treerow>
</treeitem>
<treeitem>

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

@ -21,6 +21,7 @@
* Contributor(s):
* Sean Su <ssu@netscape.com>
* Ian Neal <bugzilla@arlen.demon.co.uk>
* Karsten Düsterloh <mnyromyr@tprac.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
@ -36,27 +37,105 @@
*
* ***** END LICENSE BLOCK ***** */
/* Function to restore pref values to application defaults */
function restoreColorAndDescriptionToDefaults()
var gTagListBox = null;
function Startup()
{
var pickerColor;
var labelDescription;
gTagListBox = document.getElementById('tagList');
BuildTagList();
}
function GetCSSValue(aElement, aProperty)
{
return getComputedStyle(aElement, null).getPropertyCSSValue(aProperty).cssText;
}
// appends the tag to the tag list box
function AppendTagItem(aTagName, aKey, aColor)
{
var item = gTagListBox.appendItem(aTagName, aKey);
item.style.color = aColor;
var listBackColor = GetCSSValue(gTagListBox, "background-color");
var itemForeColor = GetCSSValue(item, "color");
if (listBackColor == itemForeColor)
item.style.color = GetCSSValue(gTagListBox, "color");
return item;
}
function BuildTagList()
{
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService);
var allTags = tagService.tagEnumerator;
var allKeys = tagService.keyEnumerator;
while (allTags.hasMore())
{
var key = allKeys.getNext();
AppendTagItem(allTags.getNext(), key, tagService.getColorForKey(key));
}
}
function DeleteTag()
{
var tagItemToRemove = gTagListBox.getSelectedItem();
var index = gTagListBox.selectedIndex;
if (index >= 0)
{
var itemToRemove = gTagListBox.getItemAtIndex(index);
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService);
tagService.deleteKey(itemToRemove.value);
gTagListBox.removeItemAt(index);
var numItemsInListBox = gTagListBox.getRowCount();
gTagListBox.selectedIndex = index < numItemsInListBox ? index : numItemsInListBox - 1;
}
}
function AddTag()
{
var args = {result: "", okCallback: AddTagCallback};
var dialog = window.openDialog("chrome://messenger/content/newTagDialog.xul",
"",
"chrome,titlebar,modal",
args);
}
function AddTagCallback(aName, aColor)
{
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService);
tagService.addTag(aName, aColor);
var item = AppendTagItem(aName, tagService.getKeyForTag(aName), aColor);
var tagListBox = document.getElementById('tagList');
tagListBox.ensureElementIsVisible(item);
tagListBox.selectItem(item);
tagListBox.focus();
}
function RestoreDefaults()
{
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService);
// remove all existing labels
var allKeys = tagService.keyEnumerator;
while (allKeys.hasMore())
{
tagService.deleteKey(allKeys.getNext());
gTagListBox.removeItemAt(0);
}
// add default items
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefDescription = prefService.getDefaultBranch("mailnews.labels.description.");
var prefColor = prefService.getDefaultBranch("mailnews.labels.color.");
/* there are only 5 labels */
for (var i = 1; i <= 5; i++)
var prefColor = prefService.getDefaultBranch("mailnews.labels.color.");
for (var i = 1; i <= 5; ++i)
{
/* set the default description from prefs */
labelDescription = document.getElementById("label" + i + "TextBox");
if (!labelDescription.disabled)
labelDescription.value = prefDescription.getComplexValue(i, Components.interfaces.nsIPrefLocalizedString).data;
/* set the default color from prefs */
pickerColor = document.getElementById("label" + i + "Color");
if (!pickerColor.disabled)
pickerColor.color = prefColor.getCharPref(i);
// mimic nsMsgTagService::MigrateLabelsToTags() and create default tags from
// the former label defaults
var tag = prefDescription.getComplexValue(i, Components.interfaces.nsIPrefLocalizedString).data;
var color = prefColor.getCharPref(i);
tagService.addTagForKey("$label" + i, tag, color);
}
BuildTagList();
}

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

@ -23,6 +23,7 @@
- Contributor(s):
- Sean Su <ssu@netscape.com>
- Ian Neal <bugzilla@arlen.demon.co.uk>
- Karsten Düsterloh <mnyromyr@tprac.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
@ -48,108 +49,40 @@
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="parent.initPanel('chrome://messenger/content/pref-labels.xul');"
headertitle="&pref.labels.title;">
<popupset id="aTooltipSet"/>
headertitle="&pref.tags.title;">
<script type="application/x-javascript" src="chrome://messenger/content/pref-labels.js"/>
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["label1TextBox", "label1Color", "label2TextBox", "label2Color", "label3TextBox", "label3Color", "label4TextBox", "label4Color", "label5TextBox", "label5Color"];
var _elementIDs = ["addTag", "deleteTag", "restoreDefaults"];
]]>
</script>
<script type="application/x-javascript" src="chrome://messenger/content/pref-labels.js"/>
<groupbox>
<caption label="&labelsSettings.caption;"/>
<description>&displayText.label;</description>
<!-- label color: 1 (default red) -->
<hbox class="indent" align="center">
<textbox
id="label1TextBox"
pref="true"
preftype="localizedstring"
prefstring="mailnews.labels.description.1"
prefattribute="value"/>
<colorpicker
class="small-margin"
type="button"
palettename="standard"
id="label1Color"
prefstring="mailnews.labels.color.1"/>
</hbox>
<!-- label color: 2 (default orange) -->
<hbox class="indent" align="center">
<textbox
id="label2TextBox"
pref="true"
preftype="localizedstring"
prefstring="mailnews.labels.description.2"
prefattribute="value"/>
<colorpicker
class="small-margin"
type="button"
palettename="standard"
id="label2Color"
prefstring="mailnews.labels.color.2"/>
</hbox>
<!-- label color: 3 (default green) -->
<hbox class="indent" align="center">
<textbox
id="label3TextBox"
pref="true"
preftype="localizedstring"
prefstring="mailnews.labels.description.3"
prefattribute="value"/>
<colorpicker
class="small-margin"
type="button"
palettename="standard"
id="label3Color"
prefstring="mailnews.labels.color.3"/>
</hbox>
<!-- label color: 4 (default blue) -->
<hbox class="indent" align="center">
<textbox
id="label4TextBox"
pref="true"
preftype="localizedstring"
prefstring="mailnews.labels.description.4"
prefattribute="value"/>
<colorpicker
class="small-margin"
type="button"
palettename="standard"
id="label4Color"
prefstring="mailnews.labels.color.4"/>
</hbox>
<!-- label color: 5 (default purple) -->
<hbox class="indent" align="center">
<textbox
id="label5TextBox"
pref="true"
preftype="localizedstring"
prefstring="mailnews.labels.description.5"
prefattribute="value"/>
<colorpicker
class="small-margin"
type="button"
palettename="standard"
id="label5Color"
prefstring="mailnews.labels.color.5"/>
</hbox>
<hbox pack="end">
<button label="&restoreDefaults.label;" accesskey="&restoreDefaults.accesskey;"
oncommand="restoreColorAndDescriptionToDefaults();">
</button>
</hbox>
<groupbox flex="1">
<caption label="&pref.tags.caption;"/>
<description>&pref.tags.description;</description>
<hbox flex="1">
<listbox id="tagList" flex="1"/>
<vbox>
<button id="addTag"
label="&addTagButton.label;"
accesskey="&addTagButton.accesskey;"
prefstring="pref.tags.disable_button.add"
oncommand="AddTag();"/>
<button id="deleteTag"
label="&deleteTagButton.label;"
accesskey="&deleteTagButton.accesskey;"
prefstring="pref.tags.disable_button.delete"
oncommand="DeleteTag();"/>
<spacer flex="1"/>
<button id="restoreDefaults"
label="&restoreDefaults.label;"
accesskey="&restoreDefaults.accesskey;"
prefstring="pref.tags.disable_button.restore"
oncommand="RestoreDefaults();"/>
</vbox>
</hbox>
</groupbox>
</page>

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

@ -1,24 +0,0 @@
<!-- These are added to the Advanced - Scripts & Plug-ins panel -->
<!ENTITY enbJsCheckMailNews.label "Mail &amp; Newsgroups">
<!ENTITY enbJsCheckMailNews.accesskey "M">
<!ENTITY enbPluginCheckMailNews.label "Mail &amp; Newsgroups">
<!ENTITY enbPluginCheckMailNews.accesskey "a">
<!-- These are added to the Window menu -->
<!ENTITY mail.label "Mail &amp; Newsgroups">
<!ENTITY mail.accesskey "M">
<!ENTITY addressbook.label "Address Book">
<!ENTITY addressbook.accesskey "A">
<!-- These are added to Preferences dialog -->
<!ENTITY viewingMessages.label "Message Display">
<!ENTITY notifications.label "Notifications">
<!ENTITY address.label "Addressing">
<!ENTITY composingMessages.label "Composition">
<!ENTITY format.label "Send Format">
<!ENTITY return.label "Return Receipts">
<!ENTITY disk.label "Disk Space">
<!ENTITY junk.label "Junk Mail">
<!ENTITY labels.label "Labels">
<!ENTITY characterEncoding.label "Character Encoding">
<!ENTITY offline.label "Offline &amp; Disk Space">

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

@ -20,6 +20,7 @@
-
- Contributor(s):
- Sean Su <ssu@netscape.com>
- Karsten Düsterloh <mnyromyr@tprac.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
@ -35,9 +36,12 @@
-
- ***** END LICENSE BLOCK ***** -->
<!ENTITY pref.labels.title "Labels">
<!ENTITY labelsSettings.caption "Customize Labels">
<!ENTITY displayText.label "Labels can be used to categorize and prioritize your messages. Modify the appearance of Labels using the settings below.">
<!ENTITY pref.tags.title "Tags">
<!ENTITY pref.tags.caption "Customize Tags">
<!ENTITY pref.tags.description "Tags can be used to categorize and prioritize your messages.">
<!ENTITY addTagButton.label "Add">
<!ENTITY addTagButton.accesskey "A">
<!ENTITY deleteTagButton.label "Delete">
<!ENTITY deleteTagButton.accesskey "D">
<!ENTITY restoreDefaults.label "Restore Defaults">
<!ENTITY restoreDefaults.accesskey "R">