mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-04 01:24:12 +01:00
Add config.browser, config.tabbrowser. Fix mailbird. &c.
This commit is contained in:
@@ -17,10 +17,7 @@ const Tabs = Module("tabs", {
|
||||
requires: ["config"],
|
||||
|
||||
init: function () {
|
||||
if (config.getBrowser)
|
||||
this.getBrowser = config.getBrowser;
|
||||
|
||||
this._alternates = [this.getBrowser().mCurrentTab, null];
|
||||
this._alternates = [config.tabbrowser.mCurrentTab, null];
|
||||
|
||||
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command
|
||||
this._lastBufferSwitchArgs = "";
|
||||
@@ -29,7 +26,7 @@ const Tabs = Module("tabs", {
|
||||
// hide tabs initially to prevent flickering when 'stal' would hide them
|
||||
// on startup
|
||||
if (config.hasTabbrowser)
|
||||
this.getBrowser().mTabContainer.collapsed = true; // FIXME: see 'stal' comment
|
||||
config.tabbrowser.mTabContainer.collapsed = true; // FIXME: see 'stal' comment
|
||||
},
|
||||
|
||||
_updateTabCount: function () {
|
||||
@@ -57,7 +54,7 @@ const Tabs = Module("tabs", {
|
||||
* in the current window.
|
||||
*/
|
||||
get browsers() {
|
||||
let browsers = this.getBrowser().browsers;
|
||||
let browsers = config.tabbrowser.browsers;
|
||||
for (let i = 0; i < browsers.length; i++)
|
||||
yield [i, browsers[i]];
|
||||
},
|
||||
@@ -81,7 +78,7 @@ const Tabs = Module("tabs", {
|
||||
/**
|
||||
* @property {number} The number of tabs in the current window.
|
||||
*/
|
||||
get count() this.getBrowser().mTabs.length,
|
||||
get count() config.tabbrowser.mTabs.length,
|
||||
|
||||
/**
|
||||
* @property {Object} The local options store for the current tab.
|
||||
@@ -93,8 +90,6 @@ const Tabs = Module("tabs", {
|
||||
return store.options;
|
||||
},
|
||||
|
||||
getBrowser: getBrowser,
|
||||
|
||||
/**
|
||||
* Returns the local state store for the tab at the specified
|
||||
* <b>tabIndex</b>. If <b>tabIndex</b> is not specified then the
|
||||
@@ -137,9 +132,9 @@ const Tabs = Module("tabs", {
|
||||
*/
|
||||
index: function (tab) {
|
||||
if (tab)
|
||||
return Array.indexOf(this.getBrowser().mTabs, tab);
|
||||
return Array.indexOf(config.tabbrowser.mTabs, tab);
|
||||
else
|
||||
return this.getBrowser().mTabContainer.selectedIndex;
|
||||
return config.tabbrowser.mTabContainer.selectedIndex;
|
||||
},
|
||||
|
||||
// TODO: implement filter
|
||||
@@ -186,9 +181,9 @@ const Tabs = Module("tabs", {
|
||||
*/
|
||||
getTab: function (index) {
|
||||
if (index != undefined)
|
||||
return this.getBrowser().mTabs[index];
|
||||
return config.tabbrowser.mTabs[index];
|
||||
else
|
||||
return this.getBrowser().mCurrentTab;
|
||||
return config.tabbrowser.mCurrentTab;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -212,7 +207,7 @@ const Tabs = Module("tabs", {
|
||||
*/
|
||||
move: function (tab, spec, wrap) {
|
||||
let index = Tabs.indexFromSpec(spec, wrap);
|
||||
this.getBrowser().moveTabTo(tab, index);
|
||||
config.tabbrowser.moveTabTo(tab, index);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -230,31 +225,31 @@ const Tabs = Module("tabs", {
|
||||
remove: function (tab, count, focusLeftTab, quitOnLastTab) {
|
||||
let removeOrBlankTab = {
|
||||
Firefox: function (tab) {
|
||||
if (tabs.getBrowser().mTabs.length > 1)
|
||||
tabs.getBrowser().removeTab(tab);
|
||||
if (config.tabbrowser.mTabs.length > 1)
|
||||
config.tabbrowser.removeTab(tab);
|
||||
else {
|
||||
if (buffer.URL != "about:blank" ||
|
||||
window.getWebNavigation().sessionHistory.count > 0) {
|
||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||
tabs.getBrowser().removeTab(tab);
|
||||
config.tabbrowser.removeTab(tab);
|
||||
}
|
||||
else
|
||||
liberator.beep();
|
||||
}
|
||||
},
|
||||
Thunderbird: function (tab) {
|
||||
if (tabs.getBrowser().mTabs.length > 1)
|
||||
tabs.getBrowser().removeTab(tab);
|
||||
if (config.tabbrowser.mTabs.length > 1)
|
||||
config.tabbrowser.removeTab(tab);
|
||||
else
|
||||
liberator.beep();
|
||||
},
|
||||
Songbird: function (tab) {
|
||||
if (tabs.getBrowser().mTabs.length > 1)
|
||||
tabs.getBrowser().removeTab(tab);
|
||||
if (config.tabbrowser.mTabs.length > 1)
|
||||
config.tabbrowser.removeTab(tab);
|
||||
else {
|
||||
if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
|
||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||
tabs.getBrowser().removeTab(tab);
|
||||
config.tabbrowser.removeTab(tab);
|
||||
}
|
||||
else
|
||||
liberator.beep();
|
||||
@@ -265,7 +260,7 @@ const Tabs = Module("tabs", {
|
||||
if (typeof count != "number" || count < 1)
|
||||
count = 1;
|
||||
|
||||
if (quitOnLastTab >= 1 && this.getBrowser().mTabs.length <= count) {
|
||||
if (quitOnLastTab >= 1 && config.tabbrowser.mTabs.length <= count) {
|
||||
if (liberator.windows.length > 1)
|
||||
window.close();
|
||||
else
|
||||
@@ -281,7 +276,7 @@ const Tabs = Module("tabs", {
|
||||
removeOrBlankTab(this.getTab(i));
|
||||
lastRemovedTab = i > 0 ? i : 1;
|
||||
}
|
||||
this.getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1;
|
||||
config.tabbrowser.mTabContainer.selectedIndex = lastRemovedTab - 1;
|
||||
}
|
||||
else {
|
||||
let i = index + count - 1;
|
||||
@@ -290,7 +285,7 @@ const Tabs = Module("tabs", {
|
||||
|
||||
for (; i >= index; i--)
|
||||
removeOrBlankTab(this.getTab(i));
|
||||
this.getBrowser().mTabContainer.selectedIndex = index;
|
||||
config.tabbrowser.mTabContainer.selectedIndex = index;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -300,7 +295,7 @@ const Tabs = Module("tabs", {
|
||||
* @param {Object} tab The tab to keep.
|
||||
*/
|
||||
keepOnly: function (tab) {
|
||||
this.getBrowser().removeAllTabsBut(tab);
|
||||
config.tabbrowser.removeAllTabsBut(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -316,7 +311,7 @@ const Tabs = Module("tabs", {
|
||||
// FIXME:
|
||||
if (index == -1)
|
||||
return void liberator.beep();
|
||||
this.getBrowser().mTabContainer.selectedIndex = index;
|
||||
config.tabbrowser.mTabContainer.selectedIndex = index;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -329,10 +324,10 @@ const Tabs = Module("tabs", {
|
||||
reload: function (tab, bypassCache) {
|
||||
if (bypassCache) {
|
||||
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
||||
this.getBrowser().getBrowserForTab(tab).reloadWithFlags(flags);
|
||||
config.tabbrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
||||
}
|
||||
else
|
||||
this.getBrowser().reloadTab(tab);
|
||||
config.tabbrowser.reloadTab(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -343,9 +338,9 @@ const Tabs = Module("tabs", {
|
||||
*/
|
||||
reloadAll: function (bypassCache) {
|
||||
if (bypassCache) {
|
||||
for (let i = 0; i < this.getBrowser().mTabs.length; i++) {
|
||||
for (let i = 0; i < config.tabbrowser.mTabs.length; i++) {
|
||||
try {
|
||||
this.reload(this.getBrowser().mTabs[i], bypassCache);
|
||||
this.reload(config.tabbrowser.mTabs[i], bypassCache);
|
||||
}
|
||||
catch (e) {
|
||||
// FIXME: can we do anything useful here without stopping the
|
||||
@@ -354,7 +349,7 @@ const Tabs = Module("tabs", {
|
||||
}
|
||||
}
|
||||
else
|
||||
this.getBrowser().reloadAllTabs();
|
||||
config.tabbrowser.reloadAllTabs();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -425,11 +420,11 @@ const Tabs = Module("tabs", {
|
||||
matches = [];
|
||||
let lowerBuffer = buffer.toLowerCase();
|
||||
let first = tabs.index() + (reverse ? 0 : 1);
|
||||
let nbrowsers = this.getBrowser().browsers.length;
|
||||
let nbrowsers = config.tabbrowser.browsers.length;
|
||||
for (let [i, ] in tabs.browsers) {
|
||||
let index = (i + first) % nbrowsers;
|
||||
let url = this.getBrowser().getBrowserAtIndex(index).contentDocument.location.href;
|
||||
let title = this.getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
||||
let url = config.tabbrowser.getBrowserAtIndex(index).contentDocument.location.href;
|
||||
let title = config.tabbrowser.getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
||||
if (url == buffer) {
|
||||
tabs.select(index, false);
|
||||
return;
|
||||
@@ -462,11 +457,11 @@ const Tabs = Module("tabs", {
|
||||
* @param {boolean} activate Whether to select the newly cloned tab.
|
||||
*/
|
||||
cloneTab: function (tab, activate) {
|
||||
let newTab = this.getBrowser().addTab();
|
||||
let newTab = config.tabbrowser.addTab();
|
||||
Tabs.copyTab(newTab, tab);
|
||||
|
||||
if (activate)
|
||||
this.getBrowser().mTabContainer.selectedItem = newTab;
|
||||
config.tabbrowser.mTabContainer.selectedItem = newTab;
|
||||
|
||||
return newTab;
|
||||
},
|
||||
@@ -479,7 +474,7 @@ const Tabs = Module("tabs", {
|
||||
*/
|
||||
detachTab: function (tab) {
|
||||
if (!tab)
|
||||
tab = this.getBrowser().mTabContainer.selectedItem;
|
||||
tab = config.tabbrowser.mTabContainer.selectedItem;
|
||||
|
||||
services.get("windowWatcher")
|
||||
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
|
||||
@@ -520,7 +515,7 @@ const Tabs = Module("tabs", {
|
||||
}, {
|
||||
copyTab: function (to, from) {
|
||||
if (!from)
|
||||
from = tabs.getBrowser().mTabContainer.selectedItem;
|
||||
from = config.tabbrowser.mTabContainer.selectedItem;
|
||||
|
||||
let tabState = services.get("sessionStore").getTabState(from);
|
||||
services.get("sessionStore").setTabState(to, tabState);
|
||||
@@ -535,8 +530,8 @@ const Tabs = Module("tabs", {
|
||||
* - "$" for the last tab
|
||||
*/
|
||||
indexFromSpec: function (spec, wrap) {
|
||||
let position = tabs.getBrowser().mTabContainer.selectedIndex;
|
||||
let length = tabs.getBrowser().mTabs.length;
|
||||
let position = config.tabbrowser.mTabContainer.selectedIndex;
|
||||
let length = config.tabbrowser.mTabs.length;
|
||||
let last = length - 1;
|
||||
|
||||
if (spec === undefined || spec === "")
|
||||
@@ -579,7 +574,7 @@ const Tabs = Module("tabs", {
|
||||
}
|
||||
else {
|
||||
let str = arg.toLowerCase();
|
||||
let browsers = tabs.getBrowser().browsers;
|
||||
let browsers = config.tabbrowser.browsers;
|
||||
|
||||
for (let i = browsers.length - 1; i >= 0; i--) {
|
||||
let host, title, uri = browsers[i].currentURI.spec;
|
||||
@@ -787,7 +782,7 @@ const Tabs = Module("tabs", {
|
||||
"E488: Trailing characters");
|
||||
|
||||
// if not specified, move to after the last tab
|
||||
tabs.move(tabs.getBrowser().mCurrentTab, arg || "$", args.bang);
|
||||
tabs.move(config.tabbrowser.mCurrentTab, arg || "$", args.bang);
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true
|
||||
@@ -795,7 +790,7 @@ const Tabs = Module("tabs", {
|
||||
|
||||
commands.add(["tabo[nly]"],
|
||||
"Close all other tabs",
|
||||
function () { tabs.keepOnly(tabs.getBrowser().mCurrentTab); },
|
||||
function () { tabs.keepOnly(config.tabbrowser.mCurrentTab); },
|
||||
{ argCount: "0" });
|
||||
|
||||
commands.add(["tabopen", "t[open]", "tabnew"],
|
||||
@@ -869,7 +864,7 @@ const Tabs = Module("tabs", {
|
||||
|
||||
browser.moveTabTo(dummy, util.Math.constrain(tabIndex || last, 0, last));
|
||||
browser.selectedTab = dummy; // required
|
||||
browser.swapBrowsersAndCloseOther(dummy, tabs.getBrowser().mCurrentTab);
|
||||
browser.swapBrowsersAndCloseOther(dummy, config.tabbrowser.mCurrentTab);
|
||||
}, {
|
||||
argCount: "+",
|
||||
completer: function (context, args) {
|
||||
@@ -937,7 +932,7 @@ const Tabs = Module("tabs", {
|
||||
completion.buffer);
|
||||
},
|
||||
events: function () {
|
||||
let tabContainer = this.getBrowser().mTabContainer;
|
||||
let tabContainer = config.tabbrowser.mTabContainer;
|
||||
["TabMove", "TabOpen", "TabClose"].forEach(function (event) {
|
||||
events.addSessionListener(tabContainer, event, this.closure._updateTabCount, false);
|
||||
}, this);
|
||||
@@ -1036,7 +1031,7 @@ const Tabs = Module("tabs", {
|
||||
// don't have to fight against the host app's attempts to keep
|
||||
// it open - hack! Adding a filter watch to mStrip is probably
|
||||
// the cleanest solution.
|
||||
let tabStrip = tabs.getBrowser().mTabContainer;
|
||||
let tabStrip = config.tabbrowser.mTabContainer;
|
||||
|
||||
if (value == 0)
|
||||
tabStrip.collapsed = true;
|
||||
|
||||
Reference in New Issue
Block a user