xref: /haiku/src/apps/expander/ExpanderApp.cpp (revision 62f5ba006a08b0df30631375878effaf67ae5dbc)
1 /*
2  * Copyright 2004-2006, Jérôme DUVAL. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "ExpanderApp.h"
8 #include "ExpanderWindow.h"
9 
10 #include <Alert.h>
11 #include <Catalog.h>
12 #include <Locale.h>
13 #include <TextView.h>
14 
15 ExpanderApp::ExpanderApp()
16 	: BApplication("application/x-vnd.Haiku-Expander")
17 {
18 	be_locale->GetAppCatalog(&fCatalog);
19 
20 	BPoint windowPosition = fSettings.Message().FindPoint("window_position");
21 	BRect windowFrame(0, 0, 450, 120);
22 	windowFrame.OffsetBy(windowPosition);
23 	BMessage settings(fSettings.Message());
24 	fWindow = new ExpanderWindow(windowFrame, NULL, &settings);
25 }
26 
27 
28 #undef TR_CONTEXT
29 #define TR_CONTEXT "About"
30 
31 void
32 ExpanderApp::AboutRequested()
33 {
34 	BAlert* alert = new BAlert("about",
35 		TR("Expander\n\twritten by Jérôme Duval\n\tCopyright 2004-2006, Haiku Inc.\n\noriginal Be version by \nDominic, Hiroshi, Peter, Pavel and Robert\n"),
36 		TR("OK"));
37 	BTextView* view = alert->TextView();
38 	BFont font;
39 
40 	view->SetStylable(true);
41 
42 	view->GetFont(&font);
43 	font.SetSize(18);
44 	font.SetFace(B_BOLD_FACE);
45 	view->SetFontAndColor(0, 8, &font);
46 
47 	alert->Go();
48 }
49 
50 
51 void
52 ExpanderApp::ReadyToRun()
53 {
54 }
55 
56 
57 void
58 ExpanderApp::ArgvReceived(int32 argc, char **argv)
59 {
60 	BMessage* msg = NULL;
61 	for (int32 i = 1; i < argc; i++) {
62 		entry_ref ref;
63 		status_t err = get_ref_for_path(argv[i], &ref);
64 		if (err == B_OK) {
65 			if (!msg) {
66 				msg = new BMessage;
67 				msg->what = B_REFS_RECEIVED;
68 			}
69 			msg->AddRef("refs", &ref);
70 		}
71 	}
72 	if (msg)
73 		RefsReceived(msg);
74 }
75 
76 
77 void
78 ExpanderApp::RefsReceived(BMessage* msg)
79 {
80 	BMessenger messenger(fWindow);
81 	msg->AddBool("fromApp", true);
82 	messenger.SendMessage(msg);
83 }
84 
85 
86 void
87 ExpanderApp::UpdateSettingsFrom(BMessage* message)
88 {
89 	fSettings.UpdateFrom(message);
90 }
91 
92 
93 //	#pragma mark -
94 
95 
96 int
97 main(int, char **)
98 {
99 	ExpanderApp theApp;
100 	theApp.Run();
101 	return 0;
102 }
103