ProcessController: Use more BString::SetToFormat.

This commit is contained in:
Augustin Cavalier
2025-03-12 08:31:19 -04:00
parent 139c35c9b9
commit ed8ca68825
@@ -287,7 +287,8 @@ ProcessController::MessageReceived(BMessage *message)
team_id team; team_id team;
thread_id thread; thread_id thread;
BAlert *alert; BAlert *alert;
char question[1000]; BString question;
switch (message->what) { switch (message->what) {
case 'Puls': case 'Puls':
Update (); Update ();
@@ -307,13 +308,13 @@ ProcessController::MessageReceived(BMessage *message)
info_pack infos; info_pack infos;
if (get_team_info(team, &infos.team_info) == B_OK) { if (get_team_info(team, &infos.team_info) == B_OK) {
get_team_name_and_icon(infos); get_team_name_and_icon(infos);
snprintf(question, sizeof(question), question.SetToFormat(
B_TRANSLATE("What do you want to do with the team \"%s\"?"), B_TRANSLATE("What do you want to do with the team \"%s\"?"),
infos.team_name); infos.team_name);
alert = new BAlert(B_TRANSLATE("Please confirm"), question, alert = new BAlert(B_TRANSLATE("Please confirm"), question,
B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"), B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"),
B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL, B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL,
B_STOP_ALERT); B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
int result = alert->Go(); int result = alert->Go();
switch (result) { switch (result) {
@@ -342,8 +343,7 @@ ProcessController::MessageReceived(BMessage *message)
thread_info thinfo; thread_info thinfo;
if (get_thread_info(thread, &thinfo) == B_OK) { if (get_thread_info(thread, &thinfo) == B_OK) {
#if DEBUG_THREADS #if DEBUG_THREADS
snprintf(question, sizeof(question), question.SetToFormat(B_TRANSLATE("What do you want to do "
B_TRANSLATE("What do you want to do "
"with the thread \"%s\"?"), thinfo.name); "with the thread \"%s\"?"), thinfo.name);
alert = new BAlert(B_TRANSLATE("Please confirm"), question, alert = new BAlert(B_TRANSLATE("Please confirm"), question,
B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"),
@@ -353,7 +353,7 @@ ProcessController::MessageReceived(BMessage *message)
#define KILL 2 #define KILL 2
#else #else
snprintf(question, sizeof(question), question.SetToFormat(
B_TRANSLATE("Are you sure you want " B_TRANSLATE("Are you sure you want "
"to kill the thread \"%s\"?"), thinfo.name); "to kill the thread \"%s\"?"), thinfo.name);
alert = new BAlert(B_TRANSLATE("Please confirm"), question, alert = new BAlert(B_TRANSLATE("Please confirm"), question,
@@ -828,17 +828,17 @@ thread_popup(void *arg)
// CPU on/off section // CPU on/off section
if (gCPUcount > 1) { if (gCPUcount > 1) {
for (unsigned int i = 0; i < gCPUcount; i++) { for (unsigned int i = 0; i < gCPUcount; i++) {
char item_name[32]; BString itemName;
sprintf (item_name, B_TRANSLATE("Processor %d"), i + 1); itemName.SetToFormat(B_TRANSLATE("Processor %d"), i + 1);
BMessage* m = new BMessage ('CPU '); BMessage* m = new BMessage('CPU ');
m->AddInt32 ("cpu", i); m->AddInt32("cpu", i);
item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m); item = new IconMenuItem (gPCView->fProcessorIcon, itemName, m);
if (_kern_cpu_enabled(i)) if (_kern_cpu_enabled(i))
item->SetMarked (true); item->SetMarked(true);
item->SetTarget(gPCView); item->SetTarget(gPCView);
addtopbottom(item); addtopbottom(item);
} }
addtopbottom (new BSeparatorItem ()); addtopbottom(new BSeparatorItem());
} }
// Scheduler modes // Scheduler modes