summaryrefslogtreecommitdiff
path: root/common/modules/options.jsm
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-08-16 21:17:52 -0400
committerKris Maglione <maglione.k@gmail.com>2011-08-16 21:17:52 -0400
commit1ad3fdf195813913a7fabe0e2da0402427bdd5fb (patch)
tree88d5344c2e59968f0ec8a4bc00f8d5df9cce3f87 /common/modules/options.jsm
parent01fd946df1a7bd89528ec4c7cdfff9fde38d00ab (diff)
downloadpentadactyl-1ad3fdf195813913a7fabe0e2da0402427bdd5fb.tar.gz
Import part of top patch in queue: Add no-op option hive for plugin API reasons, cleanup some related code.
Diffstat (limited to 'common/modules/options.jsm')
-rw-r--r--common/modules/options.jsm24
1 files changed, 23 insertions, 1 deletions
diff --git a/common/modules/options.jsm b/common/modules/options.jsm
index 5b0a398b..828fd0ce 100644
--- a/common/modules/options.jsm
+++ b/common/modules/options.jsm
@@ -11,7 +11,7 @@ try {
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("options", {
exports: ["Option", "Options", "ValueError", "options"],
- require: ["messages", "storage"],
+ require: ["contexts", "messages", "storage"],
use: ["commands", "completion", "config", "prefs", "services", "styles", "template", "util"]
}, this);
@@ -757,6 +757,18 @@ var Option = Class("Option", {
EXPORTED_SYMBOLS.push(class_.className);
}, this);
+var OptionHive = Class("OptionHive", Contexts.Hive, {
+ init: function init(group) {
+ init.supercall(this, group);
+ this.values = {};
+ this.has = Set.has(this.values);
+ },
+
+ add: function add(names, description, type, defaultValue, extraInfo) {
+ return this.modules.options.add(names, description, type, defaultValue, extraInfo);
+ }
+});
+
/**
* @instance options
*/
@@ -764,6 +776,12 @@ var Options = Module("options", {
Local: function Local(dactyl, modules, window) let ({ contexts } = modules) ({
init: function init() {
const self = this;
+
+ update(this, {
+ hives: contexts.Hives("options", Class("OptionHive", OptionHive, { modules: modules })),
+ user: contexts.hives.options.user
+ });
+
this.needInit = [];
this._options = [];
this._optionMap = {};
@@ -853,6 +871,10 @@ var Options = Module("options", {
*/
add: function add(names, description, type, defaultValue, extraInfo) {
const self = this;
+
+ if (!util.isDactyl(Components.stack.caller))
+ deprecated.warn(add, "options.add", "group.options.add");
+
util.assert(type in Option.types,
_("option.noSuchType", type),
true);