Merge pull request #434 from saneyuki/pref
Fix `browser.tabs.insertRelatedAfterCurrent` is not restored correctly when uninstall/disable
This commit is contained in:
commit
c06a2d2e2a
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
<script src="res/stopRendering.js" type="application/javascript"/>
|
<script src="res/stopRendering.js" type="application/javascript"/>
|
||||||
<script src="res/tabsDragUtils.js" type="application/javascript"/>
|
<script src="res/tabsDragUtils.js" type="application/javascript"/>
|
||||||
<script src="res/UninstallationListener.js" type="application/javascript"/>
|
|
||||||
<script src="treestyletab.js" type="application/javascript"/>
|
<script src="treestyletab.js" type="application/javascript"/>
|
||||||
<script src="windowHelper.js" type="application/javascript"/>
|
<script src="windowHelper.js" type="application/javascript"/>
|
||||||
<script src="windowHelperHacks.js" type="application/javascript"/>
|
<script src="windowHelperHacks.js" type="application/javascript"/>
|
||||||
|
@ -71,6 +71,8 @@ XPCOMUtils.defineLazyGetter(this, 'autoScroll', function() {
|
|||||||
Components.utils.import('resource://treestyletab-modules/lib/autoScroll.js', {});
|
Components.utils.import('resource://treestyletab-modules/lib/autoScroll.js', {});
|
||||||
return window['piro.sakura.ne.jp'].autoScroll;
|
return window['piro.sakura.ne.jp'].autoScroll;
|
||||||
});
|
});
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener',
|
||||||
|
'resource://treestyletab-modules/lib/UninstallationListener.js');
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, 'confirmWithPopup', 'resource://treestyletab-modules/lib/confirmWithPopup.js');
|
XPCOMUtils.defineLazyModuleGetter(this, 'confirmWithPopup', 'resource://treestyletab-modules/lib/confirmWithPopup.js');
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||||
|
|
||||||
@ -311,6 +313,8 @@ var TreeStyleTabBase = {
|
|||||||
|
|
||||||
this.addPrefListener(this);
|
this.addPrefListener(this);
|
||||||
|
|
||||||
|
this.initUninstallationListener();
|
||||||
|
|
||||||
this.onPrefChange('extensions.treestyletab.indent.vertical');
|
this.onPrefChange('extensions.treestyletab.indent.vertical');
|
||||||
this.onPrefChange('extensions.treestyletab.indent.horizontal');
|
this.onPrefChange('extensions.treestyletab.indent.horizontal');
|
||||||
this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
|
this.onPrefChange('extensions.treestyletab.clickOnIndentSpaces.enabled');
|
||||||
@ -488,7 +492,38 @@ var TreeStyleTabBase = {
|
|||||||
}
|
}
|
||||||
utils.setTreePref('prefsVersion', this.kPREF_VERSION);
|
utils.setTreePref('prefsVersion', this.kPREF_VERSION);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initUninstallationListener : function TSTWindow_initUninstallationListener()
|
||||||
|
{
|
||||||
|
var restorePrefs = function() {
|
||||||
|
// Remove pref listener before restore backuped prefs.
|
||||||
|
prefs.removePrefListener(this);
|
||||||
|
|
||||||
|
let restorePrefs = [
|
||||||
|
'browser.tabs.loadFolderAndReplace',
|
||||||
|
'browser.tabs.insertRelatedAfterCurrent',
|
||||||
|
'extensions.stm.tabBarMultiRows' // Super Tab Mode
|
||||||
|
];
|
||||||
|
for (let i = 0, maxi = restorePrefs.length; i < maxi; i++)
|
||||||
|
{
|
||||||
|
let pref = restorePrefs[i];
|
||||||
|
let backup = prefs.getPref(pref+'.backup');
|
||||||
|
if (backup === null) continue;
|
||||||
|
// we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener.
|
||||||
|
prefs.setPref(pref+'.override', backup);
|
||||||
|
// restore user preference.
|
||||||
|
prefs.setPref(pref, backup);
|
||||||
|
// clear backup pref.
|
||||||
|
prefs.clearPref(pref+'.backup');
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
new UninstallationListener({
|
||||||
|
id : 'treestyletab@piro.sakura.ne.jp',
|
||||||
|
onuninstalled : restorePrefs,
|
||||||
|
ondisabled : restorePrefs
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
updateAeroPeek : function utils_updateAeroPeek()
|
updateAeroPeek : function utils_updateAeroPeek()
|
||||||
{
|
{
|
||||||
var ns = {};
|
var ns = {};
|
||||||
|
@ -13,6 +13,24 @@
|
|||||||
original:
|
original:
|
||||||
http://github.com/piroor/fxaddonlibs/blob/master/UninstallationListener.js
|
http://github.com/piroor/fxaddonlibs/blob/master/UninstallationListener.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* To work as a JS Code Module */
|
||||||
|
if (typeof window == 'undefined' ||
|
||||||
|
(window && typeof window.constructor == 'function')) {
|
||||||
|
this.EXPORTED_SYMBOLS = ['UninstallationListener'];
|
||||||
|
|
||||||
|
// If namespace.jsm is available, export symbols to the shared namespace.
|
||||||
|
// See: http://github.com/piroor/fxaddonlibs/blob/master/namespace.jsm
|
||||||
|
try {
|
||||||
|
let ns = {};
|
||||||
|
Components.utils.import('resource://my-modules/namespace.jsm', ns);
|
||||||
|
/* var */ window = ns.getNamespaceFor('piro.sakura.ne.jp');
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
window = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 2;
|
const currentRevision = 2;
|
||||||
|
|
||||||
@ -165,3 +183,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
if (window != this) { // work as a JS Code Module
|
||||||
|
this.UninstallationListener = window['piro.sakura.ne.jp'].UninstallationListener;
|
||||||
|
}
|
@ -40,6 +40,11 @@ const Ci = Components.interfaces;
|
|||||||
|
|
||||||
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "prefs",
|
||||||
|
'resource://treestyletab-modules/lib/prefs.js');
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener',
|
||||||
|
'resource://treestyletab-modules/lib/UninstallationListener.js');
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
|
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
Components.utils.import('resource://treestyletab-modules/base.js');
|
Components.utils.import('resource://treestyletab-modules/base.js');
|
||||||
@ -379,46 +384,18 @@ TreeStyleTabWindow.prototype = {
|
|||||||
|
|
||||||
initUninstallationListener : function TSTWindow_initUninstallationListener()
|
initUninstallationListener : function TSTWindow_initUninstallationListener()
|
||||||
{
|
{
|
||||||
var namespace = {};
|
|
||||||
Components.utils.import(
|
|
||||||
'resource://treestyletab-modules/lib/prefs.js',
|
|
||||||
namespace
|
|
||||||
);
|
|
||||||
var prefs = namespace.prefs;
|
|
||||||
namespace = void(0);
|
|
||||||
var self = this;
|
|
||||||
var restorePrefs = function() {
|
var restorePrefs = function() {
|
||||||
if (prefs.getPref('extensions.treestyletab.tabsOnTop.originalState')) {
|
if (prefs.getPref('extensions.treestyletab.tabsOnTop.originalState')) {
|
||||||
prefs.clearPref('extensions.treestyletab.tabsOnTop.originalState');
|
prefs.clearPref('extensions.treestyletab.tabsOnTop.originalState');
|
||||||
try {
|
try {
|
||||||
self.browser.treeStyleTab.position = 'top';
|
this.browser.treeStyleTab.position = 'top';
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
}
|
}
|
||||||
self.window.TabsOnTop.enabled = true;
|
this.window.TabsOnTop.enabled = true;
|
||||||
}
|
}
|
||||||
|
}.bind(this);
|
||||||
if (!prefs) return;
|
new UninstallationListener({
|
||||||
|
|
||||||
let restorePrefs = [
|
|
||||||
'browser.tabs.loadFolderAndReplace',
|
|
||||||
'browser.tabs.insertRelatedAfterCurrent',
|
|
||||||
'extensions.stm.tabBarMultiRows' // Super Tab Mode
|
|
||||||
];
|
|
||||||
for (let i = 0, maxi = restorePrefs.length; i < maxi; i++)
|
|
||||||
{
|
|
||||||
let pref = restorePrefs[i];
|
|
||||||
let backup = prefs.getPref(pref+'.backup');
|
|
||||||
if (backup === null) continue;
|
|
||||||
// we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener.
|
|
||||||
prefs.setPref(pref+'.override', backup);
|
|
||||||
// restore user preference.
|
|
||||||
prefs.setPref(pref, backup);
|
|
||||||
// clear backup pref.
|
|
||||||
prefs.clearPref(pref+'.backup');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
new this.window['piro.sakura.ne.jp'].UninstallationListener({
|
|
||||||
id : 'treestyletab@piro.sakura.ne.jp',
|
id : 'treestyletab@piro.sakura.ne.jp',
|
||||||
onuninstalled : restorePrefs,
|
onuninstalled : restorePrefs,
|
||||||
ondisabled : restorePrefs
|
ondisabled : restorePrefs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user