summaryrefslogtreecommitdiff
path: root/common/content/options.js
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2009-05-15 22:17:00 +1000
committerDoug Kearns <dougkearns@gmail.com>2009-05-15 22:17:00 +1000
commita97d419fc8653934ca67ac6044114b414146532f (patch)
treee1d36e3e5bb500749cd74286eb695a89645cee8f /common/content/options.js
parent47f63446cb4ec4ccad9259faa7c69f9b4953bcc3 (diff)
downloadpentadactyl-a97d419fc8653934ca67ac6044114b414146532f.tar.gz
Move events.prefObserver to options.prefObserver.
Diffstat (limited to 'common/content/options.js')
-rw-r--r--common/content/options.js44
1 files changed, 41 insertions, 3 deletions
diff --git a/common/content/options.js b/common/content/options.js
index bdfbe09c..da19b982 100644
--- a/common/content/options.js
+++ b/common/content/options.js
@@ -805,7 +805,7 @@ function Options() //{{{
.map(function (pref) [pref, ""])]);
});
- return {
+ const self = {
OPTION_SCOPE_GLOBAL: 1,
OPTION_SCOPE_LOCAL: 2,
@@ -817,6 +817,37 @@ function Options() //{{{
return (v for ([k, v] in Iterator(sorted)));
},
+ prefObserver: {
+ register: function ()
+ {
+ // better way to monitor all changes?
+ this._branch = services.get("pref").getBranch("").QueryInterface(Ci.nsIPrefBranch2);
+ this._branch.addObserver("", this, false);
+ },
+
+ unregister: function ()
+ {
+ if (this._branch)
+ this._branch.removeObserver("", this);
+ },
+
+ observe: function (subject, topic, data)
+ {
+ if (topic != "nsPref:changed")
+ return;
+
+ // subject is the nsIPrefBranch we're observing (after appropriate QI)
+ // data is the name of the pref that's been changed (relative to subject)
+ switch (data)
+ {
+ case "accessibility.browsewithcaret":
+ let value = options.getPref("accessibility.browsewithcaret", false);
+ liberator.mode = value ? modes.CARET : modes.NORMAL;
+ break;
+ }
+ }
+ },
+
add: function (names, description, type, defaultValue, extraInfo)
{
if (!extraInfo)
@@ -1064,8 +1095,15 @@ function Options() //{{{
this.popContext();
}
}
- };
- //}}}
+ }; //}}}
+
+ self.prefObserver.register();
+ liberator.registerObserver("shutdown", function () {
+ self.prefObserver.unregister();
+ });
+
+ return self;
+
}; //}}}
// vim: set fdm=marker sw=4 ts=4 et: