タブバーの位置、サイズ、固定の状態、自動で隠す状態について、最後に閉じられたウィンドウの状態を設定値に保存するようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6668 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
b89ec7dd87
commit
c74e103989
@ -67,6 +67,11 @@ var TreeStyleTabService = {
|
||||
return 'SplitBrowser' in window ? window.SplitBrowser.activeBrowser :
|
||||
window.gBrowser ;
|
||||
},
|
||||
|
||||
get shouldApplyNewPref()
|
||||
{
|
||||
return window == this.topBrowserWindow && !this.utils.inWindowDestoructionProcess;
|
||||
},
|
||||
|
||||
/* backward compatibility */
|
||||
getTempTreeStyleTab : function TSTService_getTempTreeStyleTab(aTabBrowser)
|
||||
@ -1236,27 +1241,37 @@ catch(e) {
|
||||
|
||||
destroy : function TSTService_destroy()
|
||||
{
|
||||
window.removeEventListener('unload', this, false);
|
||||
this.utils.inWindowDestoructionProcess = true;
|
||||
try {
|
||||
window.removeEventListener('unload', this, false);
|
||||
|
||||
window['piro.sakura.ne.jp'].animationManager.stop();
|
||||
this.destroyTabBrowser(gBrowser);
|
||||
window['piro.sakura.ne.jp'].animationManager.stop();
|
||||
gBrowser.treeStyleTab.saveCurrentState();
|
||||
this.destroyTabBrowser(gBrowser);
|
||||
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
|
||||
document.removeEventListener('popupshowing', this, false);
|
||||
document.removeEventListener('popuphiding', this, false);
|
||||
document.removeEventListener('TreeStyleTabCollapsedStateChange', this, false);
|
||||
document.removeEventListener('popupshowing', this, false);
|
||||
document.removeEventListener('popuphiding', this, false);
|
||||
document.removeEventListener('TreeStyleTabCollapsedStateChange', this, false);
|
||||
|
||||
var appcontent = document.getElementById('appcontent');
|
||||
appcontent.removeEventListener('SubBrowserAdded', this, false);
|
||||
appcontent.removeEventListener('SubBrowserRemoveRequest', this, false);
|
||||
var appcontent = document.getElementById('appcontent');
|
||||
appcontent.removeEventListener('SubBrowserAdded', this, false);
|
||||
appcontent.removeEventListener('SubBrowserRemoveRequest', this, false);
|
||||
|
||||
window.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
|
||||
window.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
|
||||
window.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
|
||||
window.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
|
||||
|
||||
this.removePrefListener(this);
|
||||
this.ObserverService.removeObserver(this, 'sessionstore-windows-restored');
|
||||
this.removePrefListener(this);
|
||||
this.ObserverService.removeObserver(this, 'sessionstore-windows-restored');
|
||||
}
|
||||
catch(e) {
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this.utils.inWindowDestoructionProcess = false;
|
||||
}
|
||||
},
|
||||
|
||||
destroyTabBrowser : function TSTService_destroyTabBrowser(aTabBrowser)
|
||||
@ -1273,20 +1288,16 @@ catch(e) {
|
||||
switch (aEvent.type)
|
||||
{
|
||||
case 'DOMContentLoaded':
|
||||
this.preInit();
|
||||
return;
|
||||
return this.preInit();
|
||||
|
||||
case 'load':
|
||||
this.init();
|
||||
return;
|
||||
return this.init();
|
||||
|
||||
case 'unload':
|
||||
this.destroy();
|
||||
return;
|
||||
return this.destroy();
|
||||
|
||||
case 'SSTabRestoring':
|
||||
this.onTabRestored(aEvent);
|
||||
return;
|
||||
return this.onTabRestored(aEvent);
|
||||
|
||||
case 'popupshowing':
|
||||
if (aEvent.originalTarget.boxObject &&
|
||||
@ -1322,21 +1333,17 @@ catch(e) {
|
||||
return this.updateAeroPeekPreviews();
|
||||
|
||||
case 'keydown':
|
||||
this.onKeyDown(aEvent);
|
||||
return;
|
||||
return this.onKeyDown(aEvent);
|
||||
|
||||
case 'keyup':
|
||||
case 'keypress':
|
||||
this.onKeyRelease(aEvent);
|
||||
return;
|
||||
return this.onKeyRelease(aEvent);
|
||||
|
||||
case 'SubBrowserAdded':
|
||||
this.initTabBrowser(aEvent.originalTarget.browser);
|
||||
return;
|
||||
return this.initTabBrowser(aEvent.originalTarget.browser);
|
||||
|
||||
case 'SubBrowserRemoveRequest':
|
||||
this.destroyTabBrowser(aEvent.originalTarget.browser);
|
||||
return;
|
||||
return this.destroyTabBrowser(aEvent.originalTarget.browser);
|
||||
|
||||
case 'UIOperationHistoryUndo:TabbarOperations':
|
||||
switch (aEvent.entry.name)
|
||||
@ -1345,7 +1352,7 @@ catch(e) {
|
||||
this.currentTabbarPosition = aEvent.entry.data.oldPosition;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
return;
|
||||
|
||||
case 'UIOperationHistoryRedo:TabbarOperations':
|
||||
switch (aEvent.entry.name)
|
||||
@ -1354,6 +1361,7 @@ catch(e) {
|
||||
this.currentTabbarPosition = aEvent.entry.data.newPosition;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
// Firefox 3.5 or later
|
||||
case 'dragstart': return this.onTabDragStart(aEvent);
|
||||
|
@ -1363,6 +1363,27 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
delete aTab.__treestyletab__linkedTabBrowser;
|
||||
},
|
||||
|
||||
saveCurrentState : function TSTBrowser_saveCurrentState()
|
||||
{
|
||||
this.autoHide.saveCurrentState();
|
||||
|
||||
var b = this.mTabBrowser;
|
||||
let box = (this.tabStripPlaceHolder || this.getTabStrip(b)).boxObject;
|
||||
let prefs = {
|
||||
'tabbar.fixed.horizontal' : b.getAttribute(this.kFIXED+'-horizontal') == 'true',
|
||||
'tabbar.fixed.vertical' : b.getAttribute(this.kFIXED+'-vertical') == 'true',
|
||||
'tabbar.width' : this.isVertical && this.autoHide.expanded && box.width ? box.width : void(0),
|
||||
'tabbar.shrunkenWidth' : this.isVertical && !this.autoHide.expanded && box.width ? box.width : void(0),
|
||||
'tabbar.height' : !this.isVertical && this.autoHide.expanded && box.height ? box.height : void(0)
|
||||
};
|
||||
for (var i in prefs)
|
||||
{
|
||||
if (prefs[i] !== void(0) && this.getTreePref(i) != prefs[i])
|
||||
this.setTreePref(i, prefs[i]);
|
||||
}
|
||||
this.currentTabbarPosition = this.currentTabbarPosition;
|
||||
},
|
||||
|
||||
/* nsIObserver */
|
||||
|
||||
@ -1411,7 +1432,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
switch (aPrefName)
|
||||
{
|
||||
case 'extensions.treestyletab.tabbar.position':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
var oldPosition = this.currentTabbarPosition;
|
||||
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', oldPosition, value); /* PUBLIC API */
|
||||
this.initTabbar(this.getPositionFlag(value), this.getPositionFlag(oldPosition));
|
||||
@ -1463,7 +1484,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
break;
|
||||
|
||||
case 'extensions.treestyletab.tabbar.fixed.horizontal':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
this.setTabbrowserAttribute(this.kFIXED+'-horizontal', value ? 'true' : null, b);
|
||||
case 'extensions.treestyletab.enableSubtreeIndent.horizontal':
|
||||
case 'extensions.treestyletab.allowSubtreeCollapseExpand.horizontal':
|
||||
@ -1472,7 +1493,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
break;
|
||||
|
||||
case 'extensions.treestyletab.tabbar.fixed.vertical':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
this.setTabbrowserAttribute(this.kFIXED+'-vertical', value ? 'true' : null, b);
|
||||
case 'extensions.treestyletab.enableSubtreeIndent.vertical':
|
||||
case 'extensions.treestyletab.allowSubtreeCollapseExpand.vertical':
|
||||
@ -1482,7 +1503,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
case 'extensions.treestyletab.tabbar.width':
|
||||
case 'extensions.treestyletab.tabbar.shrunkenWidth':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
if (!this.autoHide.isResizing && this.isVertical) {
|
||||
this.removeTabStripAttribute('width');
|
||||
this.setTabStripAttribute('width', this.autoHide.widthFromMode);
|
||||
@ -1492,7 +1513,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
break;
|
||||
|
||||
case 'extensions.treestyletab.tabbar.height':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
this._horizontalTabMaxIndentBase = 0;
|
||||
this.checkTabsIndentOverflow();
|
||||
break;
|
||||
|
@ -49,14 +49,12 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
getModeForNormal : function TSTAutoHide_getModeForNormal(aTabBrowser)
|
||||
{
|
||||
var b = aTabBrowser || this.mOwner.browser;
|
||||
return b.getAttribute(this.kMODE+'-normal') ||
|
||||
this.getTreePref('tabbar.autoHide.mode');
|
||||
return parseInt(b.getAttribute(this.kMODE+'-normal') || this.getTreePref('tabbar.autoHide.mode'));
|
||||
},
|
||||
getModeForFullscreen : function TSTAutoHide_getModeForFullscreen(aTabBrowser)
|
||||
getModeForFullScreen : function TSTAutoHide_getModeForFullScreen(aTabBrowser)
|
||||
{
|
||||
var b = aTabBrowser || this.mOwner.browser;
|
||||
return b.getAttribute(this.kMODE+'-fullscreen') ||
|
||||
this.getTreePref('tabbar.autoHide.mode.fullscreen');
|
||||
return parseInt(b.getAttribute(this.kMODE+'-fullscreen') || this.getTreePref('tabbar.autoHide.mode.fullscreen'));
|
||||
},
|
||||
|
||||
get state()
|
||||
@ -82,7 +80,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
// update internal property after the appearance of the tab bar is updated.
|
||||
window.setTimeout(function(aSelf) {
|
||||
aSelf.mode = (window.fullScreen && aSelf.getPref('browser.fullscreen.autohide')) ?
|
||||
aSelf.getModeForFullscreen() :
|
||||
aSelf.getModeForFullScreen() :
|
||||
aSelf.getModeForNormal() ;
|
||||
if (aSelf.mode != aSelf.kMODE_DISABLED)
|
||||
aSelf.start();
|
||||
@ -205,7 +203,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
this.mode = this.getMode();
|
||||
this.end();
|
||||
this.mode = this.getPref('browser.fullscreen.autohide') ?
|
||||
this.getModeForFullscreen() :
|
||||
this.getModeForFullScreen() :
|
||||
this.kMODE_DISABLED ;
|
||||
if (this.mode != this.kMODE_DISABLED) {
|
||||
this.start();
|
||||
@ -215,7 +213,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
|
||||
endForFullScreen : function TSTAutoHide_endForFullScreen()
|
||||
{
|
||||
this.mode = this.getModeForFullscreen();
|
||||
this.mode = this.getModeForFullScreen();
|
||||
this.end();
|
||||
this.mode = this.getTreePref('tabbar.autoHide.mode');
|
||||
this.mOwner.checkTabsIndentOverflow();
|
||||
@ -859,13 +857,13 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
switch (aPrefName)
|
||||
{
|
||||
case 'extensions.treestyletab.tabbar.autoHide.mode':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
this.mOwner.browser.setAttribute(this.kMODE+'-normal', value);
|
||||
this.updateMode();
|
||||
return;
|
||||
|
||||
case 'extensions.treestyletab.tabbar.autoHide.mode.fullscreen':
|
||||
if (window != this.topBrowserWindow) return;
|
||||
if (!this.shouldApplyNewPref) return;
|
||||
this.mOwner.browser.setAttribute(this.kMODE+'-fullscreen', value);
|
||||
this.updateMode();
|
||||
return;
|
||||
@ -901,7 +899,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
if (!window.fullScreen) return;
|
||||
this.end();
|
||||
this.mode = value ?
|
||||
this.getModeForFullscreen() :
|
||||
this.getModeForFullScreen() :
|
||||
this.kMODE_DISABLED ;
|
||||
if (this.mode != this.kMODE_DISABLED)
|
||||
this.start();
|
||||
@ -1237,6 +1235,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
{
|
||||
this.end();
|
||||
this.removePrefListener(this);
|
||||
|
||||
var b = this.mOwner.browser;
|
||||
b.mTabContainer.removeEventListener('TabOpen', this, false);
|
||||
b.mTabContainer.removeEventListener('TabClose', this, false);
|
||||
@ -1247,6 +1246,20 @@ TreeStyleTabBrowserAutoHide.prototype = {
|
||||
b.removeEventListener('TreeStyleTabFocusSwitchingKeyDown', this, false);
|
||||
b.removeEventListener('TreeStyleTabFocusSwitchingStart', this, false);
|
||||
b.removeEventListener('TreeStyleTabFocusSwitchingEnd', this, false);
|
||||
},
|
||||
|
||||
saveCurrentState : function TSTAutoHide_saveCurrentState()
|
||||
{
|
||||
var b = this.mOwner.browser;
|
||||
var prefs = {
|
||||
'tabbar.autoHide.mode' : this.getModeForNormal(b),
|
||||
'tabbar.autoHide.mode.fullscreen' : this.getModeForFullScreen(b),
|
||||
};
|
||||
for (var i in prefs)
|
||||
{
|
||||
if (this.getTreePref(i) != prefs[i])
|
||||
this.setTreePref(i, prefs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -52,6 +52,7 @@ stringBundle = stringBundle.window['piro.sakura.ne.jp'].stringBundle;
|
||||
|
||||
var TreeStyleTabUtils = {
|
||||
tabsHash : null,
|
||||
inWindowDestoructionProcess : false,
|
||||
|
||||
/* attributes */
|
||||
kID : 'treestyletab-id',
|
||||
@ -1720,12 +1721,12 @@ var TreeStyleTabUtils = {
|
||||
},
|
||||
set currentTabbarPosition(aValue)
|
||||
{
|
||||
var position = String(aValue);
|
||||
if (!position || !/^(top|bottom|left|right)$/i.test(position))
|
||||
var position = String(aValue).toLowerCase();
|
||||
if (!position || !/^(top|bottom|left|right)$/.test(position))
|
||||
position = 'top';
|
||||
|
||||
position = position.toLowerCase();
|
||||
this.setTreePref('tabbar.position', position);
|
||||
if (position != this.getTreePref('tabbar.position'))
|
||||
this.setTreePref('tabbar.position', position);
|
||||
|
||||
return aValue;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user