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
This commit is contained in:
shatty 2003-08-10 07:52:07 +00:00
parent a93443a14a
commit c8a095c755
2 changed files with 29 additions and 39 deletions

View File

@ -1,6 +1,7 @@
#include <Autolock.h> #include <Autolock.h>
#include <Path.h> #include <Path.h>
#include <Point.h> #include <Point.h>
#include <Alert.h>
#include <Constants.h> #include <Constants.h>
#include <TerminalApp.h> #include <TerminalApp.h>
@ -52,31 +53,10 @@ void TerminalApp::DispatchMessage(BMessage *msg, BHandler *handler)
} }
} }
#include <Alert.h>
void void
TerminalApp::MessageReceived(BMessage *message) TerminalApp::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_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: default:
BApplication::MessageReceived(message); BApplication::MessageReceived(message);
break; break;
@ -88,26 +68,30 @@ TerminalApp::OpenTerminal(BMessage * message)
{ {
BPoint windowPoint(7,26); BPoint windowPoint(7,26);
TerminalWindow * terminal = new TerminalWindow(windowPoint,message); TerminalWindow * terminal = new TerminalWindow(windowPoint,message);
fWindowOpened = true;
} }
#include <Roster.h>
void void
TerminalApp::RefsReceived(BMessage *message) TerminalApp::RefsReceived(BMessage *message)
{ {
int32 refNum; int32 i = 0;
entry_ref ref; entry_ref ref;
status_t err; if (IsLaunching()) {
// peel off the first ref and open it ourselves
refNum = 0; if (message->FindRef("refs",i++,&ref) == B_OK) {
do { BMessage file(OPEN_TERMINAL);
err = message->FindRef("refs", refNum, &ref); file.AddRef("refs",&ref);
if (err != B_OK) OpenTerminal(&file);
return; }
BMessage single(OPEN_TERMINAL); }
single.AddRef("refs",&ref); // handle any other refs by launching them as separate apps
OpenTerminal(&single); while (message->FindRef("refs",i++,&ref) == B_OK) {
refNum++; BMessage * file = new BMessage(OPEN_TERMINAL);
printf("refNum = %ld\n",refNum); file->AddRef("refs",&ref);
} while (true); be_roster->Launch(APP_SIGNATURE,file);
}
} }
void void
@ -250,6 +234,7 @@ TerminalApp::ArgvReceived(int32 argc, char * const argv[], const char * cwd)
} }
break; break;
case '?': case '?':
printf("wth is that?\n");
return; return;
break; break;
default: default:

View File

@ -92,11 +92,9 @@ TerminalWindow::InitWindow(int32 id, entry_ref * settingsRef)
fSwitchTerminals = new BMenuItem("Switch Terminals", new BMessage(TERMINAL_SWITCH_TERMINAL), 'G'); fSwitchTerminals = new BMenuItem("Switch Terminals", new BMessage(TERMINAL_SWITCH_TERMINAL), 'G');
fTerminal->AddItem(fSwitchTerminals); fTerminal->AddItem(fSwitchTerminals);
fSwitchTerminals->SetTrigger('T'); fSwitchTerminals->SetTrigger('T');
fSwitchTerminals->SetTarget(be_app);
fStartNewTerminal = new BMenuItem("Start New Terminal", new BMessage(TERMINAL_START_NEW_TERMINAL), 'N'); fStartNewTerminal = new BMenuItem("Start New Terminal", new BMessage(TERMINAL_START_NEW_TERMINAL), 'N');
fTerminal->AddItem(fStartNewTerminal); fTerminal->AddItem(fStartNewTerminal);
fStartNewTerminal->SetTarget(be_app);
fLogToFile = new BMenuItem("Log to File...", new BMessage(TERMINAL_LOG_TO_FILE)); fLogToFile = new BMenuItem("Log to File...", new BMessage(TERMINAL_LOG_TO_FILE));
fTerminal->AddItem(fLogToFile); fTerminal->AddItem(fLogToFile);
@ -239,7 +237,14 @@ TerminalWindow::RestoreSettings(entry_ref * settingsRef)
void void
TerminalWindow::MessageReceived(BMessage *message) 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: case B_COPY:
fTextView->Copy(be_clipboard); fTextView->Copy(be_clipboard);
break; break;