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); 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". * Activates "auto-expand/collapse of tabs while dragging".
* When you're dragging something, a collapsed tree will be expanded * When you're dragging something, a collapsed tree will be expanded

View File

@ -283,6 +283,11 @@ TreeStyleTabBrowser.prototype = {
return !this.isVertical && this.canCollapseSubtree(); return !this.isVertical && this.canCollapseSubtree();
}, },
get counterRole()
{
return this.isVertical ? this.counterRoleVertical : this.counterRoleHorizontal ;
},
/* utils */ /* utils */
/* get tab contents */ /* get tab contents */
@ -1266,6 +1271,7 @@ TreeStyleTabBrowser.prototype = {
delayedPostProcess(self, b, splitter, toggler); delayedPostProcess(self, b, splitter, toggler);
self.updateTabbarOverflow(); self.updateTabbarOverflow();
self.updateAllTabsButton(b); self.updateAllTabsButton(b);
self.updateAllTabsCount();
delayedPostProcess = null; delayedPostProcess = null;
self.mTabBrowser.style.visibility = ''; self.mTabBrowser.style.visibility = '';
@ -2202,6 +2208,19 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.pinnedTab.faviconized': case 'extensions.treestyletab.pinnedTab.faviconized':
return this.positionPinnedTabsWithDelay(); 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: default:
return; return;
} }
@ -4922,7 +4941,10 @@ TreeStyleTabBrowser.prototype = {
{ {
var count = this.document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER); var count = this.document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER);
if (count) { 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) { if (!aDontUpdateAncestor) {
let parent = this.getParentTab(aTab); let parent = this.getParentTab(aTab);

View File

@ -244,6 +244,9 @@ var TreeStyleTabUtils = {
kRESTORE_TREE_ONLY_VISIBLE : 1, kRESTORE_TREE_ONLY_VISIBLE : 1,
kRESTORE_TREE_ALL : 2, kRESTORE_TREE_ALL : 2,
kCOUNTER_ROLE_ALL_TABS : 1,
kCOUNTER_ROLE_CONTAINED_TABS : 2,
MAX_TABBAR_SIZE_RATIO : 0.8, MAX_TABBAR_SIZE_RATIO : 0.8,
DEFAULT_SHRUNKEN_WIDTH_RATIO : 0.67, DEFAULT_SHRUNKEN_WIDTH_RATIO : 0.67,
@ -262,6 +265,9 @@ var TreeStyleTabUtils = {
scrollToNewTabMode : false, scrollToNewTabMode : false,
counterRoleHorizontal : -1,
counterRoleVertical : -1,
get SessionStore() { get SessionStore() {
if (!this._SessionStore) { if (!this._SessionStore) {
this._SessionStore = Cc['@mozilla.org/browser/sessionstore;1'].getService(Ci.nsISessionStore); this._SessionStore = Cc['@mozilla.org/browser/sessionstore;1'].getService(Ci.nsISessionStore);
@ -367,6 +373,8 @@ var TreeStyleTabUtils = {
this.onPrefChange('extensions.treestyletab.animation.indent.duration'); this.onPrefChange('extensions.treestyletab.animation.indent.duration');
this.onPrefChange('extensions.treestyletab.animation.collapse.duration'); this.onPrefChange('extensions.treestyletab.animation.collapse.duration');
this.onPrefChange('extensions.treestyletab.twisty.expandSensitiveArea'); this.onPrefChange('extensions.treestyletab.twisty.expandSensitiveArea');
this.onPrefChange('extensions.treestyletab.counter.role.horizontal');
this.onPrefChange('extensions.treestyletab.counter.role.vertical');
try { try {
if (this.XULAppInfo.OS == 'WINNT') if (this.XULAppInfo.OS == 'WINNT')
@ -2465,6 +2473,12 @@ var TreeStyleTabUtils = {
case 'extensions.treestyletab.twisty.expandSensitiveArea': case 'extensions.treestyletab.twisty.expandSensitiveArea':
return this.shouldExpandTwistyArea = value; 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: default:
return; return;
} }