tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / locale / LocalePreflet.cpp
blobd4440270db848cc5d25ce898f2dda32959d7d0cc
1 /*
2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Copyright 2010, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>. All rightts reserved.
4 * Distributed under the terms of the MIT License.
5 */
8 #include <AboutWindow.h>
9 #include <Alert.h>
10 #include <Application.h>
11 #include <Catalog.h>
12 #include <Locale.h>
13 #include <Roster.h>
14 #include <TextView.h>
16 #include "LocalePreflet.h"
17 #include "LocaleWindow.h"
20 #undef B_TRANSLATION_CONTEXT
21 #define B_TRANSLATION_CONTEXT "Locale Preflet"
24 const char* kAppName = B_TRANSLATE("Locale");
25 const char* kSignature = "application/x-vnd.Haiku-Locale";
28 class LocalePreflet : public BApplication {
29 public:
30 LocalePreflet();
31 virtual ~LocalePreflet();
33 virtual void MessageReceived(BMessage* message);
35 private:
36 status_t _RestartApp(const char* signature) const;
38 LocaleWindow* fLocaleWindow;
42 // #pragma mark -
45 LocalePreflet::LocalePreflet()
47 BApplication(kSignature),
48 fLocaleWindow(new LocaleWindow())
50 fLocaleWindow->Show();
54 LocalePreflet::~LocalePreflet()
59 void
60 LocalePreflet::MessageReceived(BMessage* message)
62 switch (message->what) {
63 case B_LOCALE_CHANGED:
64 BLocaleRoster::Default()->Refresh();
65 fLocaleWindow->PostMessage(message);
66 break;
68 case kMsgRestartTrackerAndDeskbar:
69 if (message->FindInt32("which") == 1) {
70 _RestartApp("application/x-vnd.Be-TRAK");
71 _RestartApp("application/x-vnd.Be-TSKB");
73 break;
75 case B_ABOUT_REQUESTED:
77 BAboutWindow* window;
79 const char* authors[] = {
80 "Axel Dörfler",
81 "Adrien Destugues",
82 "Oliver Tappe",
83 NULL
86 window = new BAboutWindow(kAppName, kSignature);
87 window->AddCopyright(2005, "Haiku, Inc.");
88 window->AddAuthors(authors);
90 window->Show();
92 break;
95 default:
96 BApplication::MessageReceived(message);
97 break;
102 status_t
103 LocalePreflet::_RestartApp(const char* signature) const
105 app_info info;
106 status_t status = be_roster->GetAppInfo(signature, &info);
107 if (status != B_OK)
108 return status;
110 BMessenger application(signature);
111 status = application.SendMessage(B_QUIT_REQUESTED);
112 if (status != B_OK)
113 return status;
115 status_t exit;
116 wait_for_thread(info.thread, &exit);
118 return be_roster->Launch(signature);
122 // #pragma mark -
126 main(int argc, char** argv)
128 LocalePreflet app;
129 app.Run();
130 return 0;