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 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 25 ExpanderApp::ArgvReceived(int32 argc, char **argv) 26 { 27 BMessage* msg = 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 (!msg) { 33 msg = new BMessage; 34 msg->what = B_REFS_RECEIVED; 35 } 36 msg->AddRef("refs", &ref); 37 } 38 } 39 if (msg) 40 RefsReceived(msg); 41 } 42 43 44 void 45 ExpanderApp::RefsReceived(BMessage* msg) 46 { 47 BMessenger messenger(fWindow); 48 msg->AddBool("fromApp", true); 49 messenger.SendMessage(msg); 50 } 51 52 53 void 54 ExpanderApp::UpdateSettingsFrom(BMessage* message) 55 { 56 fSettings.UpdateFrom(message); 57 } 58 59 60 // #pragma mark - 61 62 63 int 64 main(int, char **) 65 { 66 ExpanderApp theApp; 67 theApp.Run(); 68 return 0; 69 } 70