mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-28 13:25:45 +01:00
Bootstrap cleanup work.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -152,6 +152,14 @@ const CommandWidgets = Class("CommandWidgets", {
|
||||
return this.commandbar;
|
||||
}
|
||||
});
|
||||
|
||||
let fontSize = util.computedStyle(document.getElementById(config.mainWindowId)).fontSize;
|
||||
styles.registerSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
|
||||
"body { font-size: " + fontSize + "; }");
|
||||
},
|
||||
cleanup: function cleanup() {
|
||||
styles.unregisterSheet("chrome://dactyl/skin/dactyl.css");
|
||||
},
|
||||
addElement: function (obj) {
|
||||
const self = this;
|
||||
@@ -1810,12 +1818,6 @@ const CommandLine = Module("commandline", {
|
||||
host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host))));
|
||||
}
|
||||
});
|
||||
},
|
||||
styles: function () {
|
||||
let fontSize = util.computedStyle(document.getElementById(config.mainWindowId)).fontSize;
|
||||
styles.registerSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
|
||||
"body { font-size: " + fontSize + "; }");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ const ConfigBase = Class(ModuleBase, {
|
||||
* must be strings as entered via :set.
|
||||
*/
|
||||
defaults: { guioptions: "rb" },
|
||||
cleanups: {},
|
||||
|
||||
/**
|
||||
* @property {[["string", "string", "function"]]} An array of
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
given in the LICENSE.txt file included with this file.
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://dactyl/skin/dactyl.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE overlay SYSTEM "dactyl.dtd" [
|
||||
<!ENTITY dactyl.content "chrome://dactyl/content/">
|
||||
]>
|
||||
|
||||
@@ -281,6 +281,8 @@ const Option = Class("Option", {
|
||||
*/
|
||||
description: "",
|
||||
|
||||
cleanupValue: null,
|
||||
|
||||
/**
|
||||
* @property {function(CompletionContext, Args)} This option's completer.
|
||||
* @see CompletionContext
|
||||
@@ -637,6 +639,12 @@ const Options = Module("options", {
|
||||
}, window);
|
||||
},
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let opt in this)
|
||||
if (opt.cleanupValue != null)
|
||||
opt.value = opt.parse(opt.cleanupValue);
|
||||
},
|
||||
|
||||
/** @property {Iterator(Option)} @private */
|
||||
__iterator__: function ()
|
||||
values(this._options.sort(function (a, b) String.localeCompare(a.name, b.name))),
|
||||
|
||||
@@ -36,6 +36,15 @@ const Tabs = Module("tabs", {
|
||||
};
|
||||
},
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||
function node(clas) document.getAnonymousElementByAttribute(tab, "class", clas);
|
||||
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||
if (elem)
|
||||
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
||||
}
|
||||
},
|
||||
|
||||
_updateTabCount: function () {
|
||||
if (dactyl.has("Gecko2"))
|
||||
for (let [i, tab] in Iterator(this.visibleTabs)) {
|
||||
@@ -43,15 +52,15 @@ const Tabs = Module("tabs", {
|
||||
if (!node("dactyl-tab-number")) {
|
||||
let nodes = {};
|
||||
let dom = util.xmlToDom(<xul xmlns:xul={XUL} xmlns:html={XHTML}
|
||||
><xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-number"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-icon-number"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox
|
||||
></xul>.*, document, nodes);
|
||||
let img = node("tab-icon-image");
|
||||
img.parentNode.appendChild(dom);
|
||||
tab.__defineGetter__("ordinal", function () Number(nodes.icon.value));
|
||||
tab.__defineSetter__("ordinal", function (i) nodes.icon.value = nodes.label.textContent = i);
|
||||
tab.__defineGetter__("dactylOrdinal", function () Number(nodes.icon.value));
|
||||
tab.__defineSetter__("dactylOrdinal", function (i) nodes.icon.value = nodes.label.textContent = i);
|
||||
}
|
||||
tab.ordinal = i + 1;
|
||||
tab.dactylOrdinal = i + 1;
|
||||
}
|
||||
statusline.updateTabCount(true);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user