TermWindow::_CanClose(): Collect the names of the running processes and display
them in the alert. Fixes #6862. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39564 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -293,34 +293,56 @@ TermWindow::_CanClose(int32 index)
|
|||||||
if (!warnOnExit)
|
if (!warnOnExit)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool isBusy = false;
|
uint32 busyProcessCount = 0;
|
||||||
if (index != -1)
|
BString busyProcessNames;
|
||||||
isBusy = _TermViewAt(index)->IsShellBusy();
|
// all names, separated by "\n\t"
|
||||||
else {
|
|
||||||
|
if (index != -1) {
|
||||||
|
ActiveProcessInfo info;
|
||||||
|
if (_TermViewAt(index)->GetActiveProcessInfo(info)
|
||||||
|
&& info.ID() != info.ShellProcessID()) {
|
||||||
|
busyProcessCount++;
|
||||||
|
busyProcessNames = info.Name();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (int32 i = 0; i < fSessions.CountItems(); i++) {
|
for (int32 i = 0; i < fSessions.CountItems(); i++) {
|
||||||
if (_TermViewAt(i)->IsShellBusy()) {
|
ActiveProcessInfo info;
|
||||||
isBusy = true;
|
if (_TermViewAt(i)->GetActiveProcessInfo(info)
|
||||||
break;
|
&& info.ID() != info.ShellProcessID()) {
|
||||||
|
if (++busyProcessCount > 1)
|
||||||
|
busyProcessNames << "\n\t";
|
||||||
|
busyProcessNames << info.Name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBusy) {
|
if (busyProcessCount == 0)
|
||||||
const char* alertMessage = index == -1 || fSessions.CountItems() == 1
|
return true;
|
||||||
? B_TRANSLATE("A process is still running.\n"
|
|
||||||
|
BString alertMessage;
|
||||||
|
if (busyProcessCount == 1) {
|
||||||
|
// Only one pending process. Select the alert text depending on whether
|
||||||
|
// the terminal will be closed.
|
||||||
|
alertMessage = index == -1 || fSessions.CountItems() == 1
|
||||||
|
? B_TRANSLATE("The process \"%1\" is still running.\n"
|
||||||
"If you close the Terminal, the process will be killed.")
|
"If you close the Terminal, the process will be killed.")
|
||||||
: B_TRANSLATE("A process is still running.\n"
|
: B_TRANSLATE("The process \"%1\" is still running.\n"
|
||||||
"If you close the tab, the process will be killed.");
|
"If you close the tab, the process will be killed.");
|
||||||
BAlert* alert = new BAlert(B_TRANSLATE("Really close?"),
|
} else {
|
||||||
alertMessage, B_TRANSLATE("Close"), B_TRANSLATE("Cancel"), NULL,
|
// multiple pending processes
|
||||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
alertMessage = B_TRANSLATE(
|
||||||
alert->SetShortcut(1, B_ESCAPE);
|
"The following processes are still running:\n\n"
|
||||||
int32 result = alert->Go();
|
"\t%1\n\n"
|
||||||
if (result == 1)
|
"If you close the tab, the processes will be killed.");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
alertMessage.ReplaceFirst("%1", busyProcessNames);
|
||||||
|
|
||||||
|
BAlert* alert = new BAlert(B_TRANSLATE("Really close?"),
|
||||||
|
alertMessage, B_TRANSLATE("Close"), B_TRANSLATE("Cancel"), NULL,
|
||||||
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
|
alert->SetShortcut(1, B_ESCAPE);
|
||||||
|
return alert->Go() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user