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