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