[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 234/483: Configure hotkeys independently of Adblock Plus
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.
commit 47ab284a9d969644e3cad0230ed50c1e74ce98a3
Author: Wladimir Palant <trev at adblockplus.org>
Date: Fri Oct 22 15:00:15 2010 +0200
Configure hotkeys independently of Adblock Plus
---
chrome/content/overlay.xul | 6 ++---
modules/AppIntegration.jsm | 64 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul
index f9caaaa..bf2ead9 100644
--- a/chrome/content/overlay.xul
+++ b/chrome/content/overlay.xul
@@ -50,11 +50,11 @@
</popupset>
<popup id="abp-status-popup">
- <menuitem id="abp-status-ehh-selectelement" hidden="true" insertbefore="abp-status-options" label="&selectelement.label;" accesskey="&selectelement.accesskey;" key="abp-key-ehh-selectelement"/>
- <menuitem id="abp-status-ehh-stopselection" hidden="true" insertbefore="abp-status-options" label="&stopselection.label;" accesskey="&stopselection.accesskey;" key="abp-key-ehh-selectelement"/>
+ <menuitem id="abp-status-ehh-selectelement" hidden="true" insertbefore="abp-status-options" label="&selectelement.label;" accesskey="&selectelement.accesskey;" key="ehh-key-selectelement"/>
+ <menuitem id="abp-status-ehh-stopselection" hidden="true" insertbefore="abp-status-options" label="&stopselection.label;" accesskey="&stopselection.accesskey;" key="ehh-key-selectelement"/>
</popup>
<commandset id="abp-commandset">
- <command id="abp-command-ehh-selectelement"/>
+ <command id="ehh-command-selectelement"/>
</commandset>
</overlay>
diff --git a/modules/AppIntegration.jsm b/modules/AppIntegration.jsm
index 592ec95..a66b52e 100644
--- a/modules/AppIntegration.jsm
+++ b/modules/AppIntegration.jsm
@@ -31,6 +31,7 @@ const Cu = Components.utils;
let baseURI = Cc["@adblockplus.org/ehh/startup;1"].getService(Ci.nsIURI);
Cu.import(baseURI.spec + "Aardvark.jsm");
+Cu.import(baseURI.spec + "Prefs.jsm");
var AppIntegration =
{
@@ -45,6 +46,7 @@ function WindowWrapper(wnd)
this.window = wnd;
this.registerEventListeners();
+ this.configureKeys();
}
WindowWrapper.prototype =
{
@@ -86,6 +88,68 @@ WindowWrapper.prototype =
this.browser.addEventListener("select", this._bindMethod(this.stopSelection), false);
},
+ configureKeys: function()
+ {
+ for (let pref in Prefs)
+ {
+ if (/_key$/.test(pref) && typeof Prefs[pref] == "string")
+ {
+ try
+ {
+ this.configureKey(RegExp.leftContext, Prefs[pref]);
+ }
+ catch (e)
+ {
+ Cu.reportError(e);
+ }
+ }
+ }
+ },
+
+ configureKey: function(id, value)
+ {
+ let validModifiers =
+ {
+ accel: "accel",
+ ctrl: "control",
+ control: "control",
+ shift: "shift",
+ alt: "alt",
+ meta: "meta"
+ };
+
+ let command = this.E("ehh-command-" + id);
+ if (!command)
+ return;
+
+ let modifiers = [];
+ let keychar = null;
+ let keycode = null;
+ for each (let part in value.split(/\s+/))
+ {
+ if (part.toLowerCase() in validModifiers)
+ modifiers.push(validModifiers[part.toLowerCase()]);
+ else if (part.length == 1)
+ keychar = part;
+ else if ("DOM_VK_" + part.toUpperCase() in Ci.nsIDOMKeyEvent)
+ keycode = "VK_" + part.toUpperCase();
+ }
+
+ if (keychar || keycode)
+ {
+ let element = this.window.document.createElement("key");
+ element.setAttribute("id", "ehh-key-" + id);
+ element.setAttribute("command", "ehh-command-" + id);
+ if (keychar)
+ element.setAttribute("key", keychar);
+ else
+ element.setAttribute("keycode", keycode);
+ element.setAttribute("modifiers", modifiers.join(","));
+
+ this.E("abp-keyset").appendChild(element);
+ }
+ },
+
hideTooltips: function()
{
if (Aardvark.window == this.window)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git
More information about the Pkg-mozext-commits
mailing list