summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Tauner <[email protected]>2017-08-11 11:47:54 +0200
committerraveit65 <[email protected]>2019-04-23 11:07:26 +0200
commitd64d7d1dd43beee7b2e25af778de58e4c60d5ce5 (patch)
treedd9cf0b9bb106f7a6ebcdd768fdee29661788182
parent265c76e34b90b9bb65c59f3e9875ecb83eafe399 (diff)
downloadmate-terminal-d64d7d1dd43beee7b2e25af778de58e4c60d5ce5.tar.bz2
mate-terminal-d64d7d1dd43beee7b2e25af778de58e4c60d5ce5.tar.xz
Show confirmation dialog if there are multiple open tabs on closing
As a followup #149 this fixes the behavior of the code to match the description of the respective gsettings entry "confirm-window-close". Said entry is also updated to reflect the change added in #149. No changes to the gsettings handling were made thus only users who have "confirm-window-close" turned on already will see the new behavior.
-rw-r--r--src/org.mate.terminal.gschema.xml.in2
-rw-r--r--src/terminal-window.c33
2 files changed, 20 insertions, 15 deletions
diff --git a/src/org.mate.terminal.gschema.xml.in b/src/org.mate.terminal.gschema.xml.in
index 21c0be3..2e0659c 100644
--- a/src/org.mate.terminal.gschema.xml.in
+++ b/src/org.mate.terminal.gschema.xml.in
@@ -72,7 +72,7 @@
<key name="confirm-window-close" type="b">
<default>true</default>
<summary>Whether to ask for confirmation when closing terminal windows</summary>
- <description>Whether to ask for confirmation when closing a terminal window which has more than one open tab.</description>
+ <description>Whether to ask for confirmation when closing a terminal window which has more than one open tab or any foreground subprocesses.</description>
</key>
<key name="middle-click-closes-tabs" type="b">
<default>false</default>
diff --git a/src/terminal-window.c b/src/terminal-window.c
index c62bec4..8fc6c1a 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3506,7 +3506,9 @@ confirm_close_window_or_tab (TerminalWindow *window,
GtkWidget *dialog;
GSettings *settings;
gboolean do_confirm;
+ gboolean has_processes;
int n_tabs;
+ char *confirm_msg;
if (priv->confirm_close_dialog)
{
@@ -3523,7 +3525,7 @@ confirm_close_window_or_tab (TerminalWindow *window,
if (screen)
{
- do_confirm = terminal_screen_has_foreground_process (screen);
+ has_processes = terminal_screen_has_foreground_process (screen);
n_tabs = 1;
}
else
@@ -3540,16 +3542,25 @@ confirm_close_window_or_tab (TerminalWindow *window,
TerminalScreen *terminal_screen;
terminal_screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (t->data));
- if (terminal_screen_has_foreground_process (terminal_screen))
- {
- do_confirm = TRUE;
+ has_processes = terminal_screen_has_foreground_process (terminal_screen);
+ if (has_processes)
break;
- }
}
g_list_free (tabs);
}
- if (!do_confirm)
+
+ if (has_processes)
+ {
+ if (n_tabs > 1)
+ confirm_msg = _("There are still processes running in some terminals in this window. "
+ "Closing the window will kill all of them.");
+ else
+ confirm_msg = _("There is still a process running in this terminal. "
+ "Closing the terminal will kill it.");
+ } else if (n_tabs > 1)
+ confirm_msg = _("There are multiple tabs open in this window.");
+ else
return FALSE;
dialog = priv->confirm_close_dialog =
@@ -3559,14 +3570,8 @@ confirm_close_window_or_tab (TerminalWindow *window,
GTK_BUTTONS_CANCEL,
"%s", n_tabs > 1 ? _("Close this window?") : _("Close this terminal?"));
- if (n_tabs > 1)
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", _("There are still processes running in some terminals in this window. "
- "Closing the window will kill all of them."));
- else
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s", _("There is still a process running in this terminal. "
- "Closing the terminal will kill it."));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", confirm_msg);
gtk_window_set_title (GTK_WINDOW (dialog), "");