1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-22 05:48:49 -05:00

options: UI for notification preferences

This commit is contained in:
foudfou 2011-11-06 16:28:39 +01:00
parent 8ec5451c94
commit 164c43453f
6 changed files with 104 additions and 14 deletions

2
TODO
View File

@ -1,7 +1,5 @@
=TODO=
* options: in mail_accounts, have serverTypes interact with excludedAccounts
* add "enable biff notification" option. And if true:
radio choice option with:

View File

@ -14,6 +14,7 @@ if ("undefined" == typeof(firetray)) {
var firetray = {};
};
const NOTIFICATION_CUSTOM_ICON = 3;
const TREEROW_ACCOUNT_OR_SERVER_TYPE_NAME = 0;
const TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED = 1;
const TREEROW_ACCOUNT_OR_SERVER_TYPE_ORDER = 2;
@ -25,7 +26,7 @@ firetray.UIOptions = {
onLoad: function() {
if(firetray.Handler.inMailApp) {
Cu.import("resource://firetray/FiretrayMessaging.jsm");
this.populateTreeAccountsOrServerTypes();
this.initMailControls();
} else {
this.hideElement("mail_tab");
}
@ -58,6 +59,55 @@ firetray.UIOptions = {
targetNode.hidden = true;
},
disableGroup: function(group,disableval) {
try {
for(var i=0; i< group.childNodes.length; i++)
group.childNodes[i].disabled = disableval;
} catch(e) {}
},
initMailControls: function() {
this.initNotificationSettings();
this.populateTreeAccountsOrServerTypes();
},
initNotificationSettings: function() {
let radioMailNotify = document.getElementById("radiogroup_mail_notification");
let prefMailNotification = firetray.Utils.prefService.getIntPref("mail_notification");
radioMailNotify.selectedIndex = prefMailNotification;
let customIconGroup = document.getElementById("custom_mail_icon");
this.disableGroup(customIconGroup,
(prefMailNotification !== NOTIFICATION_CUSTOM_ICON));
},
updateNotificationSettings: function() {
let radioMailNotify = document.getElementById("radiogroup_mail_notification");
let prefMailNotification =
firetray.Utils.prefService.setIntPref("mail_notification", radioMailNotify.selectedIndex);
let customIconGroup = document.getElementById("custom_mail_icon");
this.disableGroup(customIconGroup,
(radioMailNotify.selectedIndex !== NOTIFICATION_CUSTOM_ICON));
},
chooseMailIconFile: function() {
var filepath = document.getElementById("custom_mail_icon_filename");
this._chooseIconFile(filepath);
},
_chooseIconFile: function(iconFilename) {
const nsIFilePicker = Ci.nsIFilePicker;
var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
filePicker.init(window, "Select Icon", nsIFilePicker.modeOpen); // FIXME: i18n
filePicker.appendFilters(nsIFilePicker.filterImages);
var rv = filePicker.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
iconFilename.value = filePicker.file.path;
var prefpane = document.getElementById("pane1");
prefpane.userChangedValue(iconFilename);
}
},
/**
* should be called only for excludedAccounts
*/

View File

@ -11,12 +11,10 @@
<prefpane id="pane1" label="&pane1.title;">
<preferences>
<preference id="pref_bool_hides_on_close"
name="extensions.firetray.hides_on_close" type="bool"/>
<preference id="pref_bool_hides_on_minimize"
name="extensions.firetray.hides_on_minimize" type="bool"/>
<preference id="pref_string_mail_accounts"
name="extensions.firetray.mail_accounts" type="string"/>
<preference id="pref_bool_hides_on_close" name="extensions.firetray.hides_on_close" type="bool"/>
<preference id="pref_bool_hides_on_minimize" name="extensions.firetray.hides_on_minimize" type="bool"/>
<preference id="pref_string_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
<preference id="pref_string_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
</preferences>
@ -31,8 +29,7 @@
<tabpanel id="general_tabpanel">
<groupbox flex="1">
<caption label="&windows_behaviour;"
tooltiptext="&windows_behaviour.tooltip;" />
<caption label="&windows_behaviour;" tooltiptext="&windows_behaviour.tooltip;" />
<checkbox id="ui_hides_on_close" preference="pref_bool_hides_on_close"
label="&bool_hides_on_close.label;"
@ -48,12 +45,40 @@
<tabpanel id="input_tabpanel" />
<tabpanel id="mail_tabpanel">
<vbox align="left" flex="1" >
<!-- <label value="&mail_notification;" class="header" /> -->
<groupbox flex="1">
<caption label="&mail_notification;" />
<radiogroup id="radiogroup_mail_notification">
<radio id="radio_mail_icon1" label="&mail_notification_disabled;"
accesskey="&mail_notification_disabled.accesskey;"
oncommand="firetray.UIOptions.updateNotificationSettings()" />
<radio id="radio_mail_icon2" label="&mail_notification_unread_count;"
accesskey="&mail_notification_unread_count.accesskey;"
oncommand="firetray.UIOptions.updateNotificationSettings()" />
<radio id="radio_mail_icon3" label="&mail_notification_newmail_icon;"
accesskey="&mail_notification_newmail_icon.accesskey;"
oncommand="firetray.UIOptions.updateNotificationSettings()" />
<radio id="radio_mail_icon4" label="&mail_notification_custom_mail_icon;"
accesskey="&mail_notification_custom_mail_icon.accesskey;"
oncommand="firetray.UIOptions.updateNotificationSettings()" />
</radiogroup>
</groupbox>
<hbox id="custom_mail_icon" align="center" flex="1" >
<textbox id="custom_mail_icon_filename" preference="pref_string_custom_mail_icon"
hidden="FALSE" flex="1" />
<button id="custom_mail_icon_select" label="&choose;"
accesskey="&choose.accesskey;"
oncommand="firetray.UIOptions.chooseMailIconFile()" />
</hbox>
<groupbox flex="1">
<caption label="&unread_count_account_exceptions;"
tooltiptext="&unread_count_account_exceptions.tooltip;" />
<tree id="ui_tree_mail_accounts" flex="1" rows="10"
<tree id="ui_tree_mail_accounts" flex="1" rows="10" minwidth="300"
seltype="single" editable="true"
preference-editable="true"
preference="pref_string_mail_accounts"
@ -68,8 +93,8 @@
tooltiptext="&account_or_server_type_excluded.tooltip;"/>
<splitter class="tree-splitter" resizeafter="grow"/>
<treecol id="account_or_server_type_order" editable="true"
persist="width"
flex="1" hidden= "true" label="&account_or_server_type_order;"
persist="width" flex="1" hidden= "true"
label="&account_or_server_type_order;"
tooltiptext="&account_or_server_type_order.tooltip;"/>
</treecols>
<treechildren id="ui_mail_accounts" flex="1" />
@ -77,6 +102,7 @@
</groupbox>
</vbox>
</tabpanel>
</tabpanels>

View File

@ -15,6 +15,18 @@
<!ENTITY bool_hides_on_minimize.label "Minimize window hides to tray">
<!ENTITY bool_hides_on_minimize.accesskey "M">
<!ENTITY mail_notification "Mail notification">
<!ENTITY mail_notification_disabled "disabled">
<!ENTITY mail_notification_disabled.accesskey "D">
<!ENTITY mail_notification_unread_count "display unread messages count">
<!ENTITY mail_notification_unread_count.accesskey "U">
<!ENTITY mail_notification_newmail_icon "display newmail icon">
<!ENTITY mail_notification_newmail_icon.accesskey "N">
<!ENTITY mail_notification_custom_mail_icon "display custom icon">
<!ENTITY mail_notification_custom_mail_icon.accesskey "I">
<!ENTITY choose "Choose">
<!ENTITY choose.accesskey "O">
<!ENTITY unread_count_account_exceptions "Included accounts">
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

View File

@ -5,7 +5,11 @@ pref("extensions.{9533f794-00b4-4354-aa15-c2bbda6989f8}.description", "chrome://
pref("browser.tabs.warnOnClose", false);
// Extension prefs
pref("extensions.firetray.hides_on_close", true);
pref("extensions.firetray.hides_on_minimize", true);
pref("extensions.firetray.mail_notification", 1);
pref("extensions.firetray.custom_mail_icon", "");
// exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts
pref("extensions.firetray.mail_accounts", '{ "serverTypes": {"pop3":{"order":1,"excluded":false}, "imap":{"order":1,"excluded":false}, "movemail":{"order":2,"excluded":true}, "none":{"order":3,"excluded":false}, "rss":{"order":4,"excluded":true}, "nntp":{"order":5,"excluded":true}}, "excludedAccounts": [] }'); // JSON