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

Add 'Copy File Path' MOW context menu item. Fix some bugs.

This commit is contained in:
Kris Maglione
2011-01-17 00:43:40 -05:00
parent f17fb77bcb
commit 32daed5095
6 changed files with 31 additions and 25 deletions

View File

@@ -21,6 +21,9 @@ var CommandWidgets = Class("CommandWidgets", {
<menuitem id="dactyl-context-copylink" <menuitem id="dactyl-context-copylink"
label="Copy Link Location" dactyl:group="link" label="Copy Link Location" dactyl:group="link"
oncommand="goDoCommand('cmd_copyLink');"/> oncommand="goDoCommand('cmd_copyLink');"/>
<menuitem id="dactyl-context-copypath"
label="Copy File Path" dactyl:group="link path"
oncommand="dactyl.clipboardWrite(document.popupNode.getAttribute('path'));"/>
<menuitem id="dactyl-context-copy" <menuitem id="dactyl-context-copy"
label="Copy" dactyl:group="selection" label="Copy" dactyl:group="selection"
command="cmd_copy"/> command="cmd_copy"/>
@@ -937,14 +940,21 @@ var CommandLine = Module("commandline", {
}, },
onContext: function onContext(event) { onContext: function onContext(event) {
let enabled = { try {
link: window.document.popupNode instanceof HTMLAnchorElement, let enabled = {
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed link: window.document.popupNode instanceof HTMLAnchorElement,
}; path: window.document.popupNode.hasAttribute("path"),
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
};
for (let [, node] in iter(event.target.childNodes)) { for (let node in array.iterValues(event.target.children)) {
let group = node.getAttributeNS(NS, "group"); let group = node.getAttributeNS(NS, "group");
node.hidden = group && !group.split(/\s+/).some(function (g) enabled[g]); util.dump(node, group, group && !group.split(/\s+/).every(function (g) enabled[g]));
node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
}
}
catch (e) {
util.reportError(e);
} }
return true; return true;
}, },
@@ -1100,6 +1110,9 @@ var CommandLine = Module("commandline", {
event.originalTarget.hasAttributeNS(NS, "command"))) { event.originalTarget.hasAttributeNS(NS, "command"))) {
let command = event.originalTarget.getAttributeNS(NS, "command"); let command = event.originalTarget.getAttributeNS(NS, "command");
if (command && event.button == 2)
return PASS;
if (command && dactyl.commands[command]) { if (command && dactyl.commands[command]) {
event.preventDefault(); event.preventDefault();
return dactyl.withSavedValues(["forceNewTab"], function () { return dactyl.withSavedValues(["forceNewTab"], function () {

View File

@@ -363,7 +363,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
userEval: function (str, context, fileName, lineNumber) { userEval: function (str, context, fileName, lineNumber) {
if (jsmodules.__proto__ != window) if (jsmodules.__proto__ != window)
str = "with (window) { with (modules) { this.eval(" + str.quote() + ") } }"; str = "with (window) { with (modules) { (this.eval || eval)(" + str.quote() + ") } }";
if (fileName == null) if (fileName == null)
if (io.sourcing && io.sourcing.file[0] !== "[") if (io.sourcing && io.sourcing.file[0] !== "[")

View File

@@ -4,8 +4,6 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
dump(" ======================= bootstrap.jsm " + (typeof JSMLoader) + " ======================= \n");
var EXPORTED_SYMBOLS = ["JSMLoader"]; var EXPORTED_SYMBOLS = ["JSMLoader"];
let global = this; let global = this;

View File

@@ -29,7 +29,7 @@ var Download = Class("Download", {
<li highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}> <li highlight="Download" key="row" xmlns:dactyl={NS} xmlns={XHTML}>
<span highlight="DownloadTitle"> <span highlight="DownloadTitle">
<span highlight="Link"> <span highlight="Link">
<a key="title" href={self.target.spec}>{self.displayName}</a> <a key="title" href={self.target.spec} path={self.targetFile.path}>{self.displayName}</a>
<span highlight="LinkInfo">{self.targetFile.path}</span> <span highlight="LinkInfo">{self.targetFile.path}</span>
</span> </span>
</span> </span>

View File

@@ -114,10 +114,11 @@ var Services = Module("Services", {
} }
["aboutURL", "creator", "description", "developers", ["aboutURL", "creator", "description", "developers",
"homepageURL", "iconURL", "installDate", "homepageURL", "installDate", "optionsURL",
"optionsURL", "releaseNotesURI", "updateDate", "version"].forEach(function (item) { "releaseNotesURI", "updateDate"].forEach(function (item) {
addon[item] = getRdfProperty(addon, item); memoize(addon, item, function (item) getRdfProperty(this, item));
}); });
update(addon, { update(addon, {
appDisabled: false, appDisabled: false,
@@ -148,7 +149,7 @@ var Services = Module("Services", {
for (let [, item] in Iterator(services.extensionManager for (let [, item] in Iterator(services.extensionManager
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {}))) .getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
res.push(this.getAddonByID(item)); res.push(this.getAddonByID(item));
callback(res); return (callback || util.identity)(res);
}, },
getInstallForFile: function (file, callback, mimetype) { getInstallForFile: function (file, callback, mimetype) {
callback({ callback({
@@ -207,14 +208,7 @@ var Services = Module("Services", {
const self = this; const self = this;
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports)) if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
throw TypeError(); throw TypeError();
this.__defineGetter__(name, function () { memoize(this, name, function () self._create(class_, ifaces, meth));
let res = self._create(class_, ifaces, meth);
if (!res)
return null;
delete this[name];
return this[name] = res;
});
}, },
/** /**

View File

@@ -262,12 +262,13 @@ var Template = Module("Template", {
sourceLink: function (frame) { sourceLink: function (frame) {
let url = (frame.filename || "unknown").replace(/.* -> /, ""); let url = (frame.filename || "unknown").replace(/.* -> /, "");
let path = util.urlPath(url);
XML.ignoreWhitespace = false; XML.prettyPrinting = false; XML.ignoreWhitespace = false; XML.prettyPrinting = false;
return <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource" return <a xmlns:dactyl={NS} dactyl:command="buffer.viewSource"
href={url} line={frame.lineNumber} href={url} path={path} line={frame.lineNumber}
highlight="URL">{ highlight="URL">{
util.urlPath(url) + ":" + frame.lineNumber path + ":" + frame.lineNumber
}</a> }</a>
}, },