From 17c7280d0553daa88da5797ddaf2b5fb69488cd8 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Sat, 14 Jan 2012 01:45:51 +0900 Subject: [PATCH] switch the role of the counter in tabs for vertical and horizontal tab bar --- defaults/preferences/treestyletab.js | 8 ++++++++ modules/browser.js | 24 +++++++++++++++++++++++- modules/utils.js | 14 ++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 52f8bffd..b7b33ed9 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -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 diff --git a/modules/browser.js b/modules/browser.js index b7f66a20..12c8c768 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -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); diff --git a/modules/utils.js b/modules/utils.js index d279518e..1b867bd6 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -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; }