xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision 42bcaa84c0eb475d3f6c49a7a7f4cc8d72083f5b)
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 
23*42bcaa84SJohn Scipione 
24*42bcaa84SJohn Scipione #include "MidiPlayerApp.h"
25*42bcaa84SJohn Scipione 
26*42bcaa84SJohn Scipione #include <AboutWindow.h>
270fe1abb5Smahlzeit #include <Alert.h>
282f1ed332SAdrien Destugues #include <Catalog.h>
292f1ed332SAdrien Destugues #include <Locale.h>
300fe1abb5Smahlzeit #include <StorageKit.h>
310fe1abb5Smahlzeit 
320fe1abb5Smahlzeit #include "MidiPlayerWindow.h"
330fe1abb5Smahlzeit 
34*42bcaa84SJohn Scipione 
35546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
36546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "Main Application"
370fe1abb5Smahlzeit 
38*42bcaa84SJohn Scipione 
39*42bcaa84SJohn Scipione //	#pragma mark - MidiPlayerApp
40*42bcaa84SJohn Scipione 
41*42bcaa84SJohn Scipione 
420fe1abb5Smahlzeit MidiPlayerApp::MidiPlayerApp()
43*42bcaa84SJohn Scipione 	:
44*42bcaa84SJohn Scipione 	BApplication(MIDI_PLAYER_SIGNATURE)
450fe1abb5Smahlzeit {
46*42bcaa84SJohn Scipione 	window = new MidiPlayerWindow();
470fe1abb5Smahlzeit }
480fe1abb5Smahlzeit 
490fe1abb5Smahlzeit 
501f8b22efSAxel Dörfler void
511f8b22efSAxel Dörfler MidiPlayerApp::ReadyToRun()
520fe1abb5Smahlzeit {
530fe1abb5Smahlzeit 	window->Show();
540fe1abb5Smahlzeit }
550fe1abb5Smahlzeit 
560fe1abb5Smahlzeit 
571f8b22efSAxel Dörfler void
581f8b22efSAxel Dörfler MidiPlayerApp::AboutRequested()
590fe1abb5Smahlzeit {
60aed35104SHumdinger 	BAlert* alert = new BAlert(NULL,
61b25cb34aSMatt Madia 		B_TRANSLATE_COMMENT("Haiku MIDI Player 1.0.0 beta\n\n"
62612dd004Smahlzeit 		"This tiny program\n"
63612dd004Smahlzeit 		"Knows how to play thousands of\n"
64aed35104SHumdinger 		"Cheesy sounding songs", "This is a haiku. First line has five "
65aed35104SHumdinger 		"syllables, second has seven and last has five again. "
66aed35104SHumdinger 		"Create your own."), B_TRANSLATE("OK"), NULL, NULL,
67aed35104SHumdinger 		B_WIDTH_AS_USUAL, B_INFO_ALERT);
68aed35104SHumdinger 		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
69aed35104SHumdinger 		alert->Go();
700fe1abb5Smahlzeit }
710fe1abb5Smahlzeit 
720fe1abb5Smahlzeit 
731f8b22efSAxel Dörfler void
74*42bcaa84SJohn Scipione MidiPlayerApp::RefsReceived(BMessage* message)
750fe1abb5Smahlzeit {
76*42bcaa84SJohn Scipione 	message->what = B_SIMPLE_DATA;
77*42bcaa84SJohn Scipione 	window->PostMessage(message);
780fe1abb5Smahlzeit }
790fe1abb5Smahlzeit 
800fe1abb5Smahlzeit 
811f8b22efSAxel Dörfler void
821f8b22efSAxel Dörfler MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
830fe1abb5Smahlzeit {
840fe1abb5Smahlzeit 	// Note: we only load the first file, even if more than one is specified.
850fe1abb5Smahlzeit 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
860fe1abb5Smahlzeit 	// the last one. That's not very useful.
870fe1abb5Smahlzeit 
881f8b22efSAxel Dörfler 	if (argc > 1) {
890fe1abb5Smahlzeit 		BMessage msg;
900fe1abb5Smahlzeit 		msg.what = B_SIMPLE_DATA;
910fe1abb5Smahlzeit 
920fe1abb5Smahlzeit 		BEntry entry(argv[1]);
930fe1abb5Smahlzeit 		entry_ref ref;
940fe1abb5Smahlzeit 		entry.GetRef(&ref);
950fe1abb5Smahlzeit 		msg.AddRef("refs", &ref);
960fe1abb5Smahlzeit 
970fe1abb5Smahlzeit 		window->PostMessage(&msg);
980fe1abb5Smahlzeit 	}
990fe1abb5Smahlzeit }
1000fe1abb5Smahlzeit 
1010fe1abb5Smahlzeit 
102*42bcaa84SJohn Scipione //	#pragma mark - main method
1031f8b22efSAxel Dörfler 
1041f8b22efSAxel Dörfler 
1051f8b22efSAxel Dörfler int
1061f8b22efSAxel Dörfler main()
1070fe1abb5Smahlzeit {
1080fe1abb5Smahlzeit 	MidiPlayerApp app;
1090fe1abb5Smahlzeit 	app.Run();
1100fe1abb5Smahlzeit 	return 0;
1110fe1abb5Smahlzeit }
112