diff --git a/src/dialog-switch.c b/src/dialog-switch.c index be6153592..c480aab0b 100644 --- a/src/dialog-switch.c +++ b/src/dialog-switch.c @@ -129,6 +129,12 @@ dialog_switch_remove (Dlg_head *h) } } +size_t +dialog_switch_num (void) +{ + return g_list_length (mc_dialogs); +} + void dialog_switch_next (void) { diff --git a/src/dialog-switch.h b/src/dialog-switch.h index 190594e40..adfdfb68c 100644 --- a/src/dialog-switch.h +++ b/src/dialog-switch.h @@ -2,10 +2,13 @@ #ifndef MC_DIALOG_SWITCH_H #define MC_DIALOG_SWITCH_H +#include + struct Dlg_head; void dialog_switch_add (struct Dlg_head *h); void dialog_switch_remove (struct Dlg_head *h); +size_t dialog_switch_num (void); void dialog_switch_next (void); void dialog_switch_prev (void); diff --git a/src/main.c b/src/main.c index be261a22e..2546bc148 100644 --- a/src/main.c +++ b/src/main.c @@ -335,20 +335,29 @@ static int quit_cmd_internal (int quiet) { int q = quit; + size_t n = dialog_switch_num () - 1; - if (quiet || !confirm_exit) + if (n != 0) { - q = 1; - } - else - { - if (query_dialog - (_("The Midnight Commander"), - _("Do you really want to quit the Midnight Commander?"), D_NORMAL, - 2, _("&Yes"), _("&No")) == 0) + char msg[BUF_MEDIUM]; + + g_snprintf (msg, sizeof (msg), + ngettext ("You have %zd opened screen. Quit anyway?", + "You have %zd opened screens. Quit anyway?", n), + n); + + if (query_dialog (_("The Midnight Commander"), msg, + D_NORMAL, 2, _("&Yes"), _("&No")) == 0) q = 1; - } - if (q) + + } else if (quiet || !confirm_exit) + q = 1; + else if (query_dialog (_("The Midnight Commander"), + _("Do you really want to quit the Midnight Commander?"), + D_NORMAL, 2, _("&Yes"), _("&No")) == 0) + q = 1; + + if (q != 0) { #ifdef HAVE_SUBSHELL_SUPPORT if (!use_subshell) @@ -357,7 +366,8 @@ quit_cmd_internal (int quiet) #endif stop_dialogs (); } - if (q) + + if (q != 0) quit |= 1; return quit; }