10fe1abb5Smahlzeit /* 20fe1abb5Smahlzeit * Copyright (c) 2004 Matthijs Hollemans 3*ef276942SJohn Scipione * Copyright (c) 2008-2014 Haiku, Inc. All rights reserved. 40fe1abb5Smahlzeit * 50fe1abb5Smahlzeit * Permission is hereby granted, free of charge, to any person obtaining a 60fe1abb5Smahlzeit * copy of this software and associated documentation files (the "Software"), 70fe1abb5Smahlzeit * to deal in the Software without restriction, including without limitation 80fe1abb5Smahlzeit * the rights to use, copy, modify, merge, publish, distribute, sublicense, 90fe1abb5Smahlzeit * and/or sell copies of the Software, and to permit persons to whom the 100fe1abb5Smahlzeit * Software is furnished to do so, subject to the following conditions: 110fe1abb5Smahlzeit * 120fe1abb5Smahlzeit * The above copyright notice and this permission notice shall be included in 130fe1abb5Smahlzeit * all copies or substantial portions of the Software. 140fe1abb5Smahlzeit * 150fe1abb5Smahlzeit * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 160fe1abb5Smahlzeit * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 170fe1abb5Smahlzeit * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 180fe1abb5Smahlzeit * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 190fe1abb5Smahlzeit * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 200fe1abb5Smahlzeit * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 210fe1abb5Smahlzeit * DEALINGS IN THE SOFTWARE. 220fe1abb5Smahlzeit */ 230fe1abb5Smahlzeit 2442bcaa84SJohn Scipione 2542bcaa84SJohn Scipione #include "MidiPlayerApp.h" 2642bcaa84SJohn Scipione 2742bcaa84SJohn Scipione #include <AboutWindow.h> 280fe1abb5Smahlzeit #include <Alert.h> 292f1ed332SAdrien Destugues #include <Catalog.h> 302f1ed332SAdrien Destugues #include <Locale.h> 310fe1abb5Smahlzeit #include <StorageKit.h> 320fe1abb5Smahlzeit 330fe1abb5Smahlzeit #include "MidiPlayerWindow.h" 340fe1abb5Smahlzeit 3542bcaa84SJohn Scipione 36546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT 37546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "Main Application" 380fe1abb5Smahlzeit 3942bcaa84SJohn Scipione 4042bcaa84SJohn Scipione // #pragma mark - MidiPlayerApp 4142bcaa84SJohn Scipione 4242bcaa84SJohn Scipione 430fe1abb5Smahlzeit MidiPlayerApp::MidiPlayerApp() 4442bcaa84SJohn Scipione : 4542bcaa84SJohn Scipione BApplication(MIDI_PLAYER_SIGNATURE) 460fe1abb5Smahlzeit { 4742bcaa84SJohn Scipione window = new MidiPlayerWindow(); 480fe1abb5Smahlzeit } 490fe1abb5Smahlzeit 500fe1abb5Smahlzeit 511f8b22efSAxel Dörfler void 521f8b22efSAxel Dörfler MidiPlayerApp::ReadyToRun() 530fe1abb5Smahlzeit { 540fe1abb5Smahlzeit window->Show(); 550fe1abb5Smahlzeit } 560fe1abb5Smahlzeit 570fe1abb5Smahlzeit 581f8b22efSAxel Dörfler void 591f8b22efSAxel Dörfler MidiPlayerApp::AboutRequested() 600fe1abb5Smahlzeit { 61aed35104SHumdinger BAlert* alert = new BAlert(NULL, 62b25cb34aSMatt Madia B_TRANSLATE_COMMENT("Haiku MIDI Player 1.0.0 beta\n\n" 63612dd004Smahlzeit "This tiny program\n" 64612dd004Smahlzeit "Knows how to play thousands of\n" 65aed35104SHumdinger "Cheesy sounding songs", "This is a haiku. First line has five " 66aed35104SHumdinger "syllables, second has seven and last has five again. " 67aed35104SHumdinger "Create your own."), B_TRANSLATE("OK"), NULL, NULL, 68aed35104SHumdinger B_WIDTH_AS_USUAL, B_INFO_ALERT); 69aed35104SHumdinger alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); 70aed35104SHumdinger alert->Go(); 710fe1abb5Smahlzeit } 720fe1abb5Smahlzeit 730fe1abb5Smahlzeit 741f8b22efSAxel Dörfler void 7542bcaa84SJohn Scipione MidiPlayerApp::RefsReceived(BMessage* message) 760fe1abb5Smahlzeit { 7742bcaa84SJohn Scipione message->what = B_SIMPLE_DATA; 7842bcaa84SJohn Scipione window->PostMessage(message); 790fe1abb5Smahlzeit } 800fe1abb5Smahlzeit 810fe1abb5Smahlzeit 821f8b22efSAxel Dörfler void 831f8b22efSAxel Dörfler MidiPlayerApp::ArgvReceived(int32 argc, char** argv) 840fe1abb5Smahlzeit { 850fe1abb5Smahlzeit // Note: we only load the first file, even if more than one is specified. 860fe1abb5Smahlzeit // For some reason, BeOS R5 MidiPlayer loads them all but will only play 870fe1abb5Smahlzeit // the last one. That's not very useful. 880fe1abb5Smahlzeit 891f8b22efSAxel Dörfler if (argc > 1) { 900fe1abb5Smahlzeit BMessage msg; 910fe1abb5Smahlzeit msg.what = B_SIMPLE_DATA; 920fe1abb5Smahlzeit 930fe1abb5Smahlzeit BEntry entry(argv[1]); 940fe1abb5Smahlzeit entry_ref ref; 950fe1abb5Smahlzeit entry.GetRef(&ref); 960fe1abb5Smahlzeit msg.AddRef("refs", &ref); 970fe1abb5Smahlzeit 980fe1abb5Smahlzeit window->PostMessage(&msg); 990fe1abb5Smahlzeit } 1000fe1abb5Smahlzeit } 1010fe1abb5Smahlzeit 1020fe1abb5Smahlzeit 10342bcaa84SJohn Scipione // #pragma mark - main method 1041f8b22efSAxel Dörfler 1051f8b22efSAxel Dörfler 1061f8b22efSAxel Dörfler int 1071f8b22efSAxel Dörfler main() 1080fe1abb5Smahlzeit { 1090fe1abb5Smahlzeit MidiPlayerApp app; 1100fe1abb5Smahlzeit app.Run(); 1110fe1abb5Smahlzeit return 0; 1120fe1abb5Smahlzeit } 113