mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 18:17:58 +01:00
Bootstrap cleanup work.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -19,7 +19,7 @@ const EVAL_ERROR = "__dactyl_eval_error";
|
||||
const EVAL_RESULT = "__dactyl_eval_result";
|
||||
const EVAL_STRING = "__dactyl_eval_string";
|
||||
|
||||
const Dactyl = Module("dactyl", {
|
||||
const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
init: function () {
|
||||
window.dactyl = this;
|
||||
// cheap attempt at compatibility
|
||||
@@ -30,6 +30,7 @@ const Dactyl = Module("dactyl", {
|
||||
this.indices = {};
|
||||
this.modules = modules;
|
||||
this.observers = {};
|
||||
util.addObserver(this);
|
||||
|
||||
this.commands["dactyl.help"] = function (event) {
|
||||
let elem = event.originalTarget;
|
||||
@@ -37,6 +38,18 @@ const Dactyl = Module("dactyl", {
|
||||
};
|
||||
},
|
||||
|
||||
observe: {
|
||||
"dactyl-cleanup": function () {
|
||||
for (let [, mod] in iter(array(values(modules)).reverse()))
|
||||
if (mod instanceof ModuleBase) {
|
||||
if ("cleanup" in mod)
|
||||
mod.cleanup();
|
||||
if ("destroy" in mod)
|
||||
mod.destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** @property {string} The name of the current user profile. */
|
||||
profileName: Class.memoize(function () {
|
||||
// NOTE: services.profile.selectedProfile.name doesn't return
|
||||
@@ -52,6 +65,12 @@ const Dactyl = Module("dactyl", {
|
||||
return "unknown";
|
||||
}),
|
||||
|
||||
cleanup: function () {
|
||||
delete window.dactyl;
|
||||
delete window.modules;
|
||||
delete window.liberator;
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
autocommands.trigger("LeavePre", {});
|
||||
storage.saveAll();
|
||||
@@ -1315,6 +1334,12 @@ const Dactyl = Module("dactyl", {
|
||||
options.add(["guioptions", "go"],
|
||||
"Show or hide certain GUI elements like the menu or toolbar",
|
||||
"charlist", config.defaults.guioptions || "", {
|
||||
|
||||
// FIXME: cleanup
|
||||
cleanupValue: config.cleanups.guioptions ||
|
||||
"r" + [k for ([k, v] in iter(groups[1].opts))
|
||||
if (!document.getElementById(v[1][0]).collapsed)].join(""),
|
||||
|
||||
completer: function (context)
|
||||
array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
|
||||
setter: function (value) {
|
||||
|
||||
Reference in New Issue
Block a user