1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-11 03:25:07 -05:00

options UI: use boradcaster for disabling UI when notification disabled

This commit is contained in:
foudfou 2011-11-24 21:27:23 +01:00
parent 9718b72232
commit 052d813502
2 changed files with 22 additions and 22 deletions

View File

@ -69,9 +69,9 @@ firetray.UIOptions = {
},
initMailControls: function() {
this.initNotificationSettings();
this.populateExcludedFoldersList();
this.populateTreeAccountsOrServerTypes();
this.initNotificationSettings();
},
initNotificationSettings: function() {
@ -100,21 +100,13 @@ firetray.UIOptions = {
let isNotificationDisabled = (notificationSetting === NOTIFICATION_DISABLED);
// update UI
// NOTE: groupbox and caption don't have a 'disabled' attribute !!
let excludedFoldersList = document.getElementById('excluded_folders_list');
excludedFoldersList.disabled = isNotificationDisabled;
let folderGroupboxCaption = document.getElementById('unread_count_folder_exceptions_caption_label');
folderGroupboxCaption.disabled = isNotificationDisabled;
this.disableGroup(excludedFoldersList, isNotificationDisabled); // disable listitems also
let mailAccountsTree = document.getElementById('ui_tree_mail_accounts');
mailAccountsTree.disabled = isNotificationDisabled;
let accountsGroupboxCaption = document.getElementById('unread_count_account_exceptions_caption_label');
accountsGroupboxCaption.disabled = isNotificationDisabled;
if (isNotificationDisabled)
if (isNotificationDisabled) {
document.getElementById("broadcaster-notification-disabled")
.setAttribute("disabled", "true"); // UI update
firetray.Messaging.disable();
else {
} else {
document.getElementById("broadcaster-notification-disabled")
.removeAttribute("disabled"); // UI update (enables!)
firetray.Messaging.enable();
firetray.Messaging.updateUnreadMsgCount();
}
@ -148,8 +140,8 @@ firetray.UIOptions = {
.getIntPref("excluded_folders_flags");
for(let folderType in FLDRS_UNINTERESTING) {
let localizedFolderType = this.strings.getString(folderType);
let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
item.setAttribute("observes", "broadcaster-notification-disabled");
LOG("folder: "+folderType);
if (FLDRS_UNINTERESTING[folderType] & prefExcludedFoldersFlags)
excludedFoldersList.addItemToSelection(item); // doesn't trigger onselect

View File

@ -12,6 +12,10 @@
<stringbundle id="firetray-options-strings" src="chrome://firetray/locale/options.properties"/>
</stringbundleset>
<broadcasterset>
<broadcaster id="broadcaster-notification-disabled" disabled="false" />
</broadcasterset>
<prefpane id="pane1" label="&pane1.title;">
<preferences>
@ -22,7 +26,6 @@
<preference id="pref_string_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
</preferences>
<tabbox>
<tabs>
<tab label="&general_options;"/>
@ -88,31 +91,36 @@
</radiogroup>
</groupbox>
<!-- NOTE: groupbox and caption don't have a 'disabled' attribute !! -->
<groupbox id="unread_count_folder_exceptions" flex="1">
<!-- label extracted from caption so we can disable it -->
<caption tooltiptext="&unread_count_folder_exceptions.tooltip;">
<label id="unread_count_folder_exceptions_caption_label"
value="&unread_count_folder_exceptions.label;" />
value="&unread_count_folder_exceptions.label;"
observes="broadcaster-notification-disabled" />
</caption>
<listbox id="excluded_folders_list" rows="7" flex="1" seltype="multiple"
tooltiptext="&excluded_folders_list.tooltip;"
onselect="firetray.UIOptions.updateExcludedFoldersPref()"/>
onselect="firetray.UIOptions.updateExcludedFoldersPref()"
observes="broadcaster-notification-disabled" />
</groupbox>
<groupbox id="unread_count_account_exceptions" flex="1">
<!-- label extracted from caption so we can disable it -->
<caption tooltiptext="&unread_count_account_exceptions.tooltip;">
<label id="unread_count_account_exceptions_caption_label"
value="&unread_count_account_exceptions.label;" />
value="&unread_count_account_exceptions.label;"
observes="broadcaster-notification-disabled" />
</caption>
<tree id="ui_tree_mail_accounts" flex="1" rows="10" minwidth="400"
seltype="single" editable="true" hidecolumnpicker="false"
preference-editable="true"
preference="pref_string_mail_accounts"
onsynctopreference="return firetray.UIOptions.saveTreeAccountsOrServerTypes();">
onsynctopreference="return
firetray.UIOptions.saveTreeAccountsOrServerTypes();"
observes="broadcaster-notification-disabled">
<treecols>
<treecol id="account_or_server_type_name" editable="false" flex="2"
persist="width" primary="true" label="&account_or_server_type_name;"