1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-07 02:33:32 +02:00

[bootstrap] Purge stale modules on upgrade as well as explicit rehash.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-25 18:41:32 -05:00
parent e5fd0ccf18
commit 26bd1c1075
6 changed files with 22 additions and 15 deletions

3
common/bootstrap.js vendored
View File

@@ -186,6 +186,9 @@ function init() {
function shutdown(data, reason) { function shutdown(data, reason) {
dump("dactyl: bootstrap: shutdown " + reasonToString(reason) + "\n"); dump("dactyl: bootstrap: shutdown " + reasonToString(reason) + "\n");
if (reason != APP_SHUTDOWN) { if (reason != APP_SHUTDOWN) {
if ([ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason) >= 0)
services.observer.notifyObservers(null, "dactyl-purge", null);
services.observer.notifyObservers(null, "dactyl-cleanup", null); services.observer.notifyObservers(null, "dactyl-cleanup", null);
for (let factory in values(components)) for (let factory in values(components))
// TODO: Categories; // TODO: Categories;

View File

@@ -1249,9 +1249,9 @@ var CommandLine = Module("commandline", {
availableHeight -= extra || 0; availableHeight -= extra || 0;
doc.body.style.minWidth = this.widgets.commandbar.commandline.scrollWidth + "px"; doc.body.style.minWidth = this.widgets.commandbar.commandline.scrollWidth + "px";
this.widgets.mowContainer.height = Math.min(doc.height, availableHeight) + "px"; this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px";
this.timeout(function () this.timeout(function ()
this.widgets.mowContainer.height = Math.min(doc.height, availableHeight) + "px", this.widgets.mowContainer.height = Math.min(doc.body.clientHeight, availableHeight) + "px",
0); 0);
doc.body.style.minWidth = ""; doc.body.style.minWidth = "";

View File

@@ -13,7 +13,6 @@
*/ */
var Events = Module("events", { var Events = Module("events", {
init: function () { init: function () {
let _events = "if (window.dactyl && dactyl.modules.loaded.events) return dactyl.modules.events"
util.overlayWindow(window, { util.overlayWindow(window, {
append: <e4x xmlns={XUL}> append: <e4x xmlns={XUL}>
<window id={document.documentElement.id}> <window id={document.documentElement.id}>
@@ -21,9 +20,9 @@ var Events = Module("events", {
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !--> from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
<!-- I don't think we really need this. Kris --> <!-- I don't think we really need this. Kris -->
<commandset id="onPentadactylFocus" commandupdater="true" events="focus" <commandset id="onPentadactylFocus" commandupdater="true" events="focus"
oncommandupdate={_events + ".onFocusChange(event);"}/> oncommandupdate="dactyl.modules.events.onFocusChange(event);"/>
<commandset id="onPentadactylSelect" commandupdater="true" events="select" <commandset id="onPentadactylSelect" commandupdater="true" events="select"
oncommandupdate={_events + ".onSelectionChange(event);"}/> oncommandupdate="dactyl.modules.events.onSelectionChange(event);"/>
</window> </window>
</e4x>.elements() </e4x>.elements()
}); });
@@ -121,7 +120,8 @@ var Events = Module("events", {
*/ */
wrapListener: function wrapListener(method, self) { wrapListener: function wrapListener(method, self) {
self = self || this; self = self || this;
return function wrappedListener(event) { method.wrapped = wrappedListener;
function wrappedListener(event) {
try { try {
method.apply(self, arguments); method.apply(self, arguments);
} }
@@ -133,6 +133,7 @@ var Events = Module("events", {
dactyl.echoerr("Processing " + event.type + " event: " + (e.echoerr || e)); dactyl.echoerr("Processing " + event.type + " event: " + (e.echoerr || e));
} }
}; };
return wrappedListener;
}, },
/** /**

View File

@@ -249,10 +249,10 @@ var Overlay = Module("Overlay", {
util.dump("Loaded in " + (Date.now() - start) + "ms"); util.dump("Loaded in " + (Date.now() - start) + "ms");
modules.events.addSessionListener(window, "unload", function onUnload() { modules.events.addSessionListener(window, "unload", function onUnload() {
window.removeEventListener("unload", onUnload, false); window.removeEventListener("unload", onUnload.wrapped, false);
for (let [, mod] in iter(modules)) for (let [, mod] in iter(modules))
if (mod instanceof ModuleBase && "destroy" in mod) if (mod instanceof ModuleBase && "destroy" in mod)
mod.destroy(); util.trapErrors(mod.destroy, mod);
}, false); }, false);
} }
})); }));

View File

@@ -949,6 +949,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
module.init(); module.init();
} }
}, },
"dactyl-purge": function () {
this.rehashing = true;
},
"toplevel-window-ready": function (window, data) { "toplevel-window-ready": function (window, data) {
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) { window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
if (event.originalTarget === window.document) { if (event.originalTarget === window.document) {
@@ -1163,9 +1166,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
}), }),
rehash: function () { rehash: function () {
this.rehashing = true;
this.addon.userDisabled = true;
this.timeout(function () { this.timeout(function () {
this.rehashing = true;
this.addon.userDisabled = true;
this.addon.userDisabled = false; this.addon.userDisabled = false;
}); });
}, },

View File

@@ -26,28 +26,28 @@ const Config = Module("config", ConfigBase, {
group="sidebar" group="sidebar"
sidebarurl="chrome://mozapps/content/extensions/extensions.xul" sidebarurl="chrome://mozapps/content/extensions/extensions.xul"
sidebartitle="Add-ons" sidebartitle="Add-ons"
oncommand="toggleSidebar('pentadactyl-viewAddonsSidebar');"/> oncommand="toggleSidebar(this.id);"/>
<broadcaster id="pentadactyl-viewConsoleSidebar" <broadcaster id="pentadactyl-viewConsoleSidebar"
autoCheck="false" autoCheck="false"
type="checkbox" type="checkbox"
group="sidebar" group="sidebar"
sidebarurl="chrome://global/content/console.xul" sidebarurl="chrome://global/content/console.xul"
sidebartitle="Console" sidebartitle="Console"
oncommand="toggleSidebar('pentadactyl-viewConsoleSidebar');"/> oncommand="toggleSidebar(this.id);"/>
<broadcaster id="pentadactyl-viewDownloadsSidebar" <broadcaster id="pentadactyl-viewDownloadsSidebar"
autoCheck="false" autoCheck="false"
type="checkbox" type="checkbox"
group="sidebar" group="sidebar"
sidebarurl="chrome://mozapps/content/downloads/downloads.xul" sidebarurl="chrome://mozapps/content/downloads/downloads.xul"
sidebartitle="Downloads" sidebartitle="Downloads"
oncommand="toggleSidebar('pentadactyl-viewDownloadsSidebar');"/> oncommand="toggleSidebar(this.id);"/>
<broadcaster id="pentadactyl-viewPreferencesSidebar" <broadcaster id="pentadactyl-viewPreferencesSidebar"
autoCheck="false" autoCheck="false"
type="checkbox" type="checkbox"
group="sidebar" group="sidebar"
sidebarurl="about:config" sidebarurl="about:config"
sidebartitle="Preferences" sidebartitle="Preferences"
oncommand="toggleSidebar('pentadactyl-viewPreferencesSidebar');"/> oncommand="toggleSidebar(this.id);"/>
</broadcasterset> </broadcasterset>
</e4x>.elements() </e4x>.elements()
}); });
@@ -223,7 +223,7 @@ const Config = Module("config", ConfigBase, {
}, },
{ argCount: "0" }); { argCount: "0" });
commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"], commands.add(["sideb[ar]", "sb[ar]", "sbop[en]"],
"Open the sidebar window", "Open the sidebar window",
function (args) { function (args) {
function compare(a, b) util.compareIgnoreCase(a, b) == 0 function compare(a, b) util.compareIgnoreCase(a, b) == 0