[Pkg-mozext-commits] [firetray] 151/399: * rename pref 'scroll_to_hide' to 'scroll_hides' * refactoring of FiretrayVersionChange.jsm
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:32 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 9dcd5faa4a0d050807e6b893d0c42d6bd98c0f24
Author: foudfou <foudil.newbie+git at gmail.com>
Date: Thu Jan 26 07:37:08 2012 +0100
* rename pref 'scroll_to_hide' to 'scroll_hides'
* refactoring of FiretrayVersionChange.jsm
---
src/chrome/content/options.js | 4 +-
src/chrome/content/options.xul | 4 +-
src/defaults/preferences/prefs.js | 2 +-
src/modules/FiretrayVersionChange.jsm | 149 +++++++++++++++++++++------------
4 files changed, 100 insertions(+), 59 deletions(-)
diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index ab3e3cc..a5c3224 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -82,8 +82,8 @@ var firetrayUIOptions = {
},
updateScrollOptions: function() {
- let scroll_to_hide = document.getElementById("ui_scroll_to_hide").checked;
- this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_to_hide);
+ let scroll_hides = document.getElementById("ui_scroll_hides").checked;
+ this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
},
initMailControls: function() {
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index 1ed1f8c..874ec7b 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -24,7 +24,7 @@
<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_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_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" />
@@ -65,7 +65,7 @@
<checkbox id="ui_show_icon_on_hide" preference="pref_bool_show_icon_on_hide"
label="&bool_show_icon_on_hide.label;"
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;"
accesskey="&enable_mouse_scroll.accesskey;"
oncommand="firetrayUIOptions.updateScrollOptions()" />
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 70fbaa9..0da0d16 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -12,7 +12,7 @@ pref("extensions.firetray.hides_on_minimize", true);
pref("extensions.firetray.hides_single_window", false);
pref("extensions.firetray.start_hidden", 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.mail_notification", 1);
diff --git a/src/modules/FiretrayVersionChange.jsm b/src/modules/FiretrayVersionChange.jsm
index d87ff0f..1425434 100644
--- a/src/modules/FiretrayVersionChange.jsm
+++ b/src/modules/FiretrayVersionChange.jsm
@@ -8,7 +8,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://firetray/commons.js");
-const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
+const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
/**
@@ -16,6 +16,9 @@ const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
*/
firetray.VersionChange = {
+ versionComparator: Cc["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Ci.nsIVersionComparator),
+
watch: function() {
AddonManager.addAddonListener(this.uninstallListener);
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
@@ -37,56 +40,6 @@ firetray.VersionChange = {
}
},
- openMailTab: function() {
- let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
- if (mail3PaneWindow) {
- var tabmail = mail3PaneWindow.document.getElementById("tabmail");
- mail3PaneWindow.focus();
- }
-
- if (tabmail) {
- var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- timer.initWithCallback({ notify: function() {
- LOG("openMailTab");
- tabmail.openTab("contentTab", {contentPage: FIRETRAY_SPLASH_PAGE});
- }}, FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
- }
- },
-
- openBrowserTab: function() {
- let win = Services.wm.getMostRecentWindow("navigator:browser");
- WARN("WIN="+win);
- if (win) {
- var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIWebNavigation)
- .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
- .rootTreeItem
- .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIDOMWindow);
-
- mainWindow.setTimeout(function(win){
- LOG("openBrowser");
- mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(FIRETRAY_SPLASH_PAGE);
- }, 1000);
- }
- },
-
- 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");
- },
-
- initPrefs: function(version) {
- firetray.Utils.prefService.setBoolPref("firstrun", false);
- firetray.Utils.prefService.setCharPref("installedVersion", version);
- this.openTab();
- },
-
onVersionChange: function(addon) {
LOG("VERSION: "+addon.version);
@@ -96,23 +49,111 @@ firetray.VersionChange = {
if (firstrun) {
WARN("FIRST RUN");
this.initPrefs(curVersion);
+ this.installHook(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);
+ var versionDelta = this.versionComparator.compare(curVersion, installedVersion);
if (versionDelta > 0) {
firetray.Utils.prefService.setCharPref("installedVersion", curVersion);
WARN("UPGRADE");
- this.openTab();
+ 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");
+ if (mail3PaneWindow) {
+ var tabmail = mail3PaneWindow.document.getElementById("tabmail");
+ mail3PaneWindow.focus();
+ }
+
+ if (tabmail) {
+ var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+ timer.initWithCallback({ notify: function() {
+ LOG("openMailTab");
+ tabmail.openTab("contentTab", {contentPage: FIRETRAY_SPLASH_PAGE});
+ }}, FIRETRAY_BROWSER_STARTUP_DELAY_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
}
+};
+firetray.VersionChange.openBrowserTab = function() {
+ let win = Services.wm.getMostRecentWindow("navigator:browser");
+ WARN("WIN="+win);
+ if (win) {
+ var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindow);
+
+ mainWindow.setTimeout(function(win){
+ LOG("openBrowser");
+ mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(FIRETRAY_SPLASH_PAGE);
+ }, 1000);
+ }
+};
+
+firetray.VersionChange.tryEraseV03Options = function() {
+ let v03options = [
+ "close_to_tray", "minimize_to_tray", "start_minimized", "confirm_exit",
+ "restore_to_next_unread", "mail_count_type", "show_mail_count",
+ "dont_count_spam", "dont_count_archive", "dont_count_drafts",
+ "dont_count_sent", "dont_count_templates", "show_mail_notification",
+ "show_icon_only_minimized", "use_custom_normal_icon",
+ "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" ];
+
+ for (let i = 0, length = v03options.length; i<length; ++i) {
+ try {
+ firetray.Utils.prefService.clearUserPref(v03options[i]);
+ } catch (x) {}
+ }
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list