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