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 <Path.h>
#include <Point.h>
#include <Alert.h>
#include <Constants.h>
#include <TerminalApp.h>
@ -52,31 +53,10 @@ void TerminalApp::DispatchMessage(BMessage *msg, BHandler *handler)
}
}
#include <Alert.h>
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 <Roster.h>
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:

View File

@ -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;