1 /* 2 * Copyright (c) 2004 Matthijs Hollemans 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 */ 22 23 #include <Alert.h> 24 #include <Catalog.h> 25 #include <Locale.h> 26 #include <StorageKit.h> 27 28 #include "MidiPlayerApp.h" 29 #include "MidiPlayerWindow.h" 30 31 #undef B_TRANSLATE_CONTEXT 32 #define B_TRANSLATE_CONTEXT "Main Application" 33 34 MidiPlayerApp::MidiPlayerApp() 35 : BApplication(MIDI_PLAYER_SIGNATURE) 36 { 37 window = new MidiPlayerWindow; 38 } 39 40 41 void 42 MidiPlayerApp::ReadyToRun() 43 { 44 window->Show(); 45 } 46 47 48 void 49 MidiPlayerApp::AboutRequested() 50 { 51 (new BAlert( 52 NULL, 53 B_TRANSLATE_COMMENT("Haiku MIDI Player 1.0.0 beta\n\n" 54 "This tiny program\n" 55 "Knows how to play thousands of\n" 56 "Cheesy sounding songs", "This is a haiku. First line has five syllables, second has seven and last has five again. Create your own."), 57 "Okay", NULL, NULL, 58 B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go(); 59 } 60 61 62 void 63 MidiPlayerApp::RefsReceived(BMessage* msg) 64 { 65 msg->what = B_SIMPLE_DATA; 66 window->PostMessage(msg); 67 } 68 69 70 void 71 MidiPlayerApp::ArgvReceived(int32 argc, char** argv) 72 { 73 // Note: we only load the first file, even if more than one is specified. 74 // For some reason, BeOS R5 MidiPlayer loads them all but will only play 75 // the last one. That's not very useful. 76 77 if (argc > 1) { 78 BMessage msg; 79 msg.what = B_SIMPLE_DATA; 80 81 BEntry entry(argv[1]); 82 entry_ref ref; 83 entry.GetRef(&ref); 84 msg.AddRef("refs", &ref); 85 86 window->PostMessage(&msg); 87 } 88 } 89 90 91 // #pragma mark - 92 93 94 int 95 main() 96 { 97 MidiPlayerApp app; 98 app.Run(); 99 return 0; 100 } 101 102