From 7dae1e801450d371c2eac96b7498de0fd53b4eb8 Mon Sep 17 00:00:00 2001 From: "silver%warwickcompsoc.co.uk" Date: Thu, 21 Apr 2005 20:21:56 +0000 Subject: [PATCH] Bug 227093 - Prompt the user when trying to close while connected. r=samuel a=asa p=oriyanh@gmail.com (Oriyan Hermoni) --- extensions/irc/xul/content/handlers.js | 21 +++++++++++++++---- extensions/irc/xul/content/prefs.js | 3 ++- .../irc/xul/locale/en-US/chatzilla.properties | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/extensions/irc/xul/content/handlers.js b/extensions/irc/xul/content/handlers.js index 3d89618e6695..07359e512f1c 100644 --- a/extensions/irc/xul/content/handlers.js +++ b/extensions/irc/xul/content/handlers.js @@ -123,9 +123,6 @@ function onClose() if ("userClose" in client && client.userClose) return true; - client.userClose = true; - display(MSG_CLOSING); - if (!("getConnectionCount" in client) || client.getConnectionCount() == 0) { @@ -134,7 +131,23 @@ function onClose() } /* otherwise, try to close out gracefully */ - client.quit(client.userAgent); + var close = true; + if (client.prefs["warnOnClose"]) + { + const buttons = ["!yes", "!no"]; + var checkState = { value: true }; + var rv = confirmEx(MSG_CONFIRM_QUIT, buttons, 0, MSG_WARN_ON_EXIT, + checkState); + close = (rv == 0); + client.prefs["warnOnClose"] = checkState.value; + } + + if (close) + { + client.userClose = true; + display(MSG_CLOSING); + client.quit(client.userAgent); + } return false; } diff --git a/extensions/irc/xul/content/prefs.js b/extensions/irc/xul/content/prefs.js index 0bab684440b3..f9091a5aacd9 100644 --- a/extensions/irc/xul/content/prefs.js +++ b/extensions/irc/xul/content/prefs.js @@ -196,7 +196,8 @@ function initPrefs() ["usermode", "+i", ".ident"], ["userHeader", true, "global.header"], ["userLog", false, "global.log"], - ["userMaxLines", 200, "global.maxLines"] + ["userMaxLines", 200, "global.maxLines"], + ["warnOnClose", true, "global"] ]; client.prefManager.addPrefs(prefs); diff --git a/extensions/irc/xul/locale/en-US/chatzilla.properties b/extensions/irc/xul/locale/en-US/chatzilla.properties index 23ac99bb3459..c4bfb980a304 100644 --- a/extensions/irc/xul/locale/en-US/chatzilla.properties +++ b/extensions/irc/xul/locale/en-US/chatzilla.properties @@ -942,6 +942,8 @@ msg.tabdnd.drop = Would you like to use the file ``%S'' as your new motif? msg.default.status = Welcome to ChatZilla! msg.closing = Disconnecting from IRC. Click close again to exit now. +msg.confirm.quit = You are still connected to some networks, are you sure you want to quit ChatZilla?\nConfirming will close the window, and disconnect from all the networks and channels you're connected to. +msg.warn.on.exit = Warn me when quitting while still connected msg.whois.name = "%S <%S@%S> ``%S'' msg.whois.channels = "%S: member of %S" @@ -1270,6 +1272,8 @@ pref.username.label = Username pref.username.help = Your username is used to construct your "host mask", which is a string representing you, by including your connection's host name and this username. It is sometimes used for setting auto-op, bans, and other things specific to one person. pref.usermode.label = Usermode pref.usermode.help = Your usermode determines how the IRC server treats you (it is a list of letters preceded by "+") - for example, you can get the server to send to message about "behind the scenes"-like things but setting a different usermode. The most common option, "i", makes you not show up as a member of a channel unless the user making the query is already in the channel (it stands for "invisible"). +pref.warnOnClose.label = Warn me when quitting while still connected +pref.warnOnClose.help = When quitting while still connected to networks, a message appears asking you if you are sure you want to quit. Uncheck this to disable it. # Preference group labels #