1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-17 14:25:01 -05:00

add ui preference functionality for new-mail themed icon

NOTES:
* we need to find out why for ex. ["glade", "mail-message-new"] gives
  "mail-message-new" where "glade" is expected (first in the list).
* we need to handle defaults better (avoid things like
  newMailIconNames.push("mail-unread")).
* be consistent in preference UI when disabling (or not) the filename inputs
  along with their related radio button.
This commit is contained in:
foudfou 2012-03-13 16:10:23 +01:00
parent 43bbfb09b6
commit 2e65e07029
10 changed files with 57 additions and 30 deletions

View File

@ -30,7 +30,8 @@ var firetrayUIOptions = {
this.updateWindowAndIconOptions(); this.updateWindowAndIconOptions();
this.updateScrollOptions(); this.updateScrollOptions();
this.initAppIconType(); this.initAppIconType();
this.initIconNames(); this.initAppIconNames();
this.initNewMailIconNames();
}, },
onQuit: function(e) { onQuit: function(e) {
@ -60,8 +61,9 @@ var firetrayUIOptions = {
disableGroup: function(group, disableval) { disableGroup: function(group, disableval) {
try { try {
for (let i=0, len=group.childNodes.length; i<len ; ++i) let children = group.childNodes;
group.childNodes[i].disabled = disableval; for (let i=0, len=children.length; i<len ; ++i)
children[i].disabled = disableval;
} catch(e) {} } catch(e) {}
}, },
@ -87,31 +89,47 @@ var firetrayUIOptions = {
firetray.Utils.prefService.getIntPref("app_icon_type"); firetray.Utils.prefService.getIntPref("app_icon_type");
}, },
initIconNames: function() { initAppIconNames: function() {
let appIconNames = firetray.Utils.getArrayPref(firetray.StatusIcon.prefAppIconNames); this.initIconNames(firetray.StatusIcon.prefAppIconNames,
"app_icon_type_themed_name", firetray.Handler.appNameOriginal.toLowerCase());
},
initNewMailIconNames: function() {
this.initIconNames("new_mail_icon_names",
"radio_mail_notification_newmail_icon_name", "mail-unread");
},
initIconNames: function(prefIconNames, uiIconNameId, defaultIconName) {
let appIconNames = firetray.Utils.getArrayPref(prefIconNames);
LOG("appIconNames="+appIconNames); LOG("appIconNames="+appIconNames);
let len = appIconNames.length; let len = appIconNames.length;
if (len>2) if (len>2)
throw new RangeError("Too many icon names"); throw new RangeError("Too many icon names");
for (let i=0; i<len; ++i) { for (let i=0; i<len; ++i) {
let textbox = document.getElementById("app_icon_type_themed_name"+(i+1)); let textbox = document.getElementById(uiIconNameId+(i+1));
textbox.value = appIconNames[i]; textbox.value = appIconNames[i];
} }
let textbox = document.getElementById("app_icon_type_themed_name3"); let textbox = document.getElementById(uiIconNameId+3);
textbox.value = firetray.Handler.appNameOriginal.toLowerCase(); textbox.value = defaultIconName;
}, },
updateIconNames: function(textbox) { updateAppIconNames: function(textbox) {
let appIconNames = []; this.updateIconNames(firetray.StatusIcon.prefAppIconNames, "app_icon_type_themed_name");
},
updateNewMailIconNames: function(textbox) {
this.updateIconNames("new_mail_icon_names", "radio_mail_notification_newmail_icon_name");
},
updateIconNames: function(prefIconNames, uiIconNameId) {
let iconNames = [];
for (let i=1; i<3; ++i) { for (let i=1; i<3; ++i) {
let tb = document.getElementById("app_icon_type_themed_name"+i); let textbox = document.getElementById(uiIconNameId+i);
let val = tb.value.trim(); let val = textbox.value.trim();
LOG("val="+val); LOG("val="+val);
if (val) if (val)
appIconNames.push(val); iconNames.push(val);
} }
LOG("appIconNames="+appIconNames); LOG("iconNames="+iconNames);
firetray.Utils.setArrayPref(firetray.StatusIcon.prefAppIconNames, appIconNames); firetray.Utils.setArrayPref(prefIconNames, iconNames);
}, },
initMailControls: function() { initMailControls: function() {

View File

@ -82,11 +82,11 @@
<radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;" <radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;"
accesskey="&app_icon_themed.accesskey;" tooltiptext="&app_icon_themed.tooltip;" /> accesskey="&app_icon_themed.accesskey;" tooltiptext="&app_icon_themed.tooltip;" />
<textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;" <textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
onchange="firetrayUIOptions.updateIconNames(this);" flex="1" /> onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
<textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;" <textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
onchange="firetrayUIOptions.updateIconNames(this);" flex="1" /> onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
<textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;" <textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
onchange="firetrayUIOptions.updateIconNames(this);" flex="1" onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
disabled="true"/> disabled="true"/>
</hbox> </hbox>
<hbox> <hbox>
@ -167,16 +167,18 @@
accesskey="&mail_notification_newmail_icon.accesskey;" accesskey="&mail_notification_newmail_icon.accesskey;"
oncommand="firetrayUIOptions.updateNotificationSettings()" oncommand="firetrayUIOptions.updateNotificationSettings()"
observes="broadcaster-notification-disabled" /> observes="broadcaster-notification-disabled" />
<!-- TODO -->
<textbox id="radio_mail_notification_newmail_icon_name1" size="12" <textbox id="radio_mail_notification_newmail_icon_name1" size="12"
placeholder="&app_icon_themed_name;" onchange="" flex="1" placeholder="&app_icon_themed_name;" flex="1"
observes="broadcaster-notification-disabled" /> observes="broadcaster-notification-disabled"
onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
<textbox id="radio_mail_notification_newmail_icon_name2" size="12" <textbox id="radio_mail_notification_newmail_icon_name2" size="12"
placeholder="&app_icon_themed_name;" onchange="" flex="1" placeholder="&app_icon_themed_name;" flex="1"
observes="broadcaster-notification-disabled" /> observes="broadcaster-notification-disabled"
onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
<textbox id="radio_mail_notification_newmail_icon_name3" size="12" <textbox id="radio_mail_notification_newmail_icon_name3" size="12"
placeholder="&app_icon_themed_name;" onchange="" flex="1" placeholder="&app_icon_themed_name;" flex="1"
observes="broadcaster-notification-disabled" /> onchange="firetrayUIOptions.updateNewMailIconNames(this);"
disabled="true"/>
</hbox> </hbox>
<hbox> <hbox>
<radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;" <radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;"

View File

@ -23,7 +23,7 @@
<!ENTITY bool_show_icon_on_hide.label "Show tray icon only if a window is hidden"> <!ENTITY bool_show_icon_on_hide.label "Show tray icon only if a window is hidden">
<!ENTITY bool_show_icon_on_hide.accesskey "w"> <!ENTITY bool_show_icon_on_hide.accesskey "w">
<!ENTITY app_icon_type "Application icon"> <!ENTITY app_icon_type "Application icon type">
<!ENTITY app_icon_themed.label "Default themed"> <!ENTITY app_icon_themed.label "Default themed">
<!ENTITY app_icon_themed.accesskey "D"> <!ENTITY app_icon_themed.accesskey "D">
<!ENTITY app_icon_themed_name "icon-name"> <!ENTITY app_icon_themed_name "icon-name">

View File

@ -1 +0,0 @@
../../../../../mail-message-new.png

View File

@ -0,0 +1 @@
../../../../../mail-unread.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -14,10 +14,11 @@ pref("extensions.firetray.start_hidden", false);
pref("extensions.firetray.show_activates", false); pref("extensions.firetray.show_activates", false);
pref("extensions.firetray.app_icon_type", 0); pref("extensions.firetray.app_icon_type", 0);
pref("extensions.firetray.app_browser_icon_names", '[]'); pref("extensions.firetray.app_browser_icon_names", '["web-browser", "internet-web-browser"]');
pref("extensions.firetray.app_mail_icon_names", '["indicator-messages", "applications-email-panel"]'); pref("extensions.firetray.app_mail_icon_names", '["indicator-messages", "applications-email-panel"]');
pref("extensions.firetray.app_default_icon_names", '[]'); pref("extensions.firetray.app_default_icon_names", '[]');
pref("extensions.firetray.app_icon_filename", ""); pref("extensions.firetray.app_icon_filename", "");
pref("extensions.firetray.new_mail_icon_names", '["indicator-messages-new", "mail-message-new"]');
pref("extensions.firetray.show_icon_on_hide", false); pref("extensions.firetray.show_icon_on_hide", false);
pref("extensions.firetray.scroll_hides", true); pref("extensions.firetray.scroll_hides", true);
pref("extensions.firetray.scroll_mode", "down_hides"); pref("extensions.firetray.scroll_mode", "down_hides");

View File

@ -367,6 +367,8 @@ firetray.PrefListener = new PrefListener(
case 'show_icon_on_hide': case 'show_icon_on_hide':
firetray.Handler.showHideIcon(); firetray.Handler.showHideIcon();
break; break;
case 'new_mail_icon_names':
firetray.StatusIcon.loadThemedIcons();
case 'message_count_type': case 'message_count_type':
firetray.Messaging.updateMsgCount(); firetray.Messaging.updateMsgCount();
break; break;

View File

@ -70,8 +70,11 @@ firetray.StatusIcon = {
loadThemedIcons: function() { loadThemedIcons: function() {
if (firetray.Handler.inMailApp) { if (firetray.Handler.inMailApp) {
let newMailIconNames = firetray.Utils.getArrayPref("new_mail_icon_names");
newMailIconNames.push("mail-unread"); // SMELL
this.themedIconNewMail = this.initThemedIcon(newMailIconNames);
this.prefAppIconNames = "app_mail_icon_names"; this.prefAppIconNames = "app_mail_icon_names";
this.themedIconNewMail = this.initThemedIcon(["indicator-messages-new", "mail-message-new"]); // TODO
} else if (firetray.Handler.inBrowserApp) { } else if (firetray.Handler.inBrowserApp) {
this.prefAppIconNames = "app_browser_icon_names"; this.prefAppIconNames = "app_browser_icon_names";
} else { } else {
@ -84,6 +87,7 @@ firetray.StatusIcon = {
initThemedIcon: function(names) { initThemedIcon: function(names) {
if (!isArray(names)) throw new TypeError(); if (!isArray(names)) throw new TypeError();
LOG("themedIconNames="+names);
let namesLen = names.length; let namesLen = names.length;
LOG("themedIconNamesLen="+namesLen); LOG("themedIconNamesLen="+namesLen);
let themedIconNames = ctypes.char.ptr.array(namesLen)(); let themedIconNames = ctypes.char.ptr.array(namesLen)();