From c8a095c755e13032e4c17766d2d3da67248d90d3 Mon Sep 17 00:00:00 2001 From: shatty Date: Sun, 10 Aug 2003 07:52:07 +0000 Subject: [PATCH] implemented proper window/app behavior for pref files and command line opening. every sent ref should open a separate window, separate app. every command line invocation opens exactly one window, a separate app. this was tested by using the built-in meta-Q application quit keystroke sequence and verifying that exactly one window was closed, using various different orderings git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4261 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/terminal/TerminalApp.cpp | 57 ++++++++++------------------ src/apps/terminal/TerminalWindow.cpp | 11 ++++-- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/src/apps/terminal/TerminalApp.cpp b/src/apps/terminal/TerminalApp.cpp index 6cece968ad..a316b71256 100644 --- a/src/apps/terminal/TerminalApp.cpp +++ b/src/apps/terminal/TerminalApp.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -52,31 +53,10 @@ void TerminalApp::DispatchMessage(BMessage *msg, BHandler *handler) } } -#include - void TerminalApp::MessageReceived(BMessage *message) { switch (message->what) { - case TERMINAL_START_NEW_TERMINAL: { - status_t result = be_roster->Launch(APP_SIGNATURE); - if (result != B_OK) { - // TODO: notify user - } - } - break; - case B_SILENT_RELAUNCH: { - BAlert * go = new BAlert("SILENT","RELAUNCH","OH YEAH"); - go->Go(); - OpenTerminal(); - } - break; - case B_REFS_RECEIVED: { - BAlert * go = new BAlert("REFS","RECEIVED","OH YEAH"); - go->Go(); - OpenTerminal(message); - } - break; default: BApplication::MessageReceived(message); break; @@ -88,26 +68,30 @@ TerminalApp::OpenTerminal(BMessage * message) { BPoint windowPoint(7,26); TerminalWindow * terminal = new TerminalWindow(windowPoint,message); + fWindowOpened = true; } +#include + void TerminalApp::RefsReceived(BMessage *message) { - int32 refNum; - entry_ref ref; - status_t err; - - refNum = 0; - do { - err = message->FindRef("refs", refNum, &ref); - if (err != B_OK) - return; - BMessage single(OPEN_TERMINAL); - single.AddRef("refs",&ref); - OpenTerminal(&single); - refNum++; - printf("refNum = %ld\n",refNum); - } while (true); + int32 i = 0; + entry_ref ref; + if (IsLaunching()) { + // peel off the first ref and open it ourselves + if (message->FindRef("refs",i++,&ref) == B_OK) { + BMessage file(OPEN_TERMINAL); + file.AddRef("refs",&ref); + OpenTerminal(&file); + } + } + // handle any other refs by launching them as separate apps + while (message->FindRef("refs",i++,&ref) == B_OK) { + BMessage * file = new BMessage(OPEN_TERMINAL); + file->AddRef("refs",&ref); + be_roster->Launch(APP_SIGNATURE,file); + } } void @@ -250,6 +234,7 @@ TerminalApp::ArgvReceived(int32 argc, char * const argv[], const char * cwd) } break; case '?': + printf("wth is that?\n"); return; break; default: diff --git a/src/apps/terminal/TerminalWindow.cpp b/src/apps/terminal/TerminalWindow.cpp index 618c2d10b1..7d09b7bebe 100644 --- a/src/apps/terminal/TerminalWindow.cpp +++ b/src/apps/terminal/TerminalWindow.cpp @@ -92,11 +92,9 @@ TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef) fSwitchTerminals = new BMenuItem("Switch Terminals", new BMessage(TERMINAL_SWITCH_TERMINAL), 'G'); fTerminal->AddItem(fSwitchTerminals); fSwitchTerminals->SetTrigger('T'); - fSwitchTerminals->SetTarget(be_app); fStartNewTerminal = new BMenuItem("Start New Terminal", new BMessage(TERMINAL_START_NEW_TERMINAL), 'N'); fTerminal->AddItem(fStartNewTerminal); - fStartNewTerminal->SetTarget(be_app); fLogToFile = new BMenuItem("Log to File...", new BMessage(TERMINAL_LOG_TO_FILE)); fTerminal->AddItem(fLogToFile); @@ -239,7 +237,14 @@ TerminalWindow::RestoreSettings(entry_ref * settingsRef) void TerminalWindow::MessageReceived(BMessage *message) { - switch(message->what){ + switch (message->what){ + case TERMINAL_START_NEW_TERMINAL: { + status_t result = be_roster->Launch(APP_SIGNATURE); + if (result != B_OK) { + // TODO: notify user + } + } + break; case B_COPY: fTextView->Copy(be_clipboard); break;