xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision 8edf74fa651350ce248d7eb9974ab6a1a0e6037d)
1 /*
2  * Copyright (c) 2004 Matthijs Hollemans
3  * Copyright (c) 2008-2014 Haiku, Inc. All rights reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 
25 #include "MidiPlayerApp.h"
26 
27 #include <AboutWindow.h>
28 #include <Alert.h>
29 #include <Catalog.h>
30 #include <Locale.h>
31 #include <StorageKit.h>
32 
33 #include "MidiPlayerWindow.h"
34 
35 
36 #undef B_TRANSLATION_CONTEXT
37 #define B_TRANSLATION_CONTEXT "Main Application"
38 
39 
40 //	#pragma mark - MidiPlayerApp
41 
42 
MidiPlayerApp()43 MidiPlayerApp::MidiPlayerApp()
44 	:
45 	BApplication(MIDI_PLAYER_SIGNATURE)
46 {
47 	window = new MidiPlayerWindow();
48 }
49 
50 
51 void
ReadyToRun()52 MidiPlayerApp::ReadyToRun()
53 {
54 	window->Show();
55 }
56 
57 
58 void
AboutRequested()59 MidiPlayerApp::AboutRequested()
60 {
61 	BAboutWindow* window = new BAboutWindow("MidiPlayer",
62 		MIDI_PLAYER_SIGNATURE);
63 
64 	const char* extraCopyrights[] = {
65 		"2008-2014 Haiku, Inc.",
66 		NULL
67 	};
68 	window->AddCopyright(2004, "Matthijs Hollemans", extraCopyrights);
69 
70 	const char* authors[] = {
71 		"Adrien Destugues",
72 		"Axel Dörfler",
73 		"Matthijs Hollemans",
74 		"Humdinger",
75 		"Ryan Leavengood",
76 		"Matt Madia",
77 		"John Scipione",
78 		"Jonas Sundström",
79 		"Oliver Tappe",
80 		NULL
81 	};
82 	window->AddAuthors(authors);
83 
84 	window->AddDescription(B_TRANSLATE_COMMENT(
85 		"This tiny program\n"
86 		"Knows how to play thousands of\n"
87 		"Cheesy sounding songs",
88 		"This is a haiku. First line has five syllables, "
89 		"second has seven and last has five again. "
90 		"Create your own."));
91 
92 	window->Show();
93 }
94 
95 
96 void
RefsReceived(BMessage * message)97 MidiPlayerApp::RefsReceived(BMessage* message)
98 {
99 	message->what = B_SIMPLE_DATA;
100 	window->PostMessage(message);
101 }
102 
103 
104 void
ArgvReceived(int32 argc,char ** argv)105 MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
106 {
107 	// Note: we only load the first file, even if more than one is specified.
108 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
109 	// the last one. That's not very useful.
110 
111 	if (argc > 1) {
112 		BMessage msg;
113 		msg.what = B_SIMPLE_DATA;
114 
115 		BEntry entry(argv[1]);
116 		entry_ref ref;
117 		entry.GetRef(&ref);
118 		msg.AddRef("refs", &ref);
119 
120 		window->PostMessage(&msg);
121 	}
122 }
123 
124 
125 //	#pragma mark - main method
126 
127 
128 int
main()129 main()
130 {
131 	MidiPlayerApp app;
132 	app.Run();
133 	return 0;
134 }
135