diff --git a/src/apps/terminal/TermApp.cpp b/src/apps/terminal/TermApp.cpp index 9454c47c60..12d88bc9fe 100644 --- a/src/apps/terminal/TermApp.cpp +++ b/src/apps/terminal/TermApp.cpp @@ -73,14 +73,7 @@ const ulong MSG_TERM_IS_MINIMIZE = 'mtim'; TermApp::TermApp() : BApplication(TERM_SIGNATURE) { - BList teams; - be_roster->GetAppList(TERM_SIGNATURE, &teams); - fWindowNumber = teams.CountItems(); - - if (fWindowNumber == 0) { - be_roster->GetAppList(R5_TERM_SIGNATURE, &teams); - fWindowNumber = teams.CountItems(); - } + fWindowNumber = FindTerminalId(); char title[256]; snprintf(title, sizeof(title), "Terminal %d", fWindowNumber); @@ -200,10 +193,6 @@ void TermApp::MessageReceived(BMessage* msg) { switch (msg->what) { - case MENU_NEW_TREM: - RunNewTerm(); - break; - case MENU_SWITCH_TERM: SwitchTerm(); break; @@ -391,18 +380,6 @@ TermApp::MakeTermWindow(BRect &frame) } -void -TermApp::RunNewTerm() -{ - app_info info; - be_app->GetAppInfo(&info); - - // try launching two different ways to work around possible problems - if (be_roster->Launch(&info.ref)!=B_OK) - be_roster->Launch(TERM_SIGNATURE); -} - - void TermApp::ActivateTermWindow(team_id id) { @@ -462,6 +439,51 @@ TermApp::IsMinimize(team_id id) return hidden; } + +int32 +TermApp::FindTerminalId() +{ + BList teams; + be_roster->GetAppList(TERM_SIGNATURE, &teams); + int32 count = teams.CountItems(); + int32 numbers[count]; + thread_info info; + get_thread_info(find_thread(NULL), &info); + + for (int32 i=0; i #include #include +#include #include #include #include @@ -202,7 +203,7 @@ TermWindow::SetupMenu(void) */ fFilemenu = new BMenu("Terminal"); fFilemenu->AddItem(new BMenuItem("Switch Terminals", new BMessage(MENU_SWITCH_TERM),'G')); - fFilemenu->AddItem(new BMenuItem("Start New Terminal", new BMessage(MENU_NEW_TREM), 'N')); + fFilemenu->AddItem(new BMenuItem("Start New Terminal", new BMessage(MENU_NEW_TERM), 'N')); fFilemenu->AddSeparatorItem(); fFilemenu->AddItem(new BMenuItem("Page Setup...", new BMessage(MENU_PAGE_SETUP))); fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P')); @@ -289,8 +290,14 @@ TermWindow::MessageReceived(BMessage *message) be_app->PostMessage(MENU_SWITCH_TERM); break; - case MENU_NEW_TREM: - be_app->PostMessage(MENU_NEW_TREM); + case MENU_NEW_TERM: { + app_info info; + be_app->GetAppInfo(&info); + + // try launching two different ways to work around possible problems + if (be_roster->Launch(&info.ref)!=B_OK) + be_roster->Launch(TERM_SIGNATURE); + } break; case MENU_PREF_OPEN: @@ -703,3 +710,6 @@ TermWindow::DoPrint() job.CommitJob(); //#endif } + + +