1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-14 04:45:02 -05:00

Hide unsupported prefs in preference window for winnt.

This commit is contained in:
foudfou 2014-02-23 21:54:04 +01:00
parent 6d4c0040f7
commit 1b8d9c3653
5 changed files with 79 additions and 28 deletions

View File

@ -1,5 +1,13 @@
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* FIXME: instantApply pref defaults to false on Windows. But the Firetray pref
window was originaly crafted for instantApply platforms: some UI changes do
also change prefs programmaticaly. For a consistant behaviour across all
instantApply cases, we should probably not set prefs dynamically, that is leave
it all to the UI. See:
http://forums.mozillazine.org/viewtopic.php?f=19&t=2743643
https://groups.google.com/forum/#!topic/mozilla.dev.extensions/SBGIogdIiwE */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
@ -15,7 +23,6 @@ const TREELEVEL_EXCLUDED_ACCOUNTS = 1;
const PREF_DEFAULT_PANE = "pref-pane-windows";
let log = firetray.Logging.getLogger("firetray.UIOptions");
var firetrayUIOptions = {
@ -23,6 +30,7 @@ var firetrayUIOptions = {
prefwindow: null,
onLoad: function(e) {
log.debug("FULL FEATURED="+firetray.Handler.support['full_feat']);
this.strings = document.getElementById("firetray-options-strings");
this.prefwindow = document.getElementById("firetray-preferences");
if (!this.prefwindow)
@ -40,15 +48,20 @@ var firetrayUIOptions = {
FIRETRAY_CHAT_SUPPORTED_OS.indexOf(firetray.Handler.runtimeOS) > -1) {
Cu.import("resource://firetray/"+firetray.Handler.runtimeOS+"/FiretrayChat.jsm");
this.initChatControls();
} else
} else {
this.hidePrefPane("pref-pane-chat");
};
this.updateWindowAndIconOptions();
this.updateScrollOptions();
this.initAppIconType();
if (firetray.Handler.support['full_feat']) {
this.initAppIconNames();
if (firetray.Handler.inMailApp)
this.initNewMailIconNames();
} else {
this.hideUnsupportedOptions();
};
window.sizeToContent();
},
@ -74,6 +87,28 @@ var firetrayUIOptions = {
}
},
hideUnsupportedOptions: function() { // full_feat
// windows prefs
['ui_hides_last_only', 'ui_start_hidden', 'ui_show_activates',
'ui_remember_desktop'].forEach(function(id){
document.getElementById(id).hidden = true;
});
// icon prefs
['app_icon_default', 'ui_show_icon_on_hide', 'ui_scroll_hides',
'ui_radiogroup_scroll'].forEach(function(id){
document.getElementById(id).hidden = true;
});
document.getElementById("ui_scroll_hides").setAttribute("oncommand", void(0));
// mail prefs
document.getElementById("newmail_icon_names").hidden = true;
for (let i=1; i<4; ++i) {
document.getElementById("radio_mail_notification_newmail_icon_name"+i).
setAttribute("observes", void(0));
}
},
hidePrefPane: function(name){
let radio = document.getAnonymousElementByAttribute(this.prefwindow, "pane", name);
if (radio.selected)
@ -81,8 +116,10 @@ var firetrayUIOptions = {
radio.hidden = true;
},
hideElement: function(targetNode, hiddenval) {
targetNode.hidden = hiddenval;
hideChildren: function(group, hiddenval) {
let children = group.childNodes;
for (let i=0, len=children.length; i<len ; ++i)
children[i].hidden = hiddenval;
},
disableChildren: function(group, disableval) {
@ -120,8 +157,9 @@ var firetrayUIOptions = {
},
updateScrollOptions: function() {
let scroll_hides = document.getElementById("ui_scroll_hides").checked;
this.disableChildren(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
let ui_scroll_hides = document.getElementById("ui_scroll_hides");
this.disableChildren(document.getElementById("ui_radiogroup_scroll"),
!ui_scroll_hides.checked);
},
initAppIconType: function() {
@ -179,13 +217,15 @@ var firetrayUIOptions = {
},
disableIconTypeMaybe: function(appIconType) {
let appIconCustomGroup = document.getElementById("app_icon_custom");
this.disableChildren(appIconCustomGroup,
(appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
if (firetray.Handler.support['full_feat']) {
let appIconDefaultGroup = document.getElementById("app_icon_default");
this.disableNChildren(appIconDefaultGroup, 2,
(appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_THEMED));
}
let appIconCustomGroup = document.getElementById("app_icon_custom");
this.disableChildren(appIconCustomGroup,
(appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
},
initMailControls: function() {
@ -289,9 +329,11 @@ var firetrayUIOptions = {
this.disableChildren(iconTextColor,
(notificationSetting !== FIRETRAY_NOTIFICATION_MESSAGE_COUNT));
if (firetray.Handler.support['full_feat']) {
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,
@ -309,8 +351,10 @@ var firetrayUIOptions = {
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
if (msgCountTypeIsNewMessages && (mailNotificationType === FIRETRAY_NOTIFICATION_MESSAGE_COUNT)) {
radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
if (firetray.Handler.support['full_feat']) {
let newMailIconNames = document.getElementById("newmail_icon_names");
this.disableNChildren(newMailIconNames, 2, false);
}
firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
}
},

View File

@ -41,6 +41,7 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
firetray_log.debug('Firetray UNLOADED !');
},
// BUG: CLOSE not emitted on TB (24, 27) win32 (XP, 7) ?!
/* until we find a fix (TODO), we need to set browser.tabs.warnOnClose=false
to prevent the popup when closing a window with multiple tabs and when
hides_on_close is set (we are not actually closing the tabs!). There is no

View File

@ -62,6 +62,7 @@ firetray.Handler = {
}
throw new Error("not resolved");
})(),
support: {chat: false, full_feat: false},
init: function() { // does creates icon
firetray.PrefListener.register(false);
@ -79,6 +80,11 @@ firetray.Handler = {
Cu.import("resource://firetray/"+this.runtimeOS+"/FiretrayWindow.jsm");
log.debug("FiretrayWindow "+this.runtimeOS+" imported");
this.support['chat'] = FIRETRAY_CHAT_SUPPORTED_OS
.indexOf(this.runtimeOS) > -1;
this.support['full_feat'] = FIRETRAY_FULL_FEAT_SUPPORTED_OS
.indexOf(firetray.Handler.runtimeOS) > -1;
if (this.appId === FIRETRAY_APP_DB['thunderbird']['id'] ||
this.appId === FIRETRAY_APP_DB['seamonkey']['id'])
this.inMailApp = true;
@ -113,7 +119,7 @@ firetray.Handler = {
let chatIsProvided = this.isChatProvided();
log.info('isChatProvided='+chatIsProvided);
if (chatIsProvided) {
if (this.isChatSupported()) {
if (this.support['chat']) {
Cu.import("resource://firetray/FiretrayMessaging.jsm"); // needed for existsChatAccount
Cu.import("resource://firetray/"+this.runtimeOS+"/FiretrayChat.jsm");
firetray.Utils.addObservers(firetray.Handler, [
@ -163,7 +169,7 @@ firetray.Handler = {
shutdown: function() {
log.debug("Disabling Handler");
if (firetray.Handler.isChatProvided() && firetray.Handler.isChatSupported()
if (firetray.Handler.isChatProvided() && firetray.Handler.support['chat']
&& firetray.Chat.initialized)
firetray.Chat.shutdown();
@ -192,10 +198,6 @@ firetray.Handler = {
return this.appHasChat && Services.prefs.getBoolPref("mail.chat.enabled");
},
isChatSupported: function() {
return FIRETRAY_CHAT_SUPPORTED_OS.indexOf(this.runtimeOS) > -1;
},
tryCloseLibs: function() {
try {
for (let libName in this.ctypesLibs) {
@ -575,7 +577,7 @@ firetray.MailChatPrefListener = new PrefListener(
let enableChatCond =
(firetray.Handler.appHasChat &&
firetray.Utils.prefService.getBoolPref("chat_icon_enable") &&
firetray.Handler.isChatSupported());
firetray.Handler.support['chat']);
if (!enableChatCond) return;
if (Services.prefs.getBoolPref("mail.chat.enabled")) {

View File

@ -4,8 +4,9 @@
automatically provided by this module */
var EXPORTED_SYMBOLS =
[ "firetray", "FIRETRAY_VERSION", "FIRETRAY_SUPPORTED_OS",
"FIRETRAY_CHAT_SUPPORTED_OS", "FIRETRAY_ID", "FIRETRAY_PREF_BRANCH",
"FIRETRAY_SPLASH_PAGE", "FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
"FIRETRAY_CHAT_SUPPORTED_OS", "FIRETRAY_FULL_FEAT_SUPPORTED_OS",
"FIRETRAY_ID", "FIRETRAY_PREF_BRANCH", "FIRETRAY_SPLASH_PAGE",
"FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
"FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
"FIRETRAY_NOTIFICATION_MESSAGE_COUNT",
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
@ -26,6 +27,7 @@ Cu.import("resource://firetray/logging.jsm");
const FIRETRAY_VERSION = "0.4.99"; // needed for sync call of onVersionChange() :(
const FIRETRAY_SUPPORTED_OS = ['linux', 'winnt']; // install.rdf sync :(
const FIRETRAY_CHAT_SUPPORTED_OS = ['linux'];
const FIRETRAY_FULL_FEAT_SUPPORTED_OS = FIRETRAY_CHAT_SUPPORTED_OS;
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
const FIRETRAY_PREF_BRANCH = "extensions.firetray.";
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";

View File

@ -15,6 +15,8 @@ var win32 = new function() {
'XP': 51, // 2001
'2K': 50, // 2000
};
// could also parse Cc["@mozilla.org/network/protocol;1?name=http"].
// getService(Ci.nsIHttpProtocolHandler).oscpu
this.WINVER = null; // initialized in kernel32.jsm
this.BOOL = ctypes.bool;