Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* fix pref UI: disable themed icon names if not selected

* refactoring
  • Loading branch information...
commit 1f480af971b98b0eaac53d8dc8fdedead073abc0 1 parent e679619
foudfou authored
50 src/chrome/content/options.js
View
@@ -67,6 +67,15 @@ var firetrayUIOptions = {
children[i].disabled = disableval;
} catch(e) {}
},
+ disableNChildren: function(group, nth, disableval) {
+ try {
+ let children = group.childNodes;
+ if (nth>children.length) throw new RangeError();
+ for (let i=0; i<nth ; ++i) {
+ children[i].disabled = disableval;
+ }
+ } catch(e) {}
+ },
disableElementsRecursive: function(group, disableval) {
let descendants = firetray.Utils.XPath(group, 'descendant::*');
@@ -144,16 +153,23 @@ var firetrayUIOptions = {
},
disableIconTypeMaybe: function(appIconType) {
- let customIconGroup = document.getElementById("custom_app_icon");
- this.disableChildren(customIconGroup,
+ let appIconCustomGroup = document.getElementById("app_icon_custom");
+ this.disableChildren(appIconCustomGroup,
(appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
+
+ let appIconDefaultGroup = document.getElementById("app_icon_default");
+ this.disableNChildren(appIconDefaultGroup, 2,
+ (appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_THEMED));
},
initMailControls: function() {
this.populateExcludedFoldersList();
this.populateTreeAccountsOrServerTypes();
+
this.initMessageCountSettings();
this.initNotificationSettings();
+
+ this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
},
initNotificationSettings: function() {
@@ -170,9 +186,7 @@ var firetrayUIOptions = {
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
let prefMailNotificationType = firetray.Utils.prefService.getIntPref("mail_notification_type");
radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, prefMailNotificationType);
- this.disableNotificationMaybe(prefMailNotificationType);
-
- this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
+ // this.disableNotificationMaybe(prefMailNotificationType); // done in toggleNotifications()
},
initMessageCountSettings: function() {
@@ -210,13 +224,19 @@ var firetrayUIOptions = {
},
disableNotificationMaybe: function(notificationSetting) {
+ F.LOG("disableNotificationMaybe: "+notificationSetting);
+
let iconTextColor = document.getElementById("icon_text_color");
this.disableChildren(iconTextColor,
- (notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
+ (notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
+
+ let newMailIconNames = document.getElementById("newmail_icon_names");
+ this.disableNChildren(newMailIconNames, 2,
+ (notificationSetting !== FIRETRAY_NOTIFICATION_NEWMAIL_ICON));
let customIconGroup = document.getElementById("custom_mail_icon");
this.disableChildren(customIconGroup,
- (notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
+ (notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
},
disableMessageCountMaybe: function(msgCountType) {
@@ -230,6 +250,8 @@ var firetrayUIOptions = {
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
if (msgCountTypeIsNewMessages && (mailNotificationType === FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT)) {
radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
+ let newMailIconNames = document.getElementById("newmail_icon_names");
+ this.disableNChildren(newMailIconNames, 2, false);
firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
}
},
@@ -238,17 +260,21 @@ var firetrayUIOptions = {
if (enabled) {
document.getElementById("broadcaster-notification-disabled")
.removeAttribute("disabled"); // UI update (enables!)
- firetray.Messaging.init();
+ if (!firetray.Messaging.initialized) firetray.Messaging.init();
firetray.Messaging.updateMsgCount();
+
+ let prefMailNotificationType = firetray.Utils.prefService.getIntPref("mail_notification_type");
+ this.disableNotificationMaybe(prefMailNotificationType);
+
+ let radioMessageCountType = document.getElementById("ui_message_count_type");
+ let messageCountType = +radioMessageCountType.getItemAtIndex(radioMessageCountType.selectedIndex).value;
+ this.disableMessageCountMaybe(messageCountType);
+
} else {
document.getElementById("broadcaster-notification-disabled")
.setAttribute("disabled", "true"); // UI update
firetray.Messaging.shutdown();
}
-
- let radioMessageCountType = document.getElementById("ui_message_count_type");
- let messageCountType = +radioMessageCountType.getItemAtIndex(radioMessageCountType.selectedIndex).value;
- this.disableMessageCountMaybe(messageCountType);
},
chooseAppIconFile: function() {
48 src/chrome/content/options.xul
View
@@ -84,21 +84,23 @@
<vbox align="left" flex="1">
<label class="header">&app_icon_type;</label>
- <hbox>
+ <hbox id="ui_app_icon_type_default_group">
<radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;"
accesskey="&app_icon_themed.accesskey;" tooltiptext="&icon_themed.tooltip;" />
- <textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
- onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
- <textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
- onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
- <textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
- onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
- disabled="true"/>
+ <hbox id="app_icon_default" align="center" flex="1" >
+ <textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
+ onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
+ <textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
+ onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
+ <textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
+ onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
+ disabled="true"/>
+ </hbox>
</hbox>
<hbox id="ui_app_icon_type_custom_group">
<radio id="ui_app_icon_type_custom" label="&app_icon_custom.label;"
accesskey="&app_icon_custom.accesskey;" />
- <hbox id="custom_app_icon" align="center" flex="1" >
+ <hbox id="app_icon_custom" align="center" flex="1" >
<textbox id="app_icon_custom_filename" preference="pref_app_icon_filename" flex="1" />
<button id="app_icon_custom_select" label="&choose;"
accesskey="&choose.accesskey;"
@@ -176,18 +178,20 @@
oncommand="firetrayUIOptions.updateNotificationSettings()"
observes="broadcaster-notification-disabled"
tooltiptext="&icon_themed.tooltip;" />
- <textbox id="radio_mail_notification_newmail_icon_name1" size="12"
- placeholder="&app_icon_themed_name;" flex="1"
- observes="broadcaster-notification-disabled"
- onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
- <textbox id="radio_mail_notification_newmail_icon_name2" size="12"
- placeholder="&app_icon_themed_name;" flex="1"
- observes="broadcaster-notification-disabled"
- onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
- <textbox id="radio_mail_notification_newmail_icon_name3" size="12"
- placeholder="&app_icon_themed_name;" flex="1"
- onchange="firetrayUIOptions.updateNewMailIconNames(this);"
- disabled="true"/>
+ <hbox id="newmail_icon_names">
+ <textbox id="radio_mail_notification_newmail_icon_name1" size="12"
+ placeholder="&app_icon_themed_name;" flex="1"
+ observes="broadcaster-notification-disabled"
+ onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
+ <textbox id="radio_mail_notification_newmail_icon_name2" size="12"
+ placeholder="&app_icon_themed_name;" flex="1"
+ observes="broadcaster-notification-disabled"
+ onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
+ <textbox id="radio_mail_notification_newmail_icon_name3" size="12"
+ placeholder="&app_icon_themed_name;" flex="1"
+ onchange="firetrayUIOptions.updateNewMailIconNames(this);"
+ disabled="true"/>
+ </hbox>
</hbox>
<hbox>
<radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;"
@@ -196,9 +200,11 @@
observes="broadcaster-notification-disabled" />
<hbox id="custom_mail_icon" align="center" flex="1" >
<textbox id="custom_mail_icon_filename" preference="pref_custom_mail_icon"
+ observes="broadcaster-notification-disabled"
onchange="firetray.Messaging.updateMsgCount();" flex="1" />
<button id="custom_mail_icon_select" label="&choose;"
accesskey="&choose.accesskey;"
+ observes="broadcaster-notification-disabled"
oncommand="firetrayUIOptions.chooseMailIconFile()" />
</hbox>
</hbox>
4 src/modules/FiretrayHandler.jsm
View
@@ -171,9 +171,9 @@ firetray.Handler = {
},
// these get overridden in OS-specific Icon/Window handlers
- setIconImage: function(icon) {},
- setIconImageFromFile: function(filename) {},
setIconImageDefault: function() {},
+ setIconImageNewMail: function() {},
+ setIconImageFromFile: function(filename) {},
setIconText: function(text, color) {},
setIconTooltip: function(localizedMessage) {},
setIconTooltipDefault: function() {},
4 src/modules/FiretrayMessaging.jsm
View
@@ -28,7 +28,7 @@ firetray.Messaging = {
init: function() {
if (this.initialized) {
- F.LOG("Messaging already initialized");
+ F.WARN("Messaging already initialized");
return;
}
F.LOG("Enabling Messaging");
@@ -179,7 +179,7 @@ firetray.Messaging = {
firetray.Handler.setIconText(newMsgCount.toString(), prefIconTextColor);
break;
case FIRETRAY_NOTIFICATION_NEWMAIL_ICON:
- firetray.Handler.setIconImage(firetray.StatusIcon.themedIconNewMail);
+ firetray.Handler.setIconImageNewMail();
break;
case FIRETRAY_NOTIFICATION_CUSTOM_ICON:
let prefCustomIconPath = firetray.Utils.prefService.getCharPref("custom_mail_icon");
22 src/modules/linux/FiretrayStatusIcon.jsm
View
@@ -181,13 +181,6 @@ firetray.StatusIcon = {
filename);
},
- setIconImageFromName: function(iconName) {
- if (!firetray.StatusIcon.trayIcon)
- F.ERROR("Icon missing");
- F.LOG(iconName);
- gtk.gtk_status_icon_set_from_icon_name(firetray.StatusIcon.trayIcon, iconName);
- },
-
setIconImageFromGIcon: function(gicon) {
if (!firetray.StatusIcon.trayIcon || !gicon)
F.ERROR("Icon missing");
@@ -197,23 +190,24 @@ firetray.StatusIcon = {
}; // firetray.StatusIcon
-
-firetray.Handler.setIconImage = firetray.StatusIcon.setIconImageFromGIcon;
-
-firetray.Handler.setIconImageFromFile = firetray.StatusIcon.setIconImageFromFile;
-
firetray.Handler.setIconImageDefault = function() {
if (!firetray.StatusIcon.themedIconApp)
throw "Default application themed icon not set";
let appIconType = firetray.Utils.prefService.getIntPref("app_icon_type");
if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_THEMED)
- firetray.Handler.setIconImage(firetray.StatusIcon.themedIconApp);
+ firetray.StatusIcon.setIconImageFromGIcon(firetray.StatusIcon.themedIconApp);
else if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM) {
let appIconFilename = firetray.Utils.prefService.getCharPref("app_icon_filename");
- firetray.Handler.setIconImageFromFile(appIconFilename);
+ firetray.StatusIcon.setIconImageFromFile(appIconFilename);
}
};
+firetray.Handler.setIconImageNewMail = function() {
+ firetray.StatusIcon.setIconImageFromGIcon(firetray.StatusIcon.themedIconNewMail);
+};
+
+firetray.Handler.setIconImageFromFile = firetray.StatusIcon.setIconImageFromFile;
+
// GTK bug: Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
firetray.Handler.setIconTooltip = function(toolTipStr) {
if (!firetray.StatusIcon.trayIcon)
Please sign in to comment.
Something went wrong with that request. Please try again.