summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/content/liberator.js114
-rw-r--r--common/content/tabs.js1
-rw-r--r--vimperator/NEWS2
-rw-r--r--vimperator/locale/en-US/gui.txt9
-rw-r--r--vimperator/locale/en-US/index.txt1
-rw-r--r--vimperator/locale/en-US/options.txt1
6 files changed, 81 insertions, 47 deletions
diff --git a/common/content/liberator.js b/common/content/liberator.js
index fb33953a..96ef92a7 100644
--- a/common/content/liberator.js
+++ b/common/content/liberator.js
@@ -30,15 +30,12 @@ the terms of any one of the MPL, the GPL or the LGPL.
Cu.import("resource://gre/modules/XPCOMUtils.jsm", modules);
-const plugins = {};
-plugins.__proto__ = modules;
+const plugins = { __proto__: modules };
+const userContext = { __proto__: modules };
const EVAL_ERROR = "__liberator_eval_error";
const EVAL_RESULT = "__liberator_eval_result";
const EVAL_STRING = "__liberator_eval_string";
-const userContext = {
- __proto__: modules
-};
const liberator = (function () //{{{
{
@@ -147,43 +144,6 @@ const liberator = (function () //{{{
liberator.help(tag);
}
- function getExtension(name) getExtensions().filter(function (e) e.name == name)[0]
-
- // TODO: maybe make this a property
- function getExtensions()
- {
- const rdf = services.get("rdf");
- const extensionManager = services.get("extensionManager");
-
- let extensions = extensionManager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
-
- function getRdfProperty(item, property)
- {
- let resource = rdf.GetResource("urn:mozilla:item:" + item.id);
- let value = "";
-
- if (resource)
- {
- let target = extensionManager.datasource.GetTarget(resource,
- rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
- if (target && target instanceof Ci.nsIRDFLiteral)
- value = target.Value;
- }
-
- return value;
- }
-
- //const Extension = new Struct("id", "name", "description", "icon", "enabled", "version");
- return [{
- id: e.id,
- name: e.name,
- description: getRdfProperty(e, "description"),
- icon: e.iconURL,
- enabled: getRdfProperty(e, "isDisabled") != "true",
- version: e.version
- } for ([,e] in Iterator(extensions))];
- }
-
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -472,13 +432,13 @@ const liberator = (function () //{{{
function action(e) { services.get("extensionManager")[command.action](e.id); };
if (args.bang)
- getExtensions().forEach(function (e) { action(e); });
+ liberator.extensions.forEach(function (e) { action(e); });
else
{
if (!name)
return void liberator.echoerr("E471: Argument required"); // XXX
- let extension = getExtension(name);
+ let extension = liberator.getExtension(name);
if (extension)
action(extension);
else
@@ -491,6 +451,31 @@ const liberator = (function () //{{{
completer: function (context) completion.extension(context)
});
});
+ commands.add(["exto[ptions]", "extp[references]"],
+ "Open an extension's preference dialog",
+ function (args)
+ {
+ let extension = liberator.getExtension(args[0]);
+ if (!extension || !extension.options)
+ return void liberator.extension("E474: Invalid argument");
+ if (args.bang)
+ window.openDialog(extension.options,
+ "_blank", "chrome");
+ else
+ liberator.open(extension.options,
+ options.get("newtab").has("all", "extoptions")
+ ? liberator.NEW_TAB : liberator.CURRENT_TAB);
+ },
+ {
+ argCount: "1",
+ bang: true,
+ completer: function (context)
+ {
+ completion.extension(context);
+ context.filters.push(function ({ item: e }) e.options);
+ },
+ literal: 0
+ });
// TODO: maybe indicate pending status too?
commands.add(["extens[ions]"],
@@ -498,7 +483,7 @@ const liberator = (function () //{{{
function (args)
{
let filter = args[0] || "";
- let extensions = getExtensions().filter(function (e) e.name.indexOf(filter) >= 0);
+ let extensions = liberator.extensions.filter(function (e) e.name.indexOf(filter) >= 0);
if (extensions.length > 0)
{
@@ -751,7 +736,7 @@ const liberator = (function () //{{{
context.title = ["Extension"];
context.anchored = false;
context.keys = { text: "name", description: "description", icon: "icon" },
- context.completions = getExtensions();
+ context.completions = liberator.extensions;
};
completion.help = function help(context) {
@@ -799,6 +784,43 @@ const liberator = (function () //{{{
/** @property {Element} The currently focused element. */
get focus() document.commandDispatcher.focusedElement,
+ get extensions()
+ {
+ const rdf = services.get("rdf");
+ const extensionManager = services.get("extensionManager");
+
+ let extensions = extensionManager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
+
+ function getRdfProperty(item, property)
+ {
+ let resource = rdf.GetResource("urn:mozilla:item:" + item.id);
+ let value = "";
+
+ if (resource)
+ {
+ let target = extensionManager.datasource.GetTarget(resource,
+ rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + property), true);
+ if (target && target instanceof Ci.nsIRDFLiteral)
+ value = target.Value;
+ }
+
+ return value;
+ }
+
+ //const Extension = new Struct("id", "name", "description", "icon", "enabled", "version");
+ return extensions.map(function(e) ({
+ id: e.id,
+ name: e.name,
+ description: getRdfProperty(e, "description"),
+ enabled: getRdfProperty(e, "isDisabled") != "true",
+ icon: e.iconURL,
+ options: getRdfProperty(e, "optionsURL"),
+ version: e.version
+ }));
+ },
+
+ getExtension: function (name) this.extensions.filter(function (e) e.name == name)[0],
+
// Global constants
CURRENT_TAB: 1,
NEW_TAB: 2,
diff --git a/common/content/tabs.js b/common/content/tabs.js
index 6d329a72..18903358 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -177,6 +177,7 @@ function Tabs() //{{{
["all", "All commands"],
["addons", ":addo[ns] command"],
["downloads", ":downl[oads] command"],
+ ["extoptions", ":exto[ptions] command"],
["help", ":h[elp] command"],
["javascript", ":javascript! or :js! command"],
["prefs", ":pref[erences]! or :prefs! command"]
diff --git a/vimperator/NEWS b/vimperator/NEWS
index 334d0b31..de930eb3 100644
--- a/vimperator/NEWS
+++ b/vimperator/NEWS
@@ -15,7 +15,7 @@
and <C-A> are equivalent, to map the uppercase character use <C-S-A>.
* add extension related commands - :extadd, :extdelete, :extdisable,
- :extenable, :extensions
+ :extenable, :extensions, :extoptions
* add '-javascript' flag to :autocommand
* add 'private' - enter private browsing mode, matching 'PrivateMode'
autocommand
diff --git a/vimperator/locale/en-US/gui.txt b/vimperator/locale/en-US/gui.txt
index a44577f3..8bba1a8b 100644
--- a/vimperator/locale/en-US/gui.txt
+++ b/vimperator/locale/en-US/gui.txt
@@ -114,6 +114,15 @@ ________________________________________________________________________________
List all installed extensions.
________________________________________________________________________________
+|:exto| |:extoptions| +
+|:extp| |:extpreferences| +
+||:exto[ptions][!] {extension}|| +
+||:extp[references][!] {extension}|| +
+________________________________________________________________________________
+Open the preferences dialog for an extension. If [!] is given, open a dialog,
+otherwise open a buffer. See also 'newtab'.
+________________________________________________________________________________
+
section:Sidebar[sidebar]
|:sbcl| |:sbclose| +
diff --git a/vimperator/locale/en-US/index.txt b/vimperator/locale/en-US/index.txt
index cbecee29..dba6311c 100644
--- a/vimperator/locale/en-US/index.txt
+++ b/vimperator/locale/en-US/index.txt
@@ -186,6 +186,7 @@ section:Ex{nbsp}commands[ex-cmd-index,:index]
||[c]:extdelete[c]||
||[c]:extdisable[c]||
||[c]:extenable[c]||
+||[c]:extoptions[c]||
||[c]:extensions[c]|| List all installed extensions +
||[c]:exusage[c]|| List all Ex commands with a short description +
||[c]:finish[c]|| Stop sourcing a script file +
diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt
index c8e01e13..be9ea2ee 100644
--- a/vimperator/locale/en-US/options.txt
+++ b/vimperator/locale/en-US/options.txt
@@ -566,6 +566,7 @@ The possible values:
*all* All commands
*addons* [c]:addo[ns][c] command
*downloads* [c]:downl[oads][c] command
+*extoptions* [c]:exto[ptions][c] command
*help* [c]:h[elp][c] command
*javascript* [c]:javascript![c] or [c]:js![c] command
*prefs* [c]:pref[erences]![c] or [c]:prefs![c] command