Skip to content

Commit

Permalink
Add a pref to let the user choose whether the scope of "unload other …
Browse files Browse the repository at this point in the history
…tabs"

should be "visible tabs" (i.e. tabs in the currently active tab group) or
"tabs in the current window".
  • Loading branch information
inverseparadox committed Nov 13, 2012
1 parent 550a894 commit 5e7aef8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
18 changes: 17 additions & 1 deletion content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<preference id="extensions.bartab.findClosestLoadedTab"
name="extensions.bartab.findClosestLoadedTab"
type="bool" />
<preference id="extensions.bartab.unloadOnlyVisibleTabs"
name="extensions.bartab.unloadOnlyVisibleTabs"
type="bool" />
</preferences>

<groupbox id="BarTabGroup">
Expand Down Expand Up @@ -145,10 +148,23 @@
</menulist>
</row>

<row align="center">
<label value="&unloadingOtherTabs.label;"
accesskey="&unloadingOtherTabs.accesskey;"
control="menuUnloadingOtherTabs" />
<menulist id="menuUnloadingOtherTabs"
preference="extensions.bartab.unloadOnlyVisibleTabs">
<menupopup>
<menuitem label="&unloadAllTabsInWindow.label;" value="false"/>
<menuitem label="&unloadOnlyVisibleTabs.label;" value="true"/>
</menupopup>
</menulist>
</row>

</rows>
</grid>
</groupbox>

</prefpane>

</prefwindow>
</prefwindow>
1 change: 1 addition & 0 deletions defaults/preferences/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pref("extensions.bartab.whitelist", "");
pref("extensions.bartab.findClosestLoadedTab", true);
pref("extensions.bartab.loadOnSelectDelay", 0);
pref("extensions.bartab.migrated", false);
pref("extensions.bartab.unloadOnlyVisibleTabs", true);

// https://developer.mozilla.org/en/Localizing_extension_descriptions
pref("[email protected]", "chrome://bartab/locale/overlay.properties");
4 changes: 4 additions & 0 deletions locale/en-US/options.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
<!ENTITY closingTabs.label "When closing a tab:">
<!ENTITY closingTabs.accesskey "C">
<!ENTITY findClosestLoadedTab.label "select the nearest loaded tab">
<!ENTITY unloadingOtherTabs.label "When unloading all but the current tab:">
<!ENTITY unloadingOtherTabs.accesskey "U">
<!ENTITY unloadAllTabsInWindow.label "Unload tabs from all groups in the current window">
<!ENTITY unloadOnlyVisibleTabs.label "Unload only tabs from the currently active tab group">
10 changes: 8 additions & 2 deletions modules/prototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,14 @@ BarTabHandler.prototype = {
// unloadTab() mutates the tabs so the only sane thing to do is to
// copy the list of tabs now and then work off that list.
var tabs = [];
for (let i = 0; i < tabbrowser.visibleTabs.length; i++) {
tabs.push(tabbrowser.visibleTabs[i]);
if(BarTabUtils.mPrefs.getBoolPref("extensions.bartab.unloadOnlyVisibleTabs")) {
for (let i = 0; i < tabbrowser.visibleTabs.length; i++) {
tabs.push(tabbrowser.visibleTabs[i]);
}
} else {
for (let i = 0; i < tabbrowser.mTabs.length; i++) {
tabs.push(tabbrowser.mTabs[i]);
}
}
var self = this;
tabs.forEach(function(tab) {
Expand Down

0 comments on commit 5e7aef8

Please sign in to comment.