1d1360823SMatthew Wilber /*****************************************************************************/
2d1360823SMatthew Wilber // ActiveTranslatorsWindow
3*2ca13760SColdfirex // Written by Michael Wilber, Haiku Translation Kit Team
4d1360823SMatthew Wilber //
5d1360823SMatthew Wilber // ActiveTranslatorsWindow.cpp
6d1360823SMatthew Wilber //
7d1360823SMatthew Wilber // BWindow class for displaying information about the currently open
8d1360823SMatthew Wilber // document
9d1360823SMatthew Wilber //
10d1360823SMatthew Wilber //
11*2ca13760SColdfirex // Copyright (c) 2003 Haiku Project
12d1360823SMatthew Wilber //
13d1360823SMatthew Wilber // Permission is hereby granted, free of charge, to any person obtaining a
14d1360823SMatthew Wilber // copy of this software and associated documentation files (the "Software"),
15d1360823SMatthew Wilber // to deal in the Software without restriction, including without limitation
16d1360823SMatthew Wilber // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17d1360823SMatthew Wilber // and/or sell copies of the Software, and to permit persons to whom the
18d1360823SMatthew Wilber // Software is furnished to do so, subject to the following conditions:
19d1360823SMatthew Wilber //
20d1360823SMatthew Wilber // The above copyright notice and this permission notice shall be included
21d1360823SMatthew Wilber // in all copies or substantial portions of the Software.
22d1360823SMatthew Wilber //
23d1360823SMatthew Wilber // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24d1360823SMatthew Wilber // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25d1360823SMatthew Wilber // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26d1360823SMatthew Wilber // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27d1360823SMatthew Wilber // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28d1360823SMatthew Wilber // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29d1360823SMatthew Wilber // DEALINGS IN THE SOFTWARE.
30d1360823SMatthew Wilber /*****************************************************************************/
31d1360823SMatthew Wilber
32d1360823SMatthew Wilber #include "Constants.h"
33d1360823SMatthew Wilber #include "ActiveTranslatorsWindow.h"
34e5ef5305SMatthew Wilber #include "TranslatorItem.h"
35d1360823SMatthew Wilber #include <Application.h>
366e608fa5SAdrien Destugues #include <Catalog.h>
37d1360823SMatthew Wilber #include <ScrollView.h>
386e608fa5SAdrien Destugues #include <Locale.h>
39d1360823SMatthew Wilber #include <Message.h>
40d1360823SMatthew Wilber #include <String.h>
41d1360823SMatthew Wilber #include <stdlib.h>
42d1360823SMatthew Wilber #include <string.h>
43d1360823SMatthew Wilber #include <dirent.h>
44d1360823SMatthew Wilber #include <unistd.h>
45d1360823SMatthew Wilber #include <sys/stat.h>
46d1360823SMatthew Wilber
47546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
48546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "ActiveTranslatorsWindow"
496e608fa5SAdrien Destugues
506e608fa5SAdrien Destugues
ActiveTranslatorsWindow(BRect rect,const char * name,BList * plist)51e5ef5305SMatthew Wilber ActiveTranslatorsWindow::ActiveTranslatorsWindow(BRect rect, const char *name,
52e5ef5305SMatthew Wilber BList *plist)
535e821a67SNiels Sascha Reedijk : BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
54d1360823SMatthew Wilber {
55d1360823SMatthew Wilber BRect rctframe = Bounds();
56d1360823SMatthew Wilber rctframe.right -= B_V_SCROLL_BAR_WIDTH;
57d1360823SMatthew Wilber
58e5ef5305SMatthew Wilber fpListView = new BOutlineListView(rctframe, "translators_list",
59d1360823SMatthew Wilber B_MULTIPLE_SELECTION_LIST);
60d1360823SMatthew Wilber
616e608fa5SAdrien Destugues fpListView->AddItem(fpUserItem = new BStringItem(B_TRANSLATE("User Translators")));
62e5ef5305SMatthew Wilber fpUserItem->SetEnabled(false);
636e608fa5SAdrien Destugues fpListView->AddItem(fpSystemItem = new BStringItem(B_TRANSLATE("System Translators")));
64e5ef5305SMatthew Wilber fpSystemItem->SetEnabled(false);
65e5ef5305SMatthew Wilber AddTranslatorsToList(plist, USER_TRANSLATOR, fpUserItem);
66e5ef5305SMatthew Wilber AddTranslatorsToList(plist, SYSTEM_TRANSLATOR, fpSystemItem);
67d1360823SMatthew Wilber
68e5ef5305SMatthew Wilber AddChild(new BScrollView("scroll_list", fpListView, B_FOLLOW_LEFT | B_FOLLOW_TOP,
69d1360823SMatthew Wilber 0, false, true));
70d1360823SMatthew Wilber
71d1360823SMatthew Wilber SetSizeLimits(100, 10000, 100, 10000);
72d1360823SMatthew Wilber
73d1360823SMatthew Wilber Show();
74d1360823SMatthew Wilber }
75d1360823SMatthew Wilber
76d1360823SMatthew Wilber void
AddTranslatorsToList(BList * plist,int32 group,BStringItem * pparent)77e5ef5305SMatthew Wilber ActiveTranslatorsWindow::AddTranslatorsToList(BList *plist, int32 group,
78d1360823SMatthew Wilber BStringItem *pparent)
79d1360823SMatthew Wilber {
80e5ef5305SMatthew Wilber BTranslatorItem *pitem;
81e5ef5305SMatthew Wilber for (int32 i = 0; i < plist->CountItems(); i++) {
82e5ef5305SMatthew Wilber pitem = static_cast<BTranslatorItem *>(plist->ItemAt(i));
83e5ef5305SMatthew Wilber if (pitem->Group() == group)
84e5ef5305SMatthew Wilber fpListView->AddUnder(pitem, pparent);
85d1360823SMatthew Wilber }
86d1360823SMatthew Wilber }
87d1360823SMatthew Wilber
~ActiveTranslatorsWindow()88d1360823SMatthew Wilber ActiveTranslatorsWindow::~ActiveTranslatorsWindow()
89d1360823SMatthew Wilber {
90d1360823SMatthew Wilber }
91d1360823SMatthew Wilber
92d1360823SMatthew Wilber void
FrameResized(float width,float height)93d1360823SMatthew Wilber ActiveTranslatorsWindow::FrameResized(float width, float height)
94d1360823SMatthew Wilber {
95d1360823SMatthew Wilber }
96d1360823SMatthew Wilber
97d1360823SMatthew Wilber void
MessageReceived(BMessage * pmsg)98d1360823SMatthew Wilber ActiveTranslatorsWindow::MessageReceived(BMessage *pmsg)
99d1360823SMatthew Wilber {
100d1360823SMatthew Wilber switch (pmsg->what) {
101d1360823SMatthew Wilber default:
102d1360823SMatthew Wilber BWindow::MessageReceived(pmsg);
103d1360823SMatthew Wilber break;
104d1360823SMatthew Wilber }
105d1360823SMatthew Wilber }
106d1360823SMatthew Wilber
107d1360823SMatthew Wilber void
Quit()108d1360823SMatthew Wilber ActiveTranslatorsWindow::Quit()
109d1360823SMatthew Wilber {
110d1360823SMatthew Wilber // tell the app to forget about this window
111d1360823SMatthew Wilber be_app->PostMessage(M_ACTIVE_TRANSLATORS_WINDOW_QUIT);
112d1360823SMatthew Wilber BWindow::Quit();
113d1360823SMatthew Wilber }
114