Bug 428705 Migrate notifications prefpane r=IanN sr=Neil
This commit is contained in:
Родитель
88ea9c07c9
Коммит
eecfd94dca
|
@ -71,6 +71,11 @@
|
|||
prefpane="viewing_messages_pane"
|
||||
url="chrome://messenger/content/pref-viewing_messages.xul"
|
||||
helpTopic="mail_prefs_display"/>
|
||||
<treeitem id="notificationsItem"
|
||||
label="¬ifications.label;"
|
||||
prefpane="notifications_pane"
|
||||
url="chrome://messenger/content/pref-notifications.xul"
|
||||
helpTopic="mail_prefs_notifications"/>
|
||||
<treeitem id="junkItem"
|
||||
label="&junk.label;"
|
||||
prefpane="junk_pane"
|
||||
|
@ -115,7 +120,7 @@
|
|||
</treeitem>
|
||||
<treeitem>
|
||||
<treerow>
|
||||
<treecell url="chrome://messenger/content/pref-notifications.xul" label="¬ifications.label;"/>
|
||||
<treecell label="(Migrated: ¬ifications.label;)"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
<treeitem id="mailcomposepref">
|
||||
|
|
|
@ -1,7 +1,52 @@
|
|||
/* ***** 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 SeaMonkey project code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bruno Escherl <aqualon@aquachan.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 ***** */
|
||||
|
||||
// The contents of this file will be loaded into the scope of the object
|
||||
// <prefpane id="notifications_pane">!
|
||||
|
||||
const nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler;
|
||||
|
||||
var gSound = null;
|
||||
var gSoundUrlPref = null;
|
||||
var gIOService = null;
|
||||
var gFileHandler = null;
|
||||
|
||||
function Startup()
|
||||
{
|
||||
PlaySoundCheck();
|
||||
|
||||
// if we don't have the alert service, hide the pref UI for using alerts to notify on new mail
|
||||
// see bug #158711
|
||||
var newMailNotificationAlertUI = document.getElementById("newMailNotificationAlert");
|
||||
|
@ -11,62 +56,64 @@ function Startup()
|
|||
// show tray icon option currently available for Windows only
|
||||
var newMailNotificationTrayIconPref = document.getElementById("newMailNotificationTrayIcon");
|
||||
newMailNotificationTrayIconPref.hidden = !/^Win/.test(navigator.platform);
|
||||
|
||||
gIOService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
gFileHandler = gIOService.getProtocolHandler("file")
|
||||
.QueryInterface(nsIFileProtocolHandler);
|
||||
gSoundUrlPref = document.getElementById("mail.biff.play_sound.url");
|
||||
|
||||
PlaySoundCheck(document.getElementById("mail.biff.play_sound").value);
|
||||
}
|
||||
|
||||
function PlaySoundCheck()
|
||||
function PlaySoundCheck(aPlaySound)
|
||||
{
|
||||
var playSound = document.getElementById("newMailNotification").checked;
|
||||
var playSoundType = document.getElementById("newMailNotificationType");
|
||||
playSoundType.disabled = !playSound;
|
||||
let playSoundType = document.getElementById("mail.biff.play_sound.type").value;
|
||||
|
||||
var disableCustomUI = !(playSound && playSoundType.value == 1);
|
||||
var mailnewsSoundFileUrl = document.getElementById("mailnewsSoundFileUrl");
|
||||
|
||||
mailnewsSoundFileUrl.disabled = disableCustomUI
|
||||
document.getElementById("preview").disabled = disableCustomUI || (mailnewsSoundFileUrl.value == "");
|
||||
document.getElementById("browse").disabled = disableCustomUI;
|
||||
EnableElementById("newMailNotificationType", aPlaySound, false);
|
||||
EnableSoundURL(aPlaySound && (playSoundType == 1));
|
||||
}
|
||||
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
|
||||
function Browse()
|
||||
function EnableSoundURL(aEnable)
|
||||
{
|
||||
EnableElementById("mailnewsSoundFileUrl", aEnable, false);
|
||||
}
|
||||
|
||||
function SelectSound()
|
||||
{
|
||||
var prefBundle = document.getElementById("bundle_prefutilities");
|
||||
|
||||
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||
.createInstance(nsIFilePicker);
|
||||
.createInstance(nsIFilePicker);
|
||||
|
||||
// XXX todo, persist the last sound directory and pass it in
|
||||
// XXX todo filter by .wav
|
||||
fp.init(window, document.getElementById("browse").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
|
||||
fp.init(window, prefBundle.getString("choosesound"), nsIFilePicker.modeOpen);
|
||||
|
||||
if (gSoundUrlPref.value != "")
|
||||
fp.displayDirectory = gFileHandler.getFileFromURLSpec(gSoundUrlPref.value).parent;
|
||||
|
||||
fp.appendFilter(prefBundle.getString("SoundFiles"), "*.wav; *.wave");
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK) {
|
||||
var mailnewsSoundFileUrl = document.getElementById("mailnewsSoundFileUrl");
|
||||
// convert the nsILocalFile into a nsIFile url
|
||||
mailnewsSoundFileUrl.value = fp.fileURL.spec;
|
||||
}
|
||||
|
||||
document.getElementById("preview").disabled = (document.getElementById("mailnewsSoundFileUrl").value == "");
|
||||
if (fp.show() == nsIFilePicker.returnOK)
|
||||
gSoundUrlPref.value = fp.fileURL.spec;
|
||||
}
|
||||
|
||||
var gSound = null;
|
||||
function ReadSoundLocation(aElement)
|
||||
{
|
||||
aElement.value = gSoundUrlPref.value;
|
||||
if (aElement.value)
|
||||
aElement.file = gFileHandler.getFileFromURLSpec(aElement.value);
|
||||
}
|
||||
|
||||
function PreviewSound()
|
||||
{
|
||||
var soundURL = document.getElementById("mailnewsSoundFileUrl").value;
|
||||
|
||||
if (!gSound)
|
||||
gSound = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
|
||||
|
||||
if (soundURL.indexOf("file://") == -1) {
|
||||
// XXX todo see if we can create a nsIURL from the native file path
|
||||
// otherwise, play a system sound
|
||||
gSound.playSystemSound(soundURL);
|
||||
}
|
||||
else {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var url = ioService.newURI(soundURL, null, null);
|
||||
gSound.play(url)
|
||||
}
|
||||
gSound = Components.classes["@mozilla.org/sound;1"]
|
||||
.createInstance(Components.interfaces.nsISound);
|
||||
var soundURL = gSoundUrlPref.value;
|
||||
if (soundURL)
|
||||
gSound.play(gIOService.newURI(soundURL, null, null));
|
||||
else
|
||||
gSound.playSystemSound("_moz_mailbeep");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
Contributor(s):
|
||||
rcassin@supernova.org
|
||||
Seth Spitzer <sspitzer@netscape.com>
|
||||
Bruno Escherl <aqualon@aquachan.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"),
|
||||
|
@ -42,64 +43,101 @@
|
|||
<?xml-stylesheet href="chrome://messenger/skin/prefPanels.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
|
||||
<!DOCTYPE page SYSTEM "chrome://messenger/locale/pref-notifications.dtd">
|
||||
<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/pref-notifications.dtd">
|
||||
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="parent.initPanel('chrome://messenger/content/pref-notifications.xul');"
|
||||
headertitle="&pref.notifications.title;"
|
||||
id="mailNotificationsPage">
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<prefpane id="notifications_pane"
|
||||
label="&pref.notifications.title;"
|
||||
script="chrome://messenger/content/pref-notifications.js">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/pref-notifications.js"/>
|
||||
<preferences id="viewing_messages_preferences">
|
||||
<preference id="mail.biff.show_alert"
|
||||
name="mail.biff.show_alert"
|
||||
type="bool"/>
|
||||
<preference id="mail.biff.show_tray_icon"
|
||||
name="mail.biff.show_tray_icon"
|
||||
type="bool"/>
|
||||
<preference id="mail.biff.animate_dock_icon"
|
||||
name="mail.biff.animate_dock_icon"
|
||||
type="bool"/>
|
||||
<preference id="mail.biff.play_sound"
|
||||
name="mail.biff.play_sound"
|
||||
type="bool"
|
||||
onchange="PlaySoundCheck(this.value);"/>
|
||||
<preference id="mail.biff.play_sound.type"
|
||||
name="mail.biff.play_sound.type"
|
||||
type="int"
|
||||
onchange="EnableSoundURL(this.value == 1);"/>
|
||||
<preference id="mail.biff.play_sound.url"
|
||||
name="mail.biff.play_sound.url"
|
||||
type="string"/>
|
||||
</preferences>
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var _elementIDs = ["mailnewsSoundFileUrl", "newMailNotification",
|
||||
"newMailNotificationType", "newMailNotificationBounce",
|
||||
"newMailNotificationAlert", "newMailNotificationTrayIcon"];
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<groupbox id="newMessagesArrivePrefs">
|
||||
<caption label="¬ifications.caption;"/>
|
||||
<groupbox id="newMessagesArrivePrefs">
|
||||
<caption label="¬ifications.caption;"/>
|
||||
|
||||
<label value="&newMessagesArrive.label;"/>
|
||||
<vbox align="start">
|
||||
<checkbox id="newMailNotificationAlert" label="&showAnimatedAlert.label;"
|
||||
prefstring="mail.biff.show_alert"
|
||||
accesskey="&showAnimatedAlert.accesskey;" />
|
||||
<checkbox id="newMailNotificationTrayIcon" label="&showTrayIcon.label;"
|
||||
prefstring="mail.biff.show_tray_icon"
|
||||
accesskey="&showTrayIcon.accesskey;"
|
||||
hidden="true" />
|
||||
<checkbox id="newMailNotificationBounce" label="&bounceSystemDockIcon.label;"
|
||||
prefstring="mail.biff.animate_dock_icon"
|
||||
accesskey="&bounceSystemDockIcon.accesskey;"/>
|
||||
<checkbox id="newMailNotification" accesskey="&playSound.accesskey;"
|
||||
prefstring="mail.biff.play_sound" label="&playSound.label;"
|
||||
oncommand="PlaySoundCheck()"/>
|
||||
</vbox>
|
||||
|
||||
<hbox align="center" class="indent" id="newMailNotificationSoundSelectBox">
|
||||
<radiogroup id="newMailNotificationType" prefstring="mail.biff.play_sound.type"
|
||||
orient="vertical" aria-labelledby="newMailNotification">
|
||||
<radio id="system" class="iconic" value="0" oncommand="PlaySoundCheck()"
|
||||
label="&systemsound.label;" accesskey="&systemsound.accesskey;"/>
|
||||
<radio id="custom" class="iconic" value="1" oncommand="PlaySoundCheck()"
|
||||
label="&customsound.label;" accesskey="&customsound.accesskey;"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
<label value="&newMessagesArrive.label;"/>
|
||||
<vbox align="start">
|
||||
<checkbox id="newMailNotificationAlert"
|
||||
label="&showAnimatedAlert.label;"
|
||||
accesskey="&showAnimatedAlert.accesskey;"
|
||||
preference="mail.biff.show_alert"/>
|
||||
<checkbox id="newMailNotificationTrayIcon"
|
||||
label="&showTrayIcon.label;"
|
||||
accesskey="&showTrayIcon.accesskey;"
|
||||
preference="mail.biff.show_tray_icon"
|
||||
hidden="true"/>
|
||||
<checkbox id="newMailNotificationBounce"
|
||||
label="&bounceSystemDockIcon.label;"
|
||||
accesskey="&bounceSystemDockIcon.accesskey;"
|
||||
preference="mail.biff.animate_dock_icon"/>
|
||||
<checkbox id="newMailNotification"
|
||||
label="&playSound.label;"
|
||||
accesskey="&playSound.accesskey;"
|
||||
preference="mail.biff.play_sound"/>
|
||||
</vbox>
|
||||
|
||||
<hbox align="center" class="indent">
|
||||
<textbox readonly="true" flex="1" id="mailnewsSoundFileUrl" preftype="string"
|
||||
aria-labelledby="custom"
|
||||
prefstring="mail.biff.play_sound.url"/>
|
||||
<hbox align="center">
|
||||
<button id="browse" label="&browse.label;" filepickertitle="&browse.title;"
|
||||
accesskey="&browse.accesskey;" oncommand="Browse()"/>
|
||||
<button id="preview" label="&preview.label;"
|
||||
accesskey="&preview.accesskey;" oncommand="PreviewSound()"/>
|
||||
<hbox align="center" class="indent">
|
||||
<radiogroup id="newMailNotificationType"
|
||||
preference="mail.biff.play_sound.type"
|
||||
orient="vertical"
|
||||
aria-labelledby="newMailNotification">
|
||||
<radio id="system"
|
||||
class="iconic"
|
||||
value="0"
|
||||
label="&systemsound.label;"
|
||||
accesskey="&systemsound.accesskey;"/>
|
||||
<radio id="custom"
|
||||
class="iconic"
|
||||
value="1"
|
||||
label="&customsound.label;"
|
||||
accesskey="&customsound.accesskey;"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
</page>
|
||||
<hbox align="center" class="indent">
|
||||
<filefield id="mailnewsSoundFileUrl"
|
||||
flex="1"
|
||||
preference="mail.biff.play_sound.url"
|
||||
preference-editable="true"
|
||||
onsyncfrompreference="return document.getElementById('notifications_pane').ReadSoundLocation(this);"
|
||||
aria-labelledby="custom"/>
|
||||
<hbox align="center">
|
||||
<button id="browse"
|
||||
label="&browse.label;"
|
||||
filepickertitle="&browse.title;"
|
||||
accesskey="&browse.accesskey;"
|
||||
oncommand="SelectSound();">
|
||||
<observes element="mailnewsSoundFileUrl" attribute="disabled"/>
|
||||
</button>
|
||||
<button id="preview"
|
||||
label="&preview.label;"
|
||||
accesskey="&preview.accesskey;"
|
||||
oncommand="PreviewSound();">
|
||||
<observes element="mailnewsSoundFileUrl" attribute="disabled"/>
|
||||
</button>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</prefpane>
|
||||
</overlay>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<!ENTITY preview.accesskey "v">
|
||||
<!ENTITY systemsound.label "System New Mail Sound">
|
||||
<!ENTITY systemsound.accesskey "M">
|
||||
<!ENTITY customsound.label "Custom .wav file">
|
||||
<!ENTITY customsound.label "Custom sound file">
|
||||
<!ENTITY customsound.accesskey "C">
|
||||
<!ENTITY browse.label "Browse…">
|
||||
<!ENTITY browse.accesskey "B">
|
||||
|
|
|
@ -370,7 +370,7 @@ nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
|||
MAKESAMETYPEPREFTRANSFORM("mail.biff.animate_doc_icon", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound.type", Int),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound.url", String),
|
||||
MAKEPREFTRANSFORM("mail.biff.play_sound.url", 0, String, File),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.show_alert", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.show_tray_icon", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.check_all_imap_folders_for_new", Bool),
|
||||
|
|
Загрузка…
Ссылка в новой задаче