xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision 8edf74fa651350ce248d7eb9974ab6a1a0e6037d)
10fe1abb5Smahlzeit /*
20fe1abb5Smahlzeit  * Copyright (c) 2004 Matthijs Hollemans
3ef276942SJohn 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 
MidiPlayerApp()430fe1abb5Smahlzeit MidiPlayerApp::MidiPlayerApp()
4442bcaa84SJohn Scipione 	:
4542bcaa84SJohn Scipione 	BApplication(MIDI_PLAYER_SIGNATURE)
460fe1abb5Smahlzeit {
4742bcaa84SJohn Scipione 	window = new MidiPlayerWindow();
480fe1abb5Smahlzeit }
490fe1abb5Smahlzeit 
500fe1abb5Smahlzeit 
511f8b22efSAxel Dörfler void
ReadyToRun()521f8b22efSAxel Dörfler MidiPlayerApp::ReadyToRun()
530fe1abb5Smahlzeit {
540fe1abb5Smahlzeit 	window->Show();
550fe1abb5Smahlzeit }
560fe1abb5Smahlzeit 
570fe1abb5Smahlzeit 
581f8b22efSAxel Dörfler void
AboutRequested()591f8b22efSAxel Dörfler MidiPlayerApp::AboutRequested()
600fe1abb5Smahlzeit {
61*8edf74faSJohn Scipione 	BAboutWindow* window = new BAboutWindow("MidiPlayer",
62*8edf74faSJohn Scipione 		MIDI_PLAYER_SIGNATURE);
63*8edf74faSJohn Scipione 
64*8edf74faSJohn Scipione 	const char* extraCopyrights[] = {
65*8edf74faSJohn Scipione 		"2008-2014 Haiku, Inc.",
66*8edf74faSJohn Scipione 		NULL
67*8edf74faSJohn Scipione 	};
68*8edf74faSJohn Scipione 	window->AddCopyright(2004, "Matthijs Hollemans", extraCopyrights);
69*8edf74faSJohn Scipione 
70*8edf74faSJohn Scipione 	const char* authors[] = {
71*8edf74faSJohn Scipione 		"Adrien Destugues",
72*8edf74faSJohn Scipione 		"Axel Dörfler",
73*8edf74faSJohn Scipione 		"Matthijs Hollemans",
74*8edf74faSJohn Scipione 		"Humdinger",
75*8edf74faSJohn Scipione 		"Ryan Leavengood",
76*8edf74faSJohn Scipione 		"Matt Madia",
77*8edf74faSJohn Scipione 		"John Scipione",
78*8edf74faSJohn Scipione 		"Jonas Sundström",
79*8edf74faSJohn Scipione 		"Oliver Tappe",
80*8edf74faSJohn Scipione 		NULL
81*8edf74faSJohn Scipione 	};
82*8edf74faSJohn Scipione 	window->AddAuthors(authors);
83*8edf74faSJohn Scipione 
84*8edf74faSJohn Scipione 	window->AddDescription(B_TRANSLATE_COMMENT(
85612dd004Smahlzeit 		"This tiny program\n"
86612dd004Smahlzeit 		"Knows how to play thousands of\n"
87*8edf74faSJohn Scipione 		"Cheesy sounding songs",
88*8edf74faSJohn Scipione 		"This is a haiku. First line has five syllables, "
89*8edf74faSJohn Scipione 		"second has seven and last has five again. "
90*8edf74faSJohn Scipione 		"Create your own."));
91*8edf74faSJohn Scipione 
92*8edf74faSJohn Scipione 	window->Show();
930fe1abb5Smahlzeit }
940fe1abb5Smahlzeit 
950fe1abb5Smahlzeit 
961f8b22efSAxel Dörfler void
RefsReceived(BMessage * message)9742bcaa84SJohn Scipione MidiPlayerApp::RefsReceived(BMessage* message)
980fe1abb5Smahlzeit {
9942bcaa84SJohn Scipione 	message->what = B_SIMPLE_DATA;
10042bcaa84SJohn Scipione 	window->PostMessage(message);
1010fe1abb5Smahlzeit }
1020fe1abb5Smahlzeit 
1030fe1abb5Smahlzeit 
1041f8b22efSAxel Dörfler void
ArgvReceived(int32 argc,char ** argv)1051f8b22efSAxel Dörfler MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
1060fe1abb5Smahlzeit {
1070fe1abb5Smahlzeit 	// Note: we only load the first file, even if more than one is specified.
1080fe1abb5Smahlzeit 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
1090fe1abb5Smahlzeit 	// the last one. That's not very useful.
1100fe1abb5Smahlzeit 
1111f8b22efSAxel Dörfler 	if (argc > 1) {
1120fe1abb5Smahlzeit 		BMessage msg;
1130fe1abb5Smahlzeit 		msg.what = B_SIMPLE_DATA;
1140fe1abb5Smahlzeit 
1150fe1abb5Smahlzeit 		BEntry entry(argv[1]);
1160fe1abb5Smahlzeit 		entry_ref ref;
1170fe1abb5Smahlzeit 		entry.GetRef(&ref);
1180fe1abb5Smahlzeit 		msg.AddRef("refs", &ref);
1190fe1abb5Smahlzeit 
1200fe1abb5Smahlzeit 		window->PostMessage(&msg);
1210fe1abb5Smahlzeit 	}
1220fe1abb5Smahlzeit }
1230fe1abb5Smahlzeit 
1240fe1abb5Smahlzeit 
12542bcaa84SJohn Scipione //	#pragma mark - main method
1261f8b22efSAxel Dörfler 
1271f8b22efSAxel Dörfler 
1281f8b22efSAxel Dörfler int
main()1291f8b22efSAxel Dörfler main()
1300fe1abb5Smahlzeit {
1310fe1abb5Smahlzeit 	MidiPlayerApp app;
1320fe1abb5Smahlzeit 	app.Run();
1330fe1abb5Smahlzeit 	return 0;
1340fe1abb5Smahlzeit }
135