1 /*
2 * Copyright 2004-2006, Jérôme Duval. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7 #include "ExpanderApp.h"
8
9 #include "ExpanderWindow.h"
10
11
ExpanderApp()12 ExpanderApp::ExpanderApp()
13 :
14 BApplication("application/x-vnd.Haiku-Expander")
15 {
16 BPoint windowPosition = fSettings.Message().FindPoint("window_position");
17 BRect windowFrame(0, 0, 450, 120);
18 windowFrame.OffsetBy(windowPosition);
19 BMessage settings(fSettings.Message());
20 fWindow = new ExpanderWindow(windowFrame, NULL, &settings);
21 }
22
23
24 void
ArgvReceived(int32 argc,char ** argv)25 ExpanderApp::ArgvReceived(int32 argc, char** argv)
26 {
27 BMessage* message = NULL;
28 for (int32 i = 1; i < argc; i++) {
29 entry_ref ref;
30 status_t err = get_ref_for_path(argv[i], &ref);
31 if (err == B_OK) {
32 if (message == NULL) {
33 message = new BMessage;
34 message->what = B_REFS_RECEIVED;
35 }
36 message->AddRef("refs", &ref);
37 }
38 }
39
40 if (message != NULL)
41 RefsReceived(message);
42 }
43
44
45 void
RefsReceived(BMessage * message)46 ExpanderApp::RefsReceived(BMessage* message)
47 {
48 BMessenger messenger(fWindow);
49 message->AddBool("fromApp", true);
50 messenger.SendMessage(message);
51 }
52
53
54 void
UpdateSettingsFrom(BMessage * message)55 ExpanderApp::UpdateSettingsFrom(BMessage* message)
56 {
57 fSettings.UpdateFrom(message);
58 }
59
60
61 // #pragma mark - main method
62
63
64 int
main(int argc,char ** argv)65 main(int argc, char** argv)
66 {
67 ExpanderApp theApp;
68 theApp.Run();
69
70 return 0;
71 }
72