1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-23 06:18:48 -05:00

* rename pref 'scroll_to_hide' to 'scroll_hides'

* refactoring of FiretrayVersionChange.jsm
This commit is contained in:
foudfou 2012-01-26 07:37:08 +01:00
parent d0e1d072c6
commit 9dcd5faa4a
4 changed files with 101 additions and 60 deletions

View File

@ -82,8 +82,8 @@ var firetrayUIOptions = {
}, },
updateScrollOptions: function() { updateScrollOptions: function() {
let scroll_to_hide = document.getElementById("ui_scroll_to_hide").checked; let scroll_hides = document.getElementById("ui_scroll_hides").checked;
this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_to_hide); this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
}, },
initMailControls: function() { initMailControls: function() {

View File

@ -24,7 +24,7 @@
<preference id="pref_bool_hides_single_window" name="extensions.firetray.hides_single_window" type="bool"/> <preference id="pref_bool_hides_single_window" name="extensions.firetray.hides_single_window" type="bool"/>
<preference id="pref_bool_start_hidden" name="extensions.firetray.start_hidden" type="bool"/> <preference id="pref_bool_start_hidden" name="extensions.firetray.start_hidden" type="bool"/>
<preference id="pref_bool_show_icon_on_hide" name="extensions.firetray.show_icon_on_hide" type="bool"/> <preference id="pref_bool_show_icon_on_hide" name="extensions.firetray.show_icon_on_hide" type="bool"/>
<preference id="pref_bool_scroll_to_hide" name="extensions.firetray.scroll_to_hide" type="bool" /> <preference id="pref_bool_scroll_hides" name="extensions.firetray.scroll_hides" type="bool" />
<preference id="pref_string_scroll_mode" name="extensions.firetray.scroll_mode" type="string" /> <preference id="pref_string_scroll_mode" name="extensions.firetray.scroll_mode" type="string" />
<preference id="pref_string_icon_text_color" name="extensions.firetray.icon_text_color" type="string" /> <preference id="pref_string_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
<preference id="pref_string_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" /> <preference id="pref_string_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
@ -65,7 +65,7 @@
<checkbox id="ui_show_icon_on_hide" preference="pref_bool_show_icon_on_hide" <checkbox id="ui_show_icon_on_hide" preference="pref_bool_show_icon_on_hide"
label="&bool_show_icon_on_hide.label;" label="&bool_show_icon_on_hide.label;"
accesskey="&bool_show_icon_on_hide.accesskey;"/> accesskey="&bool_show_icon_on_hide.accesskey;"/>
<checkbox id="ui_scroll_to_hide" preference="pref_bool_scroll_to_hide" <checkbox id="ui_scroll_hides" preference="pref_bool_scroll_hides"
label="&enable_mouse_scroll.label;" label="&enable_mouse_scroll.label;"
accesskey="&enable_mouse_scroll.accesskey;" accesskey="&enable_mouse_scroll.accesskey;"
oncommand="firetrayUIOptions.updateScrollOptions()" /> oncommand="firetrayUIOptions.updateScrollOptions()" />

View File

@ -12,7 +12,7 @@ pref("extensions.firetray.hides_on_minimize", true);
pref("extensions.firetray.hides_single_window", false); pref("extensions.firetray.hides_single_window", false);
pref("extensions.firetray.start_hidden", false); pref("extensions.firetray.start_hidden", false);
pref("extensions.firetray.show_icon_on_hide", false); pref("extensions.firetray.show_icon_on_hide", false);
pref("extensions.firetray.scroll_to_hide", true); pref("extensions.firetray.scroll_hides", true);
pref("extensions.firetray.scroll_mode", "down_hides"); pref("extensions.firetray.scroll_mode", "down_hides");
pref("extensions.firetray.mail_notification", 1); pref("extensions.firetray.mail_notification", 1);

View File

@ -16,6 +16,9 @@ const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
*/ */
firetray.VersionChange = { firetray.VersionChange = {
versionComparator: Cc["@mozilla.org/xpcom/version-comparator;1"]
.getService(Ci.nsIVersionComparator),
watch: function() { watch: function() {
AddonManager.addAddonListener(this.uninstallListener); AddonManager.addAddonListener(this.uninstallListener);
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this)); AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
@ -37,7 +40,73 @@ firetray.VersionChange = {
} }
}, },
openMailTab: function() { onVersionChange: function(addon) {
LOG("VERSION: "+addon.version);
var curVersion = addon.version;
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
if (firstrun) {
WARN("FIRST RUN");
this.initPrefs(curVersion);
this.installHook(curVersion);
} else {
try {
var installedVersion = firetray.Utils.prefService.getCharPref("installedVersion");
var versionDelta = this.versionComparator.compare(curVersion, installedVersion);
if (versionDelta > 0) {
firetray.Utils.prefService.setCharPref("installedVersion", curVersion);
WARN("UPGRADE");
this.upgradeHook(installedVersion, curVersion);
}
} catch (ex) {
WARN("REINSTALL");
this.initPrefs(curVersion);
this.reinstallHook(curVersion);
}
}
},
initPrefs: function(version) {
firetray.Utils.prefService.setBoolPref("firstrun", false);
firetray.Utils.prefService.setCharPref("installedVersion", version);
},
installHook: function(curVersion) {},
upgradeHook: function(prevVersion, curVersion) {},
reinstallHook: function(curVersion) {}
};
firetray.VersionChange.installHook = function(curVersion) {
this.openTab();
this.tryEraseV03Options();
};
firetray.VersionChange.upgradeHook = function(prevVersion, curVersion) {
this.openTab();
this.tryEraseV03Options(); // FIXME: should check versions here
};
firetray.VersionChange.reinstallHook = function(curVersion) {
this.openTab();
};
firetray.VersionChange.openTab = function() {
let appId = Services.appinfo.ID;
if (appId === THUNDERBIRD_ID)
this.openMailTab();
else if (appId === FIREFOX_ID || appId === SEAMONKEY_ID)
this.openBrowserTab();
else
ERROR("unsupported application");
};
firetray.VersionChange.openMailTab = function() {
let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane"); let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
if (mail3PaneWindow) { if (mail3PaneWindow) {
var tabmail = mail3PaneWindow.document.getElementById("tabmail"); var tabmail = mail3PaneWindow.document.getElementById("tabmail");
@ -51,9 +120,9 @@ firetray.VersionChange = {
tabmail.openTab("contentTab", {contentPage: FIRETRAY_SPLASH_PAGE}); tabmail.openTab("contentTab", {contentPage: FIRETRAY_SPLASH_PAGE});
}}, FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT); }}, FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
} }
}, };
openBrowserTab: function() { firetray.VersionChange.openBrowserTab = function() {
let win = Services.wm.getMostRecentWindow("navigator:browser"); let win = Services.wm.getMostRecentWindow("navigator:browser");
WARN("WIN="+win); WARN("WIN="+win);
if (win) { if (win) {
@ -69,50 +138,22 @@ firetray.VersionChange = {
mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(FIRETRAY_SPLASH_PAGE); mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(FIRETRAY_SPLASH_PAGE);
}, 1000); }, 1000);
} }
}, };
openTab: function() { firetray.VersionChange.tryEraseV03Options = function() {
let appId = Services.appinfo.ID; let v03options = [
if (appId === THUNDERBIRD_ID) "close_to_tray", "minimize_to_tray", "start_minimized", "confirm_exit",
this.openMailTab(); "restore_to_next_unread", "mail_count_type", "show_mail_count",
else if (appId === FIREFOX_ID || appId === SEAMONKEY_ID) "dont_count_spam", "dont_count_archive", "dont_count_drafts",
this.openBrowserTab(); "dont_count_sent", "dont_count_templates", "show_mail_notification",
else "show_icon_only_minimized", "use_custom_normal_icon",
ERROR("unsupported application"); "use_custom_special_icon", "custom_normal_icon", "custom_special_icon",
}, "text_color", "scroll_to_hide", "scroll_action", "grab_multimedia_keys",
"hide_show_mm_key", "accounts_to_exclude" ];
initPrefs: function(version) {
firetray.Utils.prefService.setBoolPref("firstrun", false); for (let i = 0, length = v03options.length; i<length; ++i) {
firetray.Utils.prefService.setCharPref("installedVersion", version); try {
this.openTab(); firetray.Utils.prefService.clearUserPref(v03options[i]);
}, } catch (x) {}
}
onVersionChange: function(addon) {
LOG("VERSION: "+addon.version);
var curVersion = addon.version;
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
if (firstrun) {
WARN("FIRST RUN");
this.initPrefs(curVersion);
} else {
try {
var installedVersion = firetray.Utils.prefService.getCharPref("installedVersion");
var versionDelta = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator)
.compare(curVersion, installedVersion);
if (versionDelta > 0) {
firetray.Utils.prefService.setCharPref("installedVersion", curVersion);
WARN("UPGRADE");
this.openTab();
}
} catch (ex) {
WARN("REINSTALL");
this.initPrefs(curVersion);
}
}
}
}; };