add "close other tabs except this tree" context menu item

This commit is contained in:
SHIMODA Hiroshi 2010-12-08 20:34:42 +09:00
parent aa73026cb9
commit 3acb6a2bfc
16 changed files with 81 additions and 0 deletions

View File

@ -245,6 +245,9 @@
<preference id="extensions.treestyletab.show.context-item-removeDescendantTabs"
name="extensions.treestyletab.show.context-item-removeDescendantTabs"
type="bool"/>
<preference id="extensions.treestyletab.show.context-item-removeAllTabsButThisTree"
name="extensions.treestyletab.show.context-item-removeAllTabsButThisTree"
type="bool"/>
<preference id="extensions.treestyletab.show.context-item-collapseAllSubtree"
name="extensions.treestyletab.show.context-item-collapseAllSubtree"
type="bool"/>
@ -282,9 +285,15 @@
preference="extensions.treestyletab.show.context-item-removeTabSubtree"
label="&context.removeTabSubtree.label;"/>
<checkbox id="extensions.treestyletab.show.context-item-removeDescendantTabs-check"
preference="extensions.treestyletab.show.context-item-removeDescendantTabs"
label="&context.removeDescendantTabs.label;"/>
</hbox>
<hbox align="center">
<checkbox id="extensions.treestyletab.show.context-item-removeAllTabsButThisTree-check"
preference="extensions.treestyletab.show.context-item-removeAllTabsButThisTree"
label="&context.removeAllTabsBut.label;"/>
</hbox>
<hbox align="center">
<checkbox id="extensions.treestyletab.show.context-item-collapseAllSubtree-check"
preference="extensions.treestyletab.show.context-item-collapseAllSubtree"

View File

@ -1528,6 +1528,26 @@ var TreeStyleTabService = {
},
_tabShouldBeExpandedAfterKeyReleased : null,
removeAllTabsBut : function TSTService_removeAllTabsBut(aTab)
{
var keepTabs = [aTab].concat(this.getDescendantTabs(aTab));
var b = this.getTabBrowserFromChild(aTab);
var closeTabs = this.getTabsArray(b)
.filter(function(aTab) {
return keepTabs.indexOf(aTab) < 0;
});
if (!this.warnAboutClosingTabs(closeTabs.length))
return;
this.stopRendering();
this.markAsClosedSet(closeTabs);
closeTabs.reverse().forEach(function(aTab) {
b.removeTab(aTab);
});
this.startRendering();
},
// For backward compatibility. You should use DOM event to block TST's focus handling.
registerTabFocusAllowance : function TSTService_registerTabFocusAllowance(aProcess) /* PUBLIC API */
{

View File

@ -107,6 +107,13 @@
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context-item-removeTabSubtree')][1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-removeAllTabsButThisTree"
label="&context.removeAllTabsBut.label;"
accesskey="&context.removeAllTabsBut.accesskey;"
oncommand="TreeStyleTabService.removeAllTabsBut(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context_closeOtherTabs')][1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-bookmarkTabSubtree"
label="&context.bookmarkTabSubtree.label;"

View File

@ -10,6 +10,7 @@ TreeStyleTabBrowser.prototype = {
kMENUITEM_RELOADCHILDREN : 'context-item-reloadDescendantTabs',
kMENUITEM_REMOVESUBTREE : 'context-item-removeTabSubtree',
kMENUITEM_REMOVECHILDREN : 'context-item-removeDescendantTabs',
kMENUITEM_REMOVEALLTABSBUT : 'context-item-removeAllTabsButThisTree',
kMENUITEM_COLLAPSEEXPAND_SEPARATOR : 'context-separator-collapseExpandAll',
kMENUITEM_COLLAPSE : 'context-item-collapseAllSubtree',
kMENUITEM_EXPAND : 'context-item-expandAllSubtree',
@ -585,6 +586,7 @@ TreeStyleTabBrowser.prototype = {
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
aSelf.kMENUITEM_REMOVECHILDREN,
aSelf.kMENUITEM_REMOVEALLTABSBUT,
aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR,
aSelf.kMENUITEM_COLLAPSE,
aSelf.kMENUITEM_EXPAND,
@ -3155,6 +3157,7 @@ TreeStyleTabBrowser.prototype = {
this.kMENUITEM_RELOADCHILDREN,
this.kMENUITEM_REMOVESUBTREE,
this.kMENUITEM_REMOVECHILDREN,
this.kMENUITEM_REMOVEALLTABSBUT,
this.kMENUITEM_COLLAPSE,
this.kMENUITEM_EXPAND,
this.kMENUITEM_AUTOHIDE,
@ -3177,6 +3180,7 @@ TreeStyleTabBrowser.prototype = {
case this.kMENUITEM_RELOADCHILDREN:
case this.kMENUITEM_REMOVESUBTREE:
case this.kMENUITEM_REMOVECHILDREN:
case this.kMENUITEM_REMOVEALLTABSBUT:
case this.kMENUITEM_COLLAPSE:
case this.kMENUITEM_EXPAND:
case this.kMENUITEM_BOOKMARKSUBTREE:
@ -3228,6 +3232,14 @@ TreeStyleTabBrowser.prototype = {
sep.removeAttribute('hidden');
}
// close all tabs but this tree
let removeAllTabsBut = items[this.kMENUITEM_REMOVEALLTABSBUT];
let rootTabs = this.visibleRootTabs;
if (rootTabs.length == 1 && rootTabs[0] == b.mContextTab)
removeAllTabsBut.setAttribute('disabled', true);
else
removeAllTabsBut.removeAttribute('disabled');
// auto hide
let autohide = items[this.kMENUITEM_AUTOHIDE];
this.autoHide.updateMenuItem(autohide);

View File

@ -77,6 +77,7 @@ pref("extensions.treestyletab.show.context-item-reloadTabSubtree", true);
pref("extensions.treestyletab.show.context-item-reloadDescendantTabs", false);
pref("extensions.treestyletab.show.context-item-removeTabSubtree", true);
pref("extensions.treestyletab.show.context-item-removeDescendantTabs", false);
pref("extensions.treestyletab.show.context-item-removeAllTabsButThisTree", false);
pref("extensions.treestyletab.show.context-item-collapseAllSubtree", true);
pref("extensions.treestyletab.show.context-item-expandAllSubtree", true);
pref("extensions.treestyletab.show.context-item-toggleAutoHide", true);

View File

@ -145,6 +145,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Untergeordnete Tabs schließen">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Alle Zweige zuklappen">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "Alle Zweige aufklappen">

View File

@ -146,6 +146,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Close Children">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Collapse All Trees">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "Expand All Trees">

View File

@ -151,6 +151,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Cerrar hija">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Colapsar todos los árboles">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "Expandir todos los árboles">

View File

@ -145,6 +145,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Fermer les enfants">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Replier toutes les arborescences">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "Déplier toutes les arborescences">

View File

@ -149,6 +149,8 @@
<!ENTITY context.removeTabSubtree.accesskey "u">
<!ENTITY context.removeDescendantTabs.label "Chiudi sottoschede">
<!ENTITY context.removeDescendantTabs.accesskey "i">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Contrai tutti i sottoalberi">
<!ENTITY context.collapseAllSubtree.accesskey "o">
<!ENTITY context.expandAllSubtree.label "Espandi tutti i sottoalberi">

View File

@ -145,6 +145,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "このタブの子タブをすべて閉じる">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "このツリー以外の他のタブをすべて閉じる">
<!ENTITY context.removeAllTabsBut.accesskey "b">
<!ENTITY context.collapseAllSubtree.label "ツリーをすべてたたむ">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "ツリーをすべて展開する">

View File

@ -139,6 +139,8 @@
<!ENTITY context.removeTabSubtree.accesskey "N">
<!ENTITY context.removeDescendantTabs.label "Zamknij potomne">
<!ENTITY context.removeDescendantTabs.accesskey "O">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Zwiń wszystkie drzewa">
<!ENTITY context.collapseAllSubtree.accesskey "T">
<!ENTITY context.expandAllSubtree.label "Rozwiń wszystkie drzewa">

View File

@ -145,6 +145,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Закрыть дочерние вкладки">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "Свернуть все деревья">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "Раскрыть все деревья">

View File

@ -145,6 +145,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "关闭子标签">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "折叠所有树">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "展开所有树">

View File

@ -147,6 +147,8 @@
<!ENTITY context.removeTabSubtree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "關閉所有子分頁">
<!ENTITY context.removeDescendantTabs.accesskey "d">
<!ENTITY context.removeAllTabsBut.label "Close Other Tabs except this Tree">
<!ENTITY context.removeAllTabsBut.accesskey "a">
<!ENTITY context.collapseAllSubtree.label "摺疊全部樹狀目錄">
<!ENTITY context.collapseAllSubtree.accesskey "c">
<!ENTITY context.expandAllSubtree.label "展開全部樹狀目錄">

View File

@ -1384,6 +1384,18 @@ var TreeStyleTabUtils = {
);
},
get allRootTabs() /* PUBLIC API */
{
return this.rootTabs;
},
get visibleRootTabs() /* PUBLIC API */
{
return this.rootTabs.filter(function(aTab) {
return !aTab.hidden;
});
},
canCollapseSubtree : function TSTUtils_canCollapseSubtree(aTabOrTabBrowser) /* PUBLIC API */
{
if (aTabOrTabBrowser &&