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 <AboutWindow.h> 10 #include <Alert.h> 11 #include <Catalog.h> 12 #include <Locale.h> 13 #include <TextView.h> 14 15 #include "ExpanderWindow.h" 16 17 18 ExpanderApp::ExpanderApp() 19 : 20 BApplication("application/x-vnd.Haiku-Expander") 21 { 22 BPoint windowPosition = fSettings.Message().FindPoint("window_position"); 23 BRect windowFrame(0, 0, 450, 120); 24 windowFrame.OffsetBy(windowPosition); 25 BMessage settings(fSettings.Message()); 26 fWindow = new ExpanderWindow(windowFrame, NULL, &settings); 27 } 28 29 30 #undef B_TRANSLATE_CONTEXT 31 #define B_TRANSLATE_CONTEXT "About" 32 33 void 34 ExpanderApp::AboutRequested() 35 { 36 const char* authors[] = { 37 "Jérôme Duval", 38 NULL 39 }; 40 BAboutWindow about(B_TRANSLATE_APP_NAME("Expander"), 2004, authors, 41 "Original Be version by Dominic, Hiroshi, Peter, Pavel and Robert."); 42 about.Show(); 43 } 44 45 46 void 47 ExpanderApp::ReadyToRun() 48 { 49 } 50 51 52 void 53 ExpanderApp::ArgvReceived(int32 argc, char **argv) 54 { 55 BMessage* msg = NULL; 56 for (int32 i = 1; i < argc; i++) { 57 entry_ref ref; 58 status_t err = get_ref_for_path(argv[i], &ref); 59 if (err == B_OK) { 60 if (!msg) { 61 msg = new BMessage; 62 msg->what = B_REFS_RECEIVED; 63 } 64 msg->AddRef("refs", &ref); 65 } 66 } 67 if (msg) 68 RefsReceived(msg); 69 } 70 71 72 void 73 ExpanderApp::RefsReceived(BMessage* msg) 74 { 75 BMessenger messenger(fWindow); 76 msg->AddBool("fromApp", true); 77 messenger.SendMessage(msg); 78 } 79 80 81 void 82 ExpanderApp::UpdateSettingsFrom(BMessage* message) 83 { 84 fSettings.UpdateFrom(message); 85 } 86 87 88 // #pragma mark - 89 90 91 int 92 main(int, char **) 93 { 94 ExpanderApp theApp; 95 theApp.Run(); 96 return 0; 97 } 98