1 /*****************************************************************************/
3 // Written by Michael Wilber, OBOS Translation Kit Team
7 // BApplication object for the Inspector application. The purpose of
8 // Inspector is to provide the user with as much relevant information as
9 // possible about the currently open document.
12 // Copyright (c) 2003 OpenBeOS Project
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 /*****************************************************************************/
33 #include "Constants.h"
34 #include "InspectorApp.h"
35 #include "ImageWindow.h"
36 #include "TranslatorItem.h"
38 #include <Directory.h>
43 #undef B_TRANSLATION_CONTEXT
44 #define B_TRANSLATION_CONTEXT "InspectorApp"
47 InspectorApp::InspectorApp()
48 : BApplication(APP_SIG
)
53 AddToTranslatorsList("/system/add-ons/Translators",
56 "/boot/home/config/add-ons/Translators",
59 // Show application window
60 BRect
rect(100, 100, 500, 400);
61 ImageWindow
*pwin
= new ImageWindow(rect
, IMAGEWINDOW_TITLE
);
66 InspectorApp::AddToTranslatorsList(const char *folder
, int32 group
)
69 if (dir
.SetTo(folder
) == B_OK
) {
72 while (dir
.GetNextEntry(&ent
) == B_OK
) {
74 if (ent
.GetPath(&path
) == B_OK
)
75 flstTranslators
.AddItem(
76 new BTranslatorItem(path
.Leaf(), path
.Path(), group
));
82 InspectorApp::MessageReceived(BMessage
*pmsg
)
85 case M_ACTIVE_TRANSLATORS_WINDOW
:
87 fpActivesWin
= new ActiveTranslatorsWindow(
88 BRect(625, 350, 800, 600),
89 B_TRANSLATE("Active Translators"),
90 GetTranslatorsList());
92 case M_ACTIVE_TRANSLATORS_WINDOW_QUIT
:
98 fpInfoWin
= new InfoWindow(BRect(625, 50, 800, 300),
99 B_TRANSLATE_COMMENT("Info Win",
100 "This is a quite narrow info window and title 'Info Win' "
101 "is therefore shortened."), fbstrInfo
.String());
103 case M_INFO_WINDOW_QUIT
:
106 case M_INFO_WINDOW_TEXT
:
107 // If image view is telling me to
108 // update the info window...
109 pmsg
->FindString("text", &fbstrInfo
);
111 fpInfoWin
->PostMessage(pmsg
);
115 BApplication::MessageReceived(pmsg
);
121 InspectorApp::RefsReceived(BMessage
*pmsg
)
123 pmsg
->what
= M_OPEN_FILE_PANEL
;
124 BWindow
*pwin
= WindowAt(0);
126 pwin
->PostMessage(pmsg
);
130 InspectorApp::GetTranslatorsList()
132 return &flstTranslators
;
135 int main(int argc
, char **argv
)
137 InspectorApp
*papp
= new InspectorApp();