2 * Copyright (c) 1998-2007 Matthijs Hollemans
3 * All rights reserved. Distributed under the terms of the MIT License.
12 #include "GlobalDefs.h"
13 #include "GrepWindow.h"
18 : BApplication(APP_SIGNATURE
),
19 fGotArgvOnStartup(false),
20 fGotRefsOnStartup(false),
33 GrepApp::ArgvReceived(int32 argc
, char** argv
)
35 fGotArgvOnStartup
= true;
37 BMessage
message(B_REFS_RECEIVED
);
40 for (int32 i
= 1; i
< argc
; i
++) {
41 BEntry
entry(argv
[i
]);
46 message
.AddRef("refs", &ref
);
49 printf("%s: File not found: %s\n", argv
[0], argv
[i
]);
53 RefsReceived(&message
);
58 GrepApp::RefsReceived(BMessage
* message
)
61 fGotRefsOnStartup
= true;
63 new GrepWindow(message
);
70 if (!fGotArgvOnStartup
&& !fGotRefsOnStartup
)
71 _NewUnfocusedGrepWindow();
73 // TODO: stippi: I don't understand what this is supposed to do:
74 if (fGotArgvOnStartup
&& !fGotRefsOnStartup
)
75 PostMessage(B_QUIT_REQUESTED
);
80 GrepApp::MessageReceived(BMessage
* message
)
82 switch (message
->what
) {
83 case B_SILENT_RELAUNCH
:
84 _NewUnfocusedGrepWindow();
92 BApplication::MessageReceived(message
);
101 if (CountWindows() == 0)
102 PostMessage(B_QUIT_REQUESTED
);
104 if (CountWindows() == 1 && fQuitter
== NULL
) {
105 fQuitter
= new BMessageRunner(be_app_messenger
,
106 new BMessage(MSG_TRY_QUIT
), 200000, -1);
112 GrepApp::_NewUnfocusedGrepWindow()
114 BMessage emptyMessage
;
115 new GrepWindow(&emptyMessage
);