10fe1abb5Smahlzeit /* 20fe1abb5Smahlzeit * Copyright (c) 2004 Matthijs Hollemans 30fe1abb5Smahlzeit * 40fe1abb5Smahlzeit * Permission is hereby granted, free of charge, to any person obtaining a 50fe1abb5Smahlzeit * copy of this software and associated documentation files (the "Software"), 60fe1abb5Smahlzeit * to deal in the Software without restriction, including without limitation 70fe1abb5Smahlzeit * the rights to use, copy, modify, merge, publish, distribute, sublicense, 80fe1abb5Smahlzeit * and/or sell copies of the Software, and to permit persons to whom the 90fe1abb5Smahlzeit * Software is furnished to do so, subject to the following conditions: 100fe1abb5Smahlzeit * 110fe1abb5Smahlzeit * The above copyright notice and this permission notice shall be included in 120fe1abb5Smahlzeit * all copies or substantial portions of the Software. 130fe1abb5Smahlzeit * 140fe1abb5Smahlzeit * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 150fe1abb5Smahlzeit * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 160fe1abb5Smahlzeit * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 170fe1abb5Smahlzeit * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 180fe1abb5Smahlzeit * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 190fe1abb5Smahlzeit * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 200fe1abb5Smahlzeit * DEALINGS IN THE SOFTWARE. 210fe1abb5Smahlzeit */ 220fe1abb5Smahlzeit 230fe1abb5Smahlzeit #include <Alert.h> 242f1ed332SAdrien Destugues #include <Catalog.h> 252f1ed332SAdrien Destugues #include <Locale.h> 260fe1abb5Smahlzeit #include <StorageKit.h> 270fe1abb5Smahlzeit 280fe1abb5Smahlzeit #include "MidiPlayerApp.h" 290fe1abb5Smahlzeit #include "MidiPlayerWindow.h" 300fe1abb5Smahlzeit 31*546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT 32*546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "Main Application" 330fe1abb5Smahlzeit 340fe1abb5Smahlzeit MidiPlayerApp::MidiPlayerApp() 350fe1abb5Smahlzeit : BApplication(MIDI_PLAYER_SIGNATURE) 360fe1abb5Smahlzeit { 370fe1abb5Smahlzeit window = new MidiPlayerWindow; 380fe1abb5Smahlzeit } 390fe1abb5Smahlzeit 400fe1abb5Smahlzeit 411f8b22efSAxel Dörfler void 421f8b22efSAxel Dörfler MidiPlayerApp::ReadyToRun() 430fe1abb5Smahlzeit { 440fe1abb5Smahlzeit window->Show(); 450fe1abb5Smahlzeit } 460fe1abb5Smahlzeit 470fe1abb5Smahlzeit 481f8b22efSAxel Dörfler void 491f8b22efSAxel Dörfler MidiPlayerApp::AboutRequested() 500fe1abb5Smahlzeit { 510fe1abb5Smahlzeit (new BAlert( 52612dd004Smahlzeit NULL, 53b25cb34aSMatt Madia B_TRANSLATE_COMMENT("Haiku MIDI Player 1.0.0 beta\n\n" 54612dd004Smahlzeit "This tiny program\n" 55612dd004Smahlzeit "Knows how to play thousands of\n" 562f1ed332SAdrien Destugues "Cheesy sounding songs", "This is a haiku. First line has five syllables, second has seven and last has five again. Create your own."), 57612dd004Smahlzeit "Okay", NULL, NULL, 580fe1abb5Smahlzeit B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go(); 590fe1abb5Smahlzeit } 600fe1abb5Smahlzeit 610fe1abb5Smahlzeit 621f8b22efSAxel Dörfler void 631f8b22efSAxel Dörfler MidiPlayerApp::RefsReceived(BMessage* msg) 640fe1abb5Smahlzeit { 650fe1abb5Smahlzeit msg->what = B_SIMPLE_DATA; 660fe1abb5Smahlzeit window->PostMessage(msg); 670fe1abb5Smahlzeit } 680fe1abb5Smahlzeit 690fe1abb5Smahlzeit 701f8b22efSAxel Dörfler void 711f8b22efSAxel Dörfler MidiPlayerApp::ArgvReceived(int32 argc, char** argv) 720fe1abb5Smahlzeit { 730fe1abb5Smahlzeit // Note: we only load the first file, even if more than one is specified. 740fe1abb5Smahlzeit // For some reason, BeOS R5 MidiPlayer loads them all but will only play 750fe1abb5Smahlzeit // the last one. That's not very useful. 760fe1abb5Smahlzeit 771f8b22efSAxel Dörfler if (argc > 1) { 780fe1abb5Smahlzeit BMessage msg; 790fe1abb5Smahlzeit msg.what = B_SIMPLE_DATA; 800fe1abb5Smahlzeit 810fe1abb5Smahlzeit BEntry entry(argv[1]); 820fe1abb5Smahlzeit entry_ref ref; 830fe1abb5Smahlzeit entry.GetRef(&ref); 840fe1abb5Smahlzeit msg.AddRef("refs", &ref); 850fe1abb5Smahlzeit 860fe1abb5Smahlzeit window->PostMessage(&msg); 870fe1abb5Smahlzeit } 880fe1abb5Smahlzeit } 890fe1abb5Smahlzeit 900fe1abb5Smahlzeit 911f8b22efSAxel Dörfler // #pragma mark - 921f8b22efSAxel Dörfler 931f8b22efSAxel Dörfler 941f8b22efSAxel Dörfler int 951f8b22efSAxel Dörfler main() 960fe1abb5Smahlzeit { 970fe1abb5Smahlzeit MidiPlayerApp app; 980fe1abb5Smahlzeit app.Run(); 990fe1abb5Smahlzeit return 0; 1000fe1abb5Smahlzeit } 1010fe1abb5Smahlzeit 102