1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:27:59 +01:00

Fix mailbird.

This commit is contained in:
Kris Maglione
2009-11-09 14:14:51 -05:00
parent 5de5a79ce5
commit dd924d0822
7 changed files with 82 additions and 73 deletions

View File

@@ -1,3 +1,13 @@
// Copyright (c) 2009 by Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
function array(obj) { function array(obj) {
if (isgenerator(obj)) if (isgenerator(obj))
obj = [k for (k in obj)]; obj = [k for (k in obj)];
@@ -182,8 +192,10 @@ function update(targ) {
} }
function extend(subc, superc, overrides) { function extend(subc, superc, overrides) {
subc.prototype = { __proto__: superc.prototype }; subc.prototype = {};
update(subc.prototype, overrides); update(subc.prototype, overrides);
// This is unduly expensive.
subc.prototype.__proto__ = superc.prototype;
subc.superclass = superc.prototype; subc.superclass = superc.prototype;
subc.prototype.constructor = subc; subc.prototype.constructor = subc;

View File

@@ -1,3 +1,7 @@
// Copyright (c) 2009 by Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
const ModuleBase = Class("ModuleBase", { requires: [] }); const ModuleBase = Class("ModuleBase", { requires: [] });
function Module(name, inst, clas, moduleInit) { function Module(name, inst, clas, moduleInit) {

View File

@@ -5,11 +5,6 @@
/** @scope modules */ /** @scope modules */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
/** /**
* Cached XPCOM services and classes. * Cached XPCOM services and classes.
* *

View File

@@ -15,7 +15,10 @@ const Tabs = Module("tabs", {
requires: ["config"], requires: ["config"],
init: function () { init: function () {
this._alternates = [getBrowser().mCurrentTab, null]; if (config.getBrowser)
this.getBrowser = config.getBrowser;
this._alternates = [this.getBrowser().mCurrentTab, null];
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command // used for the "gb" and "gB" mappings to remember the last :buffer[!] command
this._lastBufferSwitchArgs = ""; this._lastBufferSwitchArgs = "";
@@ -24,7 +27,7 @@ const Tabs = Module("tabs", {
// hide tabs initially to prevent flickering when 'stal' would hide them // hide tabs initially to prevent flickering when 'stal' would hide them
// on startup // on startup
if (config.hasTabbrowser) if (config.hasTabbrowser)
getBrowser().mTabContainer.collapsed = true; // FIXME: see 'stal' comment this.getBrowser().mTabContainer.collapsed = true; // FIXME: see 'stal' comment
}, },
/** /**
@@ -38,7 +41,7 @@ const Tabs = Module("tabs", {
* in the current window. * in the current window.
*/ */
get browsers() { get browsers() {
let browsers = getBrowser().browsers; let browsers = this.getBrowser().browsers;
for (let i = 0; i < browsers.length; i++) for (let i = 0; i < browsers.length; i++)
yield [i, browsers[i]]; yield [i, browsers[i]];
}, },
@@ -62,7 +65,7 @@ const Tabs = Module("tabs", {
/** /**
* @property {number} The number of tabs in the current window. * @property {number} The number of tabs in the current window.
*/ */
get count() getBrowser().mTabs.length, get count() this.getBrowser().mTabs.length,
/** /**
* @property {Object} The local options store for the current tab. * @property {Object} The local options store for the current tab.
@@ -114,9 +117,9 @@ const Tabs = Module("tabs", {
*/ */
index: function (tab) { index: function (tab) {
if (tab) if (tab)
return Array.indexOf(getBrowser().mTabs, tab); return Array.indexOf(this.getBrowser().mTabs, tab);
else else
return getBrowser().mTabContainer.selectedIndex; return this.getBrowser().mTabContainer.selectedIndex;
}, },
// TODO: implement filter // TODO: implement filter
@@ -163,9 +166,9 @@ const Tabs = Module("tabs", {
*/ */
getTab: function (index) { getTab: function (index) {
if (index != undefined) if (index != undefined)
return getBrowser().mTabs[index]; return this.getBrowser().mTabs[index];
else else
return getBrowser().mCurrentTab; return this.getBrowser().mCurrentTab;
}, },
/** /**
@@ -189,7 +192,7 @@ const Tabs = Module("tabs", {
*/ */
move: function (tab, spec, wrap) { move: function (tab, spec, wrap) {
let index = Tabs.indexFromSpec(spec, wrap); let index = Tabs.indexFromSpec(spec, wrap);
getBrowser().moveTabTo(tab, index); this.getBrowser().moveTabTo(tab, index);
}, },
/** /**
@@ -207,31 +210,31 @@ const Tabs = Module("tabs", {
remove: function (tab, count, focusLeftTab, quitOnLastTab) { remove: function (tab, count, focusLeftTab, quitOnLastTab) {
let removeOrBlankTab = { let removeOrBlankTab = {
Firefox: function (tab) { Firefox: function (tab) {
if (getBrowser().mTabs.length > 1) if (tabs.getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab); tabs.getBrowser().removeTab(tab);
else { else {
if (buffer.URL != "about:blank" || if (buffer.URL != "about:blank" ||
window.getWebNavigation().sessionHistory.count > 0) { window.getWebNavigation().sessionHistory.count > 0) {
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB); liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
getBrowser().removeTab(tab); tabs.getBrowser().removeTab(tab);
} }
else else
liberator.beep(); liberator.beep();
} }
}, },
Thunderbird: function (tab) { Thunderbird: function (tab) {
if (getBrowser().mTabs.length > 1) if (tabs.getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab); tabs.getBrowser().removeTab(tab);
else else
liberator.beep(); liberator.beep();
}, },
Songbird: function (tab) { Songbird: function (tab) {
if (getBrowser().mTabs.length > 1) if (tabs.getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab); tabs.getBrowser().removeTab(tab);
else { else {
if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) { if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB); liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
getBrowser().removeTab(tab); tabs.getBrowser().removeTab(tab);
} }
else else
liberator.beep(); liberator.beep();
@@ -242,7 +245,7 @@ const Tabs = Module("tabs", {
if (typeof count != "number" || count < 1) if (typeof count != "number" || count < 1)
count = 1; count = 1;
if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count) { if (quitOnLastTab >= 1 && this.getBrowser().mTabs.length <= count) {
if (liberator.windows.length > 1) if (liberator.windows.length > 1)
window.close(); window.close();
else else
@@ -258,7 +261,7 @@ const Tabs = Module("tabs", {
removeOrBlankTab(this.getTab(i)); removeOrBlankTab(this.getTab(i));
lastRemovedTab = i > 0 ? i : 1; lastRemovedTab = i > 0 ? i : 1;
} }
getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1; this.getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1;
} }
else { else {
let i = index + count - 1; let i = index + count - 1;
@@ -267,7 +270,7 @@ const Tabs = Module("tabs", {
for (; i >= index; i--) for (; i >= index; i--)
removeOrBlankTab(this.getTab(i)); removeOrBlankTab(this.getTab(i));
getBrowser().mTabContainer.selectedIndex = index; this.getBrowser().mTabContainer.selectedIndex = index;
} }
}, },
@@ -277,7 +280,7 @@ const Tabs = Module("tabs", {
* @param {Object} tab The tab to keep. * @param {Object} tab The tab to keep.
*/ */
keepOnly: function (tab) { keepOnly: function (tab) {
getBrowser().removeAllTabsBut(tab); this.getBrowser().removeAllTabsBut(tab);
}, },
/** /**
@@ -293,7 +296,7 @@ const Tabs = Module("tabs", {
// FIXME: // FIXME:
if (index == -1) if (index == -1)
return void liberator.beep(); return void liberator.beep();
getBrowser().mTabContainer.selectedIndex = index; this.getBrowser().mTabContainer.selectedIndex = index;
}, },
/** /**
@@ -306,10 +309,10 @@ const Tabs = Module("tabs", {
reload: function (tab, bypassCache) { reload: function (tab, bypassCache) {
if (bypassCache) { if (bypassCache) {
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
getBrowser().getBrowserForTab(tab).reloadWithFlags(flags); this.getBrowser().getBrowserForTab(tab).reloadWithFlags(flags);
} }
else else
getBrowser().reloadTab(tab); this.getBrowser().reloadTab(tab);
}, },
/** /**
@@ -320,9 +323,9 @@ const Tabs = Module("tabs", {
*/ */
reloadAll: function (bypassCache) { reloadAll: function (bypassCache) {
if (bypassCache) { if (bypassCache) {
for (let i = 0; i < getBrowser().mTabs.length; i++) { for (let i = 0; i < this.getBrowser().mTabs.length; i++) {
try { try {
this.reload(getBrowser().mTabs[i], bypassCache); this.reload(this.getBrowser().mTabs[i], bypassCache);
} }
catch (e) { catch (e) {
// FIXME: can we do anything useful here without stopping the // FIXME: can we do anything useful here without stopping the
@@ -331,7 +334,7 @@ const Tabs = Module("tabs", {
} }
} }
else else
getBrowser().reloadAllTabs(); this.getBrowser().reloadAllTabs();
}, },
/** /**
@@ -402,11 +405,11 @@ const Tabs = Module("tabs", {
matches = []; matches = [];
let lowerBuffer = buffer.toLowerCase(); let lowerBuffer = buffer.toLowerCase();
let first = tabs.index() + (reverse ? 0 : 1); let first = tabs.index() + (reverse ? 0 : 1);
let nbrowsers = getBrowser().browsers.length; let nbrowsers = this.getBrowser().browsers.length;
for (let [i, ] in tabs.browsers) { for (let [i, ] in tabs.browsers) {
let index = (i + first) % nbrowsers; let index = (i + first) % nbrowsers;
let url = getBrowser().getBrowserAtIndex(index).contentDocument.location.href; let url = this.getBrowser().getBrowserAtIndex(index).contentDocument.location.href;
let title = getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase(); let title = this.getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
if (url == buffer) { if (url == buffer) {
tabs.select(index, false); tabs.select(index, false);
return; return;
@@ -439,11 +442,11 @@ const Tabs = Module("tabs", {
* @param {boolean} activate Whether to select the newly cloned tab. * @param {boolean} activate Whether to select the newly cloned tab.
*/ */
cloneTab: function (tab, activate) { cloneTab: function (tab, activate) {
let newTab = getBrowser().addTab(); let newTab = this.getBrowser().addTab();
Tabs.copyTab(newTab, tab); Tabs.copyTab(newTab, tab);
if (activate) if (activate)
getBrowser().mTabContainer.selectedItem = newTab; this.getBrowser().mTabContainer.selectedItem = newTab;
return newTab; return newTab;
}, },
@@ -456,7 +459,7 @@ const Tabs = Module("tabs", {
*/ */
detachTab: function (tab) { detachTab: function (tab) {
if (!tab) if (!tab)
tab = getBrowser().mTabContainer.selectedItem; tab = this.getBrowser().mTabContainer.selectedItem;
services.get("windowWatcher") services.get("windowWatcher")
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab); .openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
@@ -497,7 +500,7 @@ const Tabs = Module("tabs", {
}, { }, {
copyTab: function (to, from) { copyTab: function (to, from) {
if (!from) if (!from)
from = getBrowser().mTabContainer.selectedItem; from = tabs.getBrowser().mTabContainer.selectedItem;
let tabState = services.get("sessionStore").getTabState(from); let tabState = services.get("sessionStore").getTabState(from);
services.get("sessionStore").setTabState(to, tabState); services.get("sessionStore").setTabState(to, tabState);
@@ -513,8 +516,8 @@ const Tabs = Module("tabs", {
* - "$" for the last tab * - "$" for the last tab
*/ */
indexFromSpec: function (spec, wrap) { indexFromSpec: function (spec, wrap) {
let position = getBrowser().mTabContainer.selectedIndex; let position = tabs.getBrowser().mTabContainer.selectedIndex;
let length = getBrowser().mTabs.length; let length = tabs.getBrowser().mTabs.length;
let last = length - 1; let last = length - 1;
if (spec === undefined || spec === "") if (spec === undefined || spec === "")
@@ -557,7 +560,7 @@ const Tabs = Module("tabs", {
} }
else { else {
let str = arg.toLowerCase(); let str = arg.toLowerCase();
let browsers = getBrowser().browsers; let browsers = tabs.getBrowser().browsers;
for (let i = browsers.length - 1; i >= 0; i--) { for (let i = browsers.length - 1; i >= 0; i--) {
let host, title, uri = browsers[i].currentURI.spec; let host, title, uri = browsers[i].currentURI.spec;
@@ -765,7 +768,7 @@ const Tabs = Module("tabs", {
"E488: Trailing characters"); "E488: Trailing characters");
// if not specified, move to after the last tab // if not specified, move to after the last tab
tabs.move(getBrowser().mCurrentTab, arg || "$", args.bang); tabs.move(tabs.getBrowser().mCurrentTab, arg || "$", args.bang);
}, { }, {
argCount: "?", argCount: "?",
bang: true bang: true
@@ -773,7 +776,7 @@ const Tabs = Module("tabs", {
commands.add(["tabo[nly]"], commands.add(["tabo[nly]"],
"Close all other tabs", "Close all other tabs",
function () { tabs.keepOnly(getBrowser().mCurrentTab); }, function () { tabs.keepOnly(tabs.getBrowser().mCurrentTab); },
{ argCount: "0" }); { argCount: "0" });
commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"], commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
@@ -847,7 +850,7 @@ const Tabs = Module("tabs", {
browser.moveTabTo(dummy, util.Math.constrain(tabIndex || last, 0, last)); browser.moveTabTo(dummy, util.Math.constrain(tabIndex || last, 0, last));
browser.selectedTab = dummy; // required browser.selectedTab = dummy; // required
browser.swapBrowsersAndCloseOther(dummy, getBrowser().mCurrentTab); browser.swapBrowsersAndCloseOther(dummy, tabs.getBrowser().mCurrentTab);
}, { }, {
argCount: "+", argCount: "+",
completer: function (context, args) { completer: function (context, args) {
@@ -1007,7 +1010,7 @@ const Tabs = Module("tabs", {
// don't have to fight against the host app's attempts to keep // don't have to fight against the host app's attempts to keep
// it open - hack! Adding a filter watch to mStrip is probably // it open - hack! Adding a filter watch to mStrip is probably
// the cleanest solution. // the cleanest solution.
let tabStrip = getBrowser().mTabContainer; let tabStrip = tabs.getBrowser().mTabContainer;
if (value == 0) if (value == 0)
tabStrip.collapsed = true; tabStrip.collapsed = true;

View File

@@ -3,7 +3,7 @@
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
const config = Module("config", ConfigBase, { const Config = Module("config", ConfigBase, {
init: function () { init: function () {
// don't wait too long when selecting new messages // don't wait too long when selecting new messages
// GetThreadTree()._selectDelay = 300; // TODO: make configurable // GetThreadTree()._selectDelay = 300; // TODO: make configurable
@@ -116,16 +116,6 @@ const config = Module("config", ConfigBase, {
// they are sorted by relevance, not alphabetically // they are sorted by relevance, not alphabetically
helpFiles: ["intro.html", "version.html"], helpFiles: ["intro.html", "version.html"],
get ignoreKeys() {
delete this.ignoreKeys;
return this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT
}
},
modes: [ modes: [
["MESSAGE", { char: "m" }], ["MESSAGE", { char: "m" }],
["COMPOSE"] ["COMPOSE"]
@@ -148,7 +138,7 @@ const config = Module("config", ConfigBase, {
return document.getElementById("appcontent").boxObject.height; return document.getElementById("appcontent").boxObject.height;
}, },
get scripts() this.isComposeWindow() ? ["compose/compose.js"] : [ get scripts() this.isComposeWindow ? ["compose/compose.js"] : [
"addressbook.js", "addressbook.js",
"mail.js", "mail.js",
"tabs.js", "tabs.js",
@@ -165,6 +155,14 @@ const config = Module("config", ConfigBase, {
function () { window.openOptionsDialog(); }, function () { window.openOptionsDialog(); },
{ argCount: "0" }); { argCount: "0" });
}, },
modes: function () {
this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT
};
},
optons: function () { optons: function () {
// FIXME: comment obviously incorrect // FIXME: comment obviously incorrect
// 0: never automatically edit externally // 0: never automatically edit externally
@@ -186,6 +184,6 @@ const config = Module("config", ConfigBase, {
getter: function () MailOfflineMgr.isOnline() getter: function () MailOfflineMgr.isOnline()
}); });
}, },
}) });
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -13,8 +13,7 @@ const Mail = Module("mail", {
this._selectMessageReverse = false; this._selectMessageReverse = false;
this._mailSession = Cc["@mozilla.org/messenger/services/session;1"].getService(Ci.nsIMsgMailSession); this._mailSession = Cc["@mozilla.org/messenger/services/session;1"].getService(Ci.nsIMsgMailSession);
this._nsIFolderListener = Ci.this._nsIFolderListener; this._notifyFlags = Ci.nsIFolderListener.intPropertyChanged | Ci.nsIFolderListener.event;
this._notifyFlags = this._nsIFolderListener.intPropertyChanged | this._nsIFolderListener.event;
this._mailSession.AddFolderListener(this._folderListener, this._notifyFlags); this._mailSession.AddFolderListener(this._folderListener, this._notifyFlags);
}, },

View File

@@ -6,7 +6,7 @@
Components.utils.import("resource://gre/modules/utils.js"); // XXX Components.utils.import("resource://gre/modules/utils.js"); // XXX
const config = Module("config", { const Config = Module("config", {
init: function () { init: function () {
// TODO: mention this to SB devs, they seem keen to provide these // TODO: mention this to SB devs, they seem keen to provide these
// functions to make porting from FF as simple as possible. // functions to make porting from FF as simple as possible.
@@ -147,16 +147,6 @@ const config = Module("config", {
modes: [["PLAYER", { char: "p" }]], modes: [["PLAYER", { char: "p" }]],
get ignoreKeys() {
delete this.ignoreKeys;
return this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT
};
},
scripts: [ scripts: [
"browser.js", "browser.js",
"bookmarks.js", "bookmarks.js",
@@ -282,6 +272,14 @@ const config = Module("config", {
context.completions = Config.displayPanes; // FIXME: useful description etc context.completions = Config.displayPanes; // FIXME: useful description etc
}; };
}, },
modes: function () {
this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT
};
},
options: function () { options: function () {
// TODO: SB doesn't explicitly support an offline mode. Should we? --djk // TODO: SB doesn't explicitly support an offline mode. Should we? --djk
options.add(["online"], options.add(["online"],