xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision bc3955fea5b07e2e94a27fc05e4bb58fe6f0319b)
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 <StorageKit.h>
25 
26 #include "MidiPlayerApp.h"
27 #include "MidiPlayerWindow.h"
28 
29 
30 MidiPlayerApp::MidiPlayerApp()
31 	: BApplication(MIDI_PLAYER_SIGNATURE)
32 {
33 	window = new MidiPlayerWindow;
34 }
35 
36 
37 void
38 MidiPlayerApp::ReadyToRun()
39 {
40 	window->Show();
41 }
42 
43 
44 void
45 MidiPlayerApp::AboutRequested()
46 {
47 	(new BAlert(
48 		NULL,
49 		"Haiku MIDI Player 1.0.0 beta\n\n"
50 		"This tiny program\n"
51 		"Knows how to play thousands of\n"
52 		"Cheesy sounding songs",
53 		"Okay", NULL, NULL,
54 		B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go();
55 }
56 
57 
58 void
59 MidiPlayerApp::RefsReceived(BMessage* msg)
60 {
61 	msg->what = B_SIMPLE_DATA;
62 	window->PostMessage(msg);
63 }
64 
65 
66 void
67 MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
68 {
69 	// Note: we only load the first file, even if more than one is specified.
70 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
71 	// the last one. That's not very useful.
72 
73 	if (argc > 1) {
74 		BMessage msg;
75 		msg.what = B_SIMPLE_DATA;
76 
77 		BEntry entry(argv[1]);
78 		entry_ref ref;
79 		entry.GetRef(&ref);
80 		msg.AddRef("refs", &ref);
81 
82 		window->PostMessage(&msg);
83 	}
84 }
85 
86 
87 //	#pragma mark -
88 
89 
90 int
91 main()
92 {
93 	MidiPlayerApp app;
94 	app.Run();
95 	return 0;
96 }
97 
98