switch the role of the counter in tabs for vertical and horizontal tab bar

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-01-14 01:45:51 +09:00
parent 4d816760b5
commit 17c7280d05
3 changed files with 45 additions and 1 deletions

View File

@ -197,6 +197,14 @@ pref("extensions.treestyletab.allowSubtreeCollapseExpand.vertical", true);
*/
pref("extensions.treestyletab.showBorderForFirstTab", false);
/**
* The role of the "counter" in each tab.
* 1 = Indicate number of all tabs in the tree (including the parent tab itself)
* 2 = Indicate number of contained tabs in the collapsed tree (imitating file managers)
*/
pref("extensions.treestyletab.counter.role.horizontal", 1);
pref("extensions.treestyletab.counter.role.vertical", 2);
/**
* Activates "auto-expand/collapse of tabs while dragging".
* When you're dragging something, a collapsed tree will be expanded

View File

@ -282,6 +282,11 @@ TreeStyleTabBrowser.prototype = {
{
return !this.isVertical && this.canCollapseSubtree();
},
get counterRole()
{
return this.isVertical ? this.counterRoleVertical : this.counterRoleHorizontal ;
},
/* utils */
@ -1266,6 +1271,7 @@ TreeStyleTabBrowser.prototype = {
delayedPostProcess(self, b, splitter, toggler);
self.updateTabbarOverflow();
self.updateAllTabsButton(b);
self.updateAllTabsCount();
delayedPostProcess = null;
self.mTabBrowser.style.visibility = '';
@ -2202,6 +2208,19 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.pinnedTab.faviconized':
return this.positionPinnedTabsWithDelay();
case 'extensions.treestyletab.counter.role.horizontal':
if (!this.isVertical) {
let self = this;
this.Deferred.next(function() { self.updateAllTabsCount(); });
}
return;
case 'extensions.treestyletab.counter.role.vertical':
if (this.isVertical) {
let self = this;
this.Deferred.next(function() { self.updateAllTabsCount(); });
}
return;
default:
return;
}
@ -4922,7 +4941,10 @@ TreeStyleTabBrowser.prototype = {
{
var count = this.document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER);
if (count) {
count.setAttribute('value', this.getDescendantTabs(aTab).length + 1);
let value = this.getDescendantTabs(aTab).length;
if (this.counterRole == this.kCOUNTER_ROLE_ALL_TABS)
value += 1;
count.setAttribute('value', value);
}
if (!aDontUpdateAncestor) {
let parent = this.getParentTab(aTab);

View File

@ -244,6 +244,9 @@ var TreeStyleTabUtils = {
kRESTORE_TREE_ONLY_VISIBLE : 1,
kRESTORE_TREE_ALL : 2,
kCOUNTER_ROLE_ALL_TABS : 1,
kCOUNTER_ROLE_CONTAINED_TABS : 2,
MAX_TABBAR_SIZE_RATIO : 0.8,
DEFAULT_SHRUNKEN_WIDTH_RATIO : 0.67,
@ -261,6 +264,9 @@ var TreeStyleTabUtils = {
shouldExpandTwistyArea : true,
scrollToNewTabMode : false,
counterRoleHorizontal : -1,
counterRoleVertical : -1,
get SessionStore() {
if (!this._SessionStore) {
@ -367,6 +373,8 @@ var TreeStyleTabUtils = {
this.onPrefChange('extensions.treestyletab.animation.indent.duration');
this.onPrefChange('extensions.treestyletab.animation.collapse.duration');
this.onPrefChange('extensions.treestyletab.twisty.expandSensitiveArea');
this.onPrefChange('extensions.treestyletab.counter.role.horizontal');
this.onPrefChange('extensions.treestyletab.counter.role.vertical');
try {
if (this.XULAppInfo.OS == 'WINNT')
@ -2465,6 +2473,12 @@ var TreeStyleTabUtils = {
case 'extensions.treestyletab.twisty.expandSensitiveArea':
return this.shouldExpandTwistyArea = value;
case 'extensions.treestyletab.counter.role.horizontal':
return this.counterRoleHorizontal = value;
case 'extensions.treestyletab.counter.role.vertical':
return this.counterRoleVertical = value;
default:
return;
}