TreeStyleTabBase should not inherit "prefs"

This commit is contained in:
Piro / YUKI Hiroshi 2013-01-06 11:47:50 +09:00
parent 04471a3f3a
commit 72d38659d8
7 changed files with 118 additions and 84 deletions

View File

@ -370,7 +370,7 @@ TreeStyleTabWindowHelper.overrideExtensionsBeforeBrowserInit = function TSTWH_ov
case 'TreeStyleTabTabbarPositionChanged': case 'TreeStyleTabTabbarPositionChanged':
var b = aEvent.originalTarget; var b = aEvent.originalTarget;
if (b.treeStyleTab.isVertical) if (b.treeStyleTab.isVertical)
b.treeStyleTab.setPref('tabberwocky.multirow', false); TreeStyleTabUtils.prefs.setPref('tabberwocky.multirow', false);
break; break;
case 'unload': case 'unload':
@ -467,7 +467,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
break; break;
case sv.kEVENT_TYPE_FOCUS_NEXT_TAB: case sv.kEVENT_TYPE_FOCUS_NEXT_TAB:
let mode = sv.getPref('extensions.tabmix.focusTab'); let mode = TreeStyleTabUtils.prefs.getPref('extensions.tabmix.focusTab');
if (mode != 2 && mode != 5) if (mode != 2 && mode != 5)
aEvent.preventDefault(); aEvent.preventDefault();
break; break;
@ -581,7 +581,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('flst' in window && if ('flst' in window &&
TreeStyleTabUtils.getTreePref('compatibility.FLST')) { TreeStyleTabUtils.getTreePref('compatibility.FLST')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return !aTabBrowser.treeStyleTab.getPref('extensions.flst.enabled'); return !TreeStyleTabUtils.prefs.getPref('extensions.flst.enabled');
}); });
} }
@ -600,7 +600,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('LastTab' in window && if ('LastTab' in window &&
TreeStyleTabUtils.getTreePref('compatibility.LastTab')) { TreeStyleTabUtils.getTreePref('compatibility.LastTab')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return !aTabBrowser.treeStyleTab.getPref('extensions.lasttab.focusLastTabOnClose'); return !TreeStyleTabUtils.prefs.getPref('extensions.lasttab.focusLastTabOnClose');
}); });
} }
@ -848,8 +848,8 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ( if (
autoHIDE.statBar && autoHIDE.statBar &&
gBrowser.treeStyleTab.currentTabbarPosition == 'bottom' && gBrowser.treeStyleTab.currentTabbarPosition == 'bottom' &&
!gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && !TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar.always') &&
gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar')
) { ) {
autoHIDE.statBar.setAttribute('ahHIDE', true); autoHIDE.statBar.setAttribute('ahHIDE', true);
} }
@ -859,8 +859,8 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ( if (
autoHIDE.statBar && autoHIDE.statBar &&
aTabBrowser.treeStyleTab.currentTabbarPosition == 'bottom' && aTabBrowser.treeStyleTab.currentTabbarPosition == 'bottom' &&
!aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && !TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar.always') &&
aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar')
) { ) {
autoHIDE.statBar.removeAttribute('ahHIDE'); autoHIDE.statBar.removeAttribute('ahHIDE');
} }
@ -991,15 +991,15 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
case 'extensions.stm.tabBarMultiRows': case 'extensions.stm.tabBarMultiRows':
case 'extensions.stm.tabBarPosition': case 'extensions.stm.tabBarPosition':
if ( if (
sv.getPref('extensions.stm.tabBarMultiRows') && TreeStyleTabUtils.prefs.getPref('extensions.stm.tabBarMultiRows') &&
sv.getPref('extensions.stm.tabBarPosition') == 0 TreeStyleTabUtils.prefs.getPref('extensions.stm.tabBarPosition') == 0
) { ) {
sv.setPref('extensions.stm.tabBarMultiRows.override', false); TreeStyleTabUtils.prefs.setPref('extensions.stm.tabBarMultiRows.override', false);
} }
return; return;
case 'extensions.stm.newTabBtnPos': case 'extensions.stm.newTabBtnPos':
if (TreeStyleTabService.getPref(aData) == 0) if (TreeStyleTabUtils.prefs.getPref(aData) == 0)
document.documentElement.removeAttribute(TreeStyleTabService.kHIDE_NEWTAB); document.documentElement.removeAttribute(TreeStyleTabService.kHIDE_NEWTAB);
else else
document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true); document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true);
@ -1009,16 +1009,16 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
}; };
observer.observe(null, null, 'extensions.stm.tabBarMultiRows'); observer.observe(null, null, 'extensions.stm.tabBarMultiRows');
observer.observe(null, null, 'extensions.stm.newTabBtnPos'); observer.observe(null, null, 'extensions.stm.newTabBtnPos');
sv.addPrefListener(observer); TreeStyleTabUtils.prefs.addPrefListener(observer);
document.addEventListener('unload', function() { document.addEventListener('unload', function() {
document.removeEventListener('unload', arguments.callee, false); document.removeEventListener('unload', arguments.callee, false);
sv.removePrefListener(observer); TreeStyleTabUtils.prefs.removePrefListener(observer);
}, false); }, false);
let warnPref = 'extensions.treestyletab.compatibility.STM.warnForNewTabPosition'; let warnPref = 'extensions.treestyletab.compatibility.STM.warnForNewTabPosition';
if ( if (
sv.getPref(warnPref) && TreeStyleTabUtils.prefs.getPref(warnPref) &&
sv.getPref('extensions.stm.newTabPosition') != 0 TreeStyleTabUtils.prefs.getPref('extensions.stm.newTabPosition') != 0
) { ) {
let checked = { value : false }; let checked = { value : false };
if (Services.prompt.confirmEx( if (Services.prompt.confirmEx(
@ -1033,14 +1033,14 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
TreeStyleTabUtils.treeBundle.getString('compatibility_STM_warning_never'), TreeStyleTabUtils.treeBundle.getString('compatibility_STM_warning_never'),
checked checked
) == 0) { ) == 0) {
sv.setPref('extensions.stm.newTabPosition', 0); TreeStyleTabUtils.prefs.setPref('extensions.stm.newTabPosition', 0);
} }
if (checked.value) if (checked.value)
sv.setPref(warnPref, false); TreeStyleTabUtils.prefs.setPref(warnPref, false);
} }
sv.registerTabFocusAllowance(function(aTabBrowser) { sv.registerTabFocusAllowance(function(aTabBrowser) {
return aTabBrowser.treeStyleTab.getPref('extensions.stm.focusAfterCloseTab') == 0; return TreeStyleTabUtils.prefs.getPref('extensions.stm.focusAfterCloseTab') == 0;
}); });
} }
@ -1049,7 +1049,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('tabutils' in window && if ('tabutils' in window &&
TreeStyleTabUtils.getTreePref('compatibility.TabUtilities')) { TreeStyleTabUtils.getTreePref('compatibility.TabUtilities')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return aTabBrowser.treeStyleTab.getPref('extensions.tabutils.selectOnClose') == 0; return TreeStyleTabUtils.prefs.getPref('extensions.tabutils.selectOnClose') == 0;
}); });
} }
@ -1185,7 +1185,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
' (function() {\n' + ' (function() {\n' +
' var tabs = this.treeStyleTab.getDescendantTabs(this.mCurrentTab);\n' + ' var tabs = this.treeStyleTab.getDescendantTabs(this.mCurrentTab);\n' +
' if (tabs.length) {\n' + ' if (tabs.length) {\n' +
' var index = this.treeStyleTab.getPref("extensions.tabmix.openTabNextInverse") ?\n' + ' var index = TreeStyleTabUtils.prefs.getPref("extensions.tabmix.openTabNextInverse") ?\n' +
' tabs[tabs.length - 1]._tPos :\n' + ' tabs[tabs.length - 1]._tPos :\n' +
' this.mCurrentTab._tPos ;\n' + ' this.mCurrentTab._tPos ;\n' +
' if (index < aTab._tPos) index++;\n' + ' if (index < aTab._tPos) index++;\n' +

View File

@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab. * The Original Code is the Tree Style Tab.
* *
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2010-2012 * Portions created by the Initial Developer are Copyright (C) 2010-2013
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com> * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
@ -37,11 +37,21 @@ const EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
XPCOMUtils.defineLazyGetter(this, 'window', function() {
Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp');
});
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Cu.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs;
});
function AutoHideBrowser(aTabBrowser) function AutoHideBrowser(aTabBrowser)
{ {
@ -118,7 +128,7 @@ AutoHideBrowser.prototype = {
// update internal property after the appearance of the tab bar is updated. // update internal property after the appearance of the tab bar is updated.
var w = this.window; var w = this.window;
w.setTimeout(function(aSelf) { w.setTimeout(function(aSelf) {
aSelf.mode = (w.fullScreen && aSelf.treeStyleTab.getPref('browser.fullscreen.autohide')) ? aSelf.mode = (w.fullScreen && prefs.getPref('browser.fullscreen.autohide')) ?
aSelf.getModeForFullScreen() : aSelf.getModeForFullScreen() :
aSelf.getModeForNormal() ; aSelf.getModeForNormal() ;
if (aSelf.mode != aSelf.kMODE_DISABLED) if (aSelf.mode != aSelf.kMODE_DISABLED)
@ -273,7 +283,7 @@ AutoHideBrowser.prototype = {
{ {
this.mode = this.getMode(); this.mode = this.getMode();
this.end(); this.end();
this.mode = this.treeStyleTab.getPref('browser.fullscreen.autohide') ? this.mode = prefs.getPref('browser.fullscreen.autohide') ?
this.getModeForFullScreen() : this.getModeForFullScreen() :
this.kMODE_DISABLED ; this.kMODE_DISABLED ;
if (this.mode != this.kMODE_DISABLED) { if (this.mode != this.kMODE_DISABLED) {
@ -841,7 +851,7 @@ AutoHideBrowser.prototype = {
if (!this.window || !this.window.TreeStyleTabService) if (!this.window || !this.window.TreeStyleTabService)
return; return;
var value = this.treeStyleTab.getPref(aPrefName); var value = prefs.getPref(aPrefName);
switch (aPrefName) switch (aPrefName)
{ {
case 'extensions.treestyletab.tabbar.autoHide.mode': case 'extensions.treestyletab.tabbar.autoHide.mode':
@ -1160,7 +1170,7 @@ AutoHideBrowser.prototype = {
b.setAttribute(this.kMODE+'-normal', utils.getTreePref('tabbar.autoHide.mode')); b.setAttribute(this.kMODE+'-normal', utils.getTreePref('tabbar.autoHide.mode'));
b.setAttribute(this.kMODE+'-fullscreen', utils.getTreePref('tabbar.autoHide.mode.fullscreen')); b.setAttribute(this.kMODE+'-fullscreen', utils.getTreePref('tabbar.autoHide.mode.fullscreen'));
sv.addPrefListener(this); prefs.addPrefListener(this);
this.onPrefChange('browser.tabs.closeButtons'); this.onPrefChange('browser.tabs.closeButtons');
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area'); this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
this.onPrefChange('extensions.treestyletab.tabbar.togglerSize'); this.onPrefChange('extensions.treestyletab.tabbar.togglerSize');
@ -1183,7 +1193,7 @@ AutoHideBrowser.prototype = {
destroy : function AHB_destroy() destroy : function AHB_destroy()
{ {
this.end(); this.end();
this.treeStyleTab.removePrefListener(this); prefs.removePrefListener(this);
var sv = this.treeStyleTab; var sv = this.treeStyleTab;
var b = this.browser; var b = this.browser;

View File

@ -83,7 +83,6 @@ if (Services.appinfo.OS === 'WINNT') {
} }
var TreeStyleTabBase = { var TreeStyleTabBase = {
__proto__ : prefs,
tabsHash : null, tabsHash : null,
inWindowDestoructionProcess : false, inWindowDestoructionProcess : false,
@ -302,7 +301,7 @@ var TreeStyleTabBase = {
this.applyPlatformDefaultPrefs(); this.applyPlatformDefaultPrefs();
utils.migratePrefs(); utils.migratePrefs();
this.addPrefListener(this); prefs.addPrefListener(this);
this.initUninstallationListener(); this.initUninstallationListener();
@ -341,7 +340,7 @@ var TreeStyleTabBase = {
{ {
let originalKey = originalKeys[i]; let originalKey = originalKeys[i];
let key = originalKey.replace('platform.'+OS+'.', ''); let key = originalKey.replace('platform.'+OS+'.', '');
this.setDefaultPref(key, this.getPref(originalKey)); prefs.setDefaultPref(key, prefs.getPref(originalKey));
processed[key] = true; processed[key] = true;
} }
originalKeys = this.getDescendant('extensions.treestyletab.platform.default'); originalKeys = this.getDescendant('extensions.treestyletab.platform.default');
@ -350,7 +349,7 @@ var TreeStyleTabBase = {
let originalKey = originalKeys[i]; let originalKey = originalKeys[i];
let key = originalKey.replace('platform.default.', ''); let key = originalKey.replace('platform.default.', '');
if (!(key in processed)) if (!(key in processed))
this.setDefaultPref(key, this.getPref(originalKey)); prefs.setDefaultPref(key, prefs.getPref(originalKey));
} }
}, },
@ -580,7 +579,7 @@ var TreeStyleTabBase = {
if (checked.value) { if (checked.value) {
utils.setTreePref('openGroupBookmark.behavior', behavior); utils.setTreePref('openGroupBookmark.behavior', behavior);
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); prefs.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
} }
return behavior; return behavior;
}, },
@ -2499,7 +2498,7 @@ var TreeStyleTabBase = {
onPrefChange : function utils_onPrefChange(aPrefName) onPrefChange : function utils_onPrefChange(aPrefName)
{ {
var value = this.getPref(aPrefName); var value = prefs.getPref(aPrefName);
switch (aPrefName) switch (aPrefName)
{ {
case 'extensions.treestyletab.indent.vertical': case 'extensions.treestyletab.indent.vertical':
@ -2520,29 +2519,29 @@ var TreeStyleTabBase = {
case 'extensions.stm.tabBarMultiRows': // Super Tab Mode case 'extensions.stm.tabBarMultiRows': // Super Tab Mode
if (this.prefOverriding) return; if (this.prefOverriding) return;
aPrefName += '.override'; aPrefName += '.override';
this.setPref(aPrefName, value); prefs.setPref(aPrefName, value);
case 'browser.tabs.insertRelatedAfterCurrent.override': case 'browser.tabs.insertRelatedAfterCurrent.override':
case 'browser.tabs.loadFolderAndReplace.override': case 'browser.tabs.loadFolderAndReplace.override':
case 'extensions.stm.tabBarMultiRows.override': // Super Tab Mode case 'extensions.stm.tabBarMultiRows.override': // Super Tab Mode
if (this.getPref(aPrefName+'.force')) { if (prefs.getPref(aPrefName+'.force')) {
let defaultValue = this.getDefaultPref(aPrefName); let defaultValue = prefs.getDefaultPref(aPrefName);
if (value != defaultValue) { if (value != defaultValue) {
this.setPref(aPrefName, defaultValue); prefs.setPref(aPrefName, defaultValue);
return; return;
} }
} }
this.prefOverriding = true; this.prefOverriding = true;
let (target = aPrefName.replace('.override', '')) { let (target = aPrefName.replace('.override', '')) {
let originalValue = this.getPref(target); let originalValue = prefs.getPref(target);
if (originalValue !== null && originalValue != value) if (originalValue !== null && originalValue != value)
this.setPref(target+'.backup', originalValue); prefs.setPref(target+'.backup', originalValue);
this.setPref(target, this.getPref(aPrefName)); prefs.setPref(target, prefs.getPref(aPrefName));
} }
this.prefOverriding = false; this.prefOverriding = false;
return; return;
case 'extensions.treestyletab.clickOnIndentSpaces.enabled': case 'extensions.treestyletab.clickOnIndentSpaces.enabled':
return this.shouldDetectClickOnIndentSpaces = this.getPref(aPrefName); return this.shouldDetectClickOnIndentSpaces = prefs.getPref(aPrefName);
case 'extensions.treestyletab.tabbar.scroll.smooth': case 'extensions.treestyletab.tabbar.scroll.smooth':
return this.smoothScrollEnabled = value; return this.smoothScrollEnabled = value;

View File

@ -37,8 +37,9 @@ const EXPORTED_SYMBOLS = ['TreeStyleTabBrowser'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
@ -47,7 +48,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 'TabbarDNDObserver', 'resource://treesty
XPCOMUtils.defineLazyModuleGetter(this, 'TabpanelDNDObserver', 'resource://treestyletab-modules/tabpanelDNDObserver.js'); XPCOMUtils.defineLazyModuleGetter(this, 'TabpanelDNDObserver', 'resource://treestyletab-modules/tabpanelDNDObserver.js');
XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideBrowser', 'resource://treestyletab-modules/autoHide.js'); XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideBrowser', 'resource://treestyletab-modules/autoHide.js');
Components.utils.import('resource://treestyletab-modules/window.js'); XPCOMUtils.defineLazyGetter(this, 'window', function() {
Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp');
});
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Cu.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs;
});
Cu.import('resource://treestyletab-modules/window.js');
function TreeStyleTabBrowser(aWindowService, aTabBrowser) function TreeStyleTabBrowser(aWindowService, aTabBrowser)
{ {
@ -447,7 +457,7 @@ TreeStyleTabBrowser.prototype = {
{ {
var w = this.window; var w = this.window;
return ('tabberwocky' in w && utils.getTreePref('compatibility.Tabberwocky')) ? return ('tabberwocky' in w && utils.getTreePref('compatibility.Tabberwocky')) ?
(this.getPref('tabberwocky.multirow') && !this.isVertical) : (prefs.getPref('tabberwocky.multirow') && !this.isVertical) :
('TabmixTabbar' in w && utils.getTreePref('compatibility.TMP')) ? ('TabmixTabbar' in w && utils.getTreePref('compatibility.TMP')) ?
w.TabmixTabbar.isMultiRow : w.TabmixTabbar.isMultiRow :
false ; false ;
@ -721,7 +731,7 @@ TreeStyleTabBrowser.prototype = {
Services.obs.addObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY, false); Services.obs.addObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY, false);
Services.obs.addObserver(this, 'private-browsing-change-granted', false); Services.obs.addObserver(this, 'private-browsing-change-granted', false);
Services.obs.addObserver(this, 'lightweight-theme-styling-update', false); Services.obs.addObserver(this, 'lightweight-theme-styling-update', false);
this.addPrefListener(this); prefs.addPrefListener(this);
// Don't init these ovservers on this point to avoid needless initializations. // Don't init these ovservers on this point to avoid needless initializations.
// this.tabbarDNDObserver; // this.tabbarDNDObserver;
@ -1245,7 +1255,7 @@ TreeStyleTabBrowser.prototype = {
let newTabButton = d.getElementById('new-tab-button'); let newTabButton = d.getElementById('new-tab-button');
if (newTabButton && newTabButton.parentNode == b.tabContainer._container) if (newTabButton && newTabButton.parentNode == b.tabContainer._container)
newTabBox = newTabButton; newTabBox = newTabButton;
tabBarMode = this.getPref('extensions.tabmix.tabBarMode'); tabBarMode = prefs.getPref('extensions.tabmix.tabBarMode');
} }
// All-in-One Sidebar // All-in-One Sidebar
@ -1292,7 +1302,7 @@ TreeStyleTabBrowser.prototype = {
if (newTabBox) if (newTabBox)
newTabBox.orient = 'horizontal'; newTabBox.orient = 'horizontal';
if (tabBarMode == 2) if (tabBarMode == 2)
this.setPref('extensions.tabmix.tabBarMode', 1); prefs.setPref('extensions.tabmix.tabBarMode', 1);
} }
if (toolboxContainer) if (toolboxContainer)
@ -1770,7 +1780,7 @@ TreeStyleTabBrowser.prototype = {
if (splitter.collapsed || splitter.getAttribute('state') != 'collapsed') { if (splitter.collapsed || splitter.getAttribute('state') != 'collapsed') {
this._tabStripPlaceHolder.collapsed = this._tabStripPlaceHolder.collapsed =
splitter.collapsed = splitter.collapsed =
(this.getPref('browser.tabs.autoHide') && this.getExistingTabsCount() == 1); (prefs.getPref('browser.tabs.autoHide') && this.getExistingTabsCount() == 1);
} }
var strip = this.tabStrip; var strip = this.tabStrip;
@ -2052,7 +2062,7 @@ TreeStyleTabBrowser.prototype = {
Services.obs.removeObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY); Services.obs.removeObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY);
Services.obs.removeObserver(this, 'private-browsing-change-granted'); Services.obs.removeObserver(this, 'private-browsing-change-granted');
Services.obs.removeObserver(this, 'lightweight-theme-styling-update'); Services.obs.removeObserver(this, 'lightweight-theme-styling-update');
this.removePrefListener(this); prefs.removePrefListener(this);
delete this.windowService; delete this.windowService;
delete this.window; delete this.window;
@ -2323,7 +2333,7 @@ TreeStyleTabBrowser.prototype = {
return; return;
var b = this.mTabBrowser; var b = this.mTabBrowser;
var value = this.getPref(aPrefName); var value = prefs.getPref(aPrefName);
var tabContainer = b.mTabContainer; var tabContainer = b.mTabContainer;
var tabs = this.getAllTabs(b); var tabs = this.getAllTabs(b);
switch (aPrefName) switch (aPrefName)
@ -2431,7 +2441,7 @@ TreeStyleTabBrowser.prototype = {
case 'browser.tabs.animate': case 'browser.tabs.animate':
this.setTabbrowserAttribute(this.kANIMATION_ENABLED, this.setTabbrowserAttribute(this.kANIMATION_ENABLED,
this.getPref('browser.tabs.animate') !== false prefs.getPref('browser.tabs.animate') !== false
? 'true' : null ? 'true' : null
); );
return; return;
@ -2524,8 +2534,8 @@ TreeStyleTabBrowser.prototype = {
aStyle = 'osx'; aStyle = 'osx';
} }
else if ( else if (
this.getPref('extensions.informationaltab.thumbnail.enabled') && prefs.getPref('extensions.informationaltab.thumbnail.enabled') &&
this.getPref('extensions.informationaltab.thumbnail.position') < 100 prefs.getPref('extensions.informationaltab.thumbnail.position') < 100
) { ) {
let self = this; let self = this;
this.extensions.isAvailable('informationaltab@piro.sakura.ne.jp', { this.extensions.isAvailable('informationaltab@piro.sakura.ne.jp', {
@ -2844,7 +2854,7 @@ TreeStyleTabBrowser.prototype = {
this.updateInsertionPositionInfo(tab); this.updateInsertionPositionInfo(tab);
if (this.getPref('browser.tabs.autoHide')) if (prefs.getPref('browser.tabs.autoHide'))
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR); this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR);
if (this.canStackTabs) if (this.canStackTabs)
@ -3073,7 +3083,7 @@ TreeStyleTabBrowser.prototype = {
if (tab.getAttribute('pinned') == 'true') if (tab.getAttribute('pinned') == 'true')
this.positionPinnedTabsWithDelay(); this.positionPinnedTabsWithDelay();
if (this.getPref('browser.tabs.autoHide')) if (prefs.getPref('browser.tabs.autoHide'))
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR); this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR);
if (this.canStackTabs) if (this.canStackTabs)
@ -6251,7 +6261,7 @@ TreeStyleTabBrowser.prototype = {
this.needRestoreTree = false; this.needRestoreTree = false;
if (this.useTMPSessionAPI && this.getPref('extensions.tabmix.sessions.manager')) if (this.useTMPSessionAPI && prefs.getPref('extensions.tabmix.sessions.manager'))
return; return;
var level = utils.getTreePref('restoreTree.level'); var level = utils.getTreePref('restoreTree.level');

View File

@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab. * The Original Code is the Tree Style Tab.
* *
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2010-2012 * Portions created by the Initial Developer are Copyright (C) 2010-2013
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com> * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
@ -39,12 +39,22 @@ const DEBUG = false;
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm'); Cu.import('resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
XPCOMUtils.defineLazyGetter(this, 'window', function() {
Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp');
});
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Cu.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs;
});
const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab'; const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab';
const SSS = Cc['@mozilla.org/content/style-sheet-service;1'] const SSS = Cc['@mozilla.org/content/style-sheet-service;1']
@ -1064,7 +1074,7 @@ catch(e) {
var w = this.window; var w = this.window;
var self = this; var self = this;
let bgLoad = sv.getPref('browser.tabs.loadInBackground'); let bgLoad = prefs.getPref('browser.tabs.loadInBackground');
if (aEvent.shiftKey) bgLoad = !bgLoad; if (aEvent.shiftKey) bgLoad = !bgLoad;
let tab = sv.getTabFromEvent(aEvent); let tab = sv.getTabFromEvent(aEvent);

View File

@ -47,19 +47,17 @@ XPCOMUtils.defineLazyGetter(this, 'window', function() {
Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp'); return getNamespaceFor('piro.sakura.ne.jp');
}); });
XPCOMUtils.defineLazyGetter(this, 'prefs', function() { XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Cu.import('resource://treestyletab-modules/lib/prefs.js'); Cu.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs; return window['piro.sakura.ne.jp'].prefs;
}); });
XPCOMUtils.defineLazyGetter(this, 'stringBundle', function() { XPCOMUtils.defineLazyGetter(this, 'stringBundle', function() {
Cu.import('resource://treestyletab-modules/lib/stringBundle.js', {}); Cu.import('resource://treestyletab-modules/lib/stringBundle.js', {});
return window['piro.sakura.ne.jp'].stringBundle; return window['piro.sakura.ne.jp'].stringBundle;
}); });
XPCOMUtils.defineLazyModuleGetter(this, 'base', XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabConstants',
'resource://treestyletab-modules/base.js', 'TreeStyleTabBase'); 'resource://treestyletab-modules/constants.js', 'TreeStyleTabConstants');
const TST_PREF_PREFIX = 'extensions.treestyletab.'; const TST_PREF_PREFIX = 'extensions.treestyletab.';
const TST_PREF_VERSION = 9; const TST_PREF_VERSION = 9;

View File

@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab. * The Original Code is the Tree Style Tab.
* *
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2012 * Portions created by the Initial Developer are Copyright (C) 2012-2013
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com> * Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
@ -37,17 +37,24 @@ const EXPORTED_SYMBOLS = ['TreeStyleTabWindow'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(this, 'window', function() {
Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp');
});
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Cu.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs;
XPCOMUtils.defineLazyModuleGetter(this, "prefs",
'resource://treestyletab-modules/lib/prefs.js');
XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener', XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener',
'resource://treestyletab-modules/lib/UninstallationListener.js'); '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'); Cu.import('resource://treestyletab-modules/base.js');
XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabBrowser', 'resource://treestyletab-modules/browser.js'); XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabBrowser', 'resource://treestyletab-modules/browser.js');
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestyletab-modules/autoHide.js'); XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestyletab-modules/autoHide.js');
@ -280,7 +287,7 @@ TreeStyleTabWindow.prototype = {
{ {
return this.window.fullScreen ? return this.window.fullScreen ?
( (
this.getPref('browser.fullscreen.autohide') && prefs.getPref('browser.fullscreen.autohide') &&
utils.getTreePref('tabbar.autoHide.mode.fullscreen') utils.getTreePref('tabbar.autoHide.mode.fullscreen')
) : ) :
utils.getTreePref('tabbar.autoHide.mode'); utils.getTreePref('tabbar.autoHide.mode');
@ -361,7 +368,7 @@ TreeStyleTabWindow.prototype = {
w.addEventListener('UIOperationHistoryUndo:TabbarOperations', this, false); w.addEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
w.addEventListener('UIOperationHistoryRedo:TabbarOperations', this, false); w.addEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
this.addPrefListener(this); prefs.addPrefListener(this);
this.initUninstallationListener(); this.initUninstallationListener();
@ -521,7 +528,7 @@ TreeStyleTabWindow.prototype = {
w.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false); w.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
w.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false); w.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
this.removePrefListener(this); prefs.removePrefListener(this);
} }
catch(e) { catch(e) {
throw e; throw e;
@ -807,7 +814,7 @@ TreeStyleTabWindow.prototype = {
get ctrlTabPreviewsEnabled() get ctrlTabPreviewsEnabled()
{ {
return 'allTabs' in this.window && return 'allTabs' in this.window &&
this.getPref('browser.ctrlTab.previews'); prefs.getPref('browser.ctrlTab.previews');
}, },
onTabbarResizeStart : function TSTWindow_onTabbarResizeStart(aEvent) onTabbarResizeStart : function TSTWindow_onTabbarResizeStart(aEvent)
@ -915,7 +922,7 @@ TreeStyleTabWindow.prototype = {
var tab = aEvent.originalTarget; var tab = aEvent.originalTarget;
var b = this.getTabBrowserFromChild(tab); var b = this.getTabBrowserFromChild(tab);
if ( if (
this.getPref('browser.tabs.selectOwnerOnClose') && prefs.getPref('browser.tabs.selectOwnerOnClose') &&
tab.owner && tab.owner &&
( (
!b._removingTabs || !b._removingTabs ||
@ -952,7 +959,7 @@ TreeStyleTabWindow.prototype = {
var w = this.window; var w = this.window;
if ( if (
this.updateAeroPeekPreviewsTimer || this.updateAeroPeekPreviewsTimer ||
!this.getPref('browser.taskbar.previews.enable') || !prefs.getPref('browser.taskbar.previews.enable') ||
!utils.getTreePref('taskbarPreviews.hideCollapsedTabs') || !utils.getTreePref('taskbarPreviews.hideCollapsedTabs') ||
!('Win7Features' in w) || !('Win7Features' in w) ||
!w.Win7Features || !w.Win7Features ||
@ -976,7 +983,7 @@ TreeStyleTabWindow.prototype = {
updateAeroPeekPreviewsInternal : function TSTWindow_updateAeroPeekPreviewsInternal() updateAeroPeekPreviewsInternal : function TSTWindow_updateAeroPeekPreviewsInternal()
{ {
if ( if (
!this.getPref('browser.taskbar.previews.enable') || !prefs.getPref('browser.taskbar.previews.enable') ||
!utils.getTreePref('taskbarPreviews.hideCollapsedTabs') !utils.getTreePref('taskbarPreviews.hideCollapsedTabs')
) )
return; return;
@ -1016,9 +1023,9 @@ TreeStyleTabWindow.prototype = {
var TabsOnTop = w.TabsOnTop; var TabsOnTop = w.TabsOnTop;
var originalState = utils.getTreePref('tabsOnTop.originalState'); var originalState = utils.getTreePref('tabsOnTop.originalState');
if (originalState === null) { if (originalState === null) {
let current = this.getDefaultPref('browser.tabs.onTop') === null ? let current = prefs.getDefaultPref('browser.tabs.onTop') === null ?
TabsOnTop.enabled : TabsOnTop.enabled :
this.getPref('browser.tabs.onTop') ; prefs.getPref('browser.tabs.onTop') ;
utils.setTreePref('tabsOnTop.originalState', originalState = current); utils.setTreePref('tabsOnTop.originalState', originalState = current);
} }
@ -1361,7 +1368,7 @@ TreeStyleTabWindow.prototype = {
{ {
if ( if (
aTabsCount <= 1 || aTabsCount <= 1 ||
!this.getPref('browser.tabs.warnOnClose') !prefs.getPref('browser.tabs.warnOnClose')
) )
return true; return true;
var checked = { value:true }; var checked = { value:true };
@ -1378,7 +1385,7 @@ TreeStyleTabWindow.prototype = {
checked checked
) == 0; ) == 0;
if (shouldClose && !checked.value) if (shouldClose && !checked.value)
this.setPref('browser.tabs.warnOnClose', false); prefs.setPref('browser.tabs.warnOnClose', false);
return shouldClose; return shouldClose;
}, },
@ -1663,7 +1670,7 @@ TreeStyleTabWindow.prototype = {
onPrefChange : function TSTWindow_onPrefChange(aPrefName) onPrefChange : function TSTWindow_onPrefChange(aPrefName)
{ {
var value = this.getPref(aPrefName); var value = prefs.getPref(aPrefName);
switch (aPrefName) switch (aPrefName)
{ {
case 'extensions.treestyletab.tabbar.autoHide.mode': case 'extensions.treestyletab.tabbar.autoHide.mode':
@ -1677,7 +1684,7 @@ TreeStyleTabWindow.prototype = {
case 'extensions.treestyletab.tabbar.style': case 'extensions.treestyletab.tabbar.style':
case 'extensions.treestyletab.tabbar.position': case 'extensions.treestyletab.tabbar.position':
this.themeManager.set(this.getPref('extensions.treestyletab.tabbar.style'), this.position); this.themeManager.set(prefs.getPref('extensions.treestyletab.tabbar.style'), this.position);
break; break;
case 'browser.ctrlTab.previews': case 'browser.ctrlTab.previews':