From 45860b0d58795009bf90c1a1970c1a17fc5ffb8c Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 17 Jan 2011 15:18:31 -0500 Subject: [PATCH] Fix stupid :restart confirmation. --- common/content/dactyl.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e454e1b0..cc469477 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1089,6 +1089,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { node.collapsed = !visible; }, + confirmQuit: function confirmQuit() + prefs.withContext(function () { + prefs.set("browser.warnOnQuit", false); + return !window.canQuitApplication(); + }), + /** * Quit the host application, no matter how many tabs/windows are open. * @@ -1098,11 +1104,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * windows could be closed individually. */ quit: function (saveSession, force) { - if (!force && - prefs.withContext(function () { - prefs.set("browser.warnOnQuit", false); - return !canQuitApplication(); - })) + if (!force && !this.confirmQuit()) return; let pref = "browser.startup.page"; @@ -1115,6 +1117,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { services.appStartup.quit(Ci.nsIAppStartup[force ? "eForceQuit" : "eAttemptQuit"]); }, + /** + * Restart the host application. + */ + restart: function () { + if (!this.confirmQuit()) + return; + + services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); + }, + /** * Returns an array of URLs parsed from *str*. * @@ -1214,16 +1226,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { util.reportError(error); }, - /** - * Restart the host application. - */ - restart: function () { - if (!canQuitApplication()) - return; - - services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); - }, - /** * Parses a Dactyl command-line string i.e. the value of the * -dactyl command-line option.