From ae7a6e3a6ffcfb7ad151d684822cd0f2f5bc77af Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 10 Apr 2010 17:52:05 +0000 Subject: [PATCH] Patch by mt (ticket #5573) : localize deskbar. Thanks ! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36117 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/deskbar/BarApp.cpp | 3 ++ src/apps/deskbar/BarApp.h | 3 ++ src/apps/deskbar/BeMenu.cpp | 58 +++++++++++++++++--------- src/apps/deskbar/Jamfile | 11 ++++- src/apps/deskbar/PreferencesWindow.cpp | 43 ++++++++++--------- src/apps/deskbar/StatusView.cpp | 28 ++++++++----- src/apps/deskbar/TimeView.cpp | 25 ++++++----- src/apps/deskbar/WindowMenu.cpp | 15 ++++--- 8 files changed, 121 insertions(+), 65 deletions(-) diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 8483fe0772..d1e1a2e7ab 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -39,10 +39,12 @@ All rights reserved. #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -93,6 +95,7 @@ TBarApp::TBarApp() InitSettings(); InitIconPreloader(); + be_locale->GetAppCatalog(&fCatalog); be_roster->StartWatching(this); sBarTeamInfoList.MakeEmpty(); diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 9c42a3c561..3041b7a8f1 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -36,6 +36,7 @@ All rights reserved. #include +#include #include #include "BarWindow.h" #include "PreferencesWindow.h" @@ -178,6 +179,8 @@ class TBarApp : public BApplication { static BLocker sSubscriberLock; static BList sBarTeamInfoList; static BList sSubscribers; + + BCatalog fCatalog; }; #endif // BAR_APP_H diff --git a/src/apps/deskbar/BeMenu.cpp b/src/apps/deskbar/BeMenu.cpp index c2fca348ef..cda98bc18a 100644 --- a/src/apps/deskbar/BeMenu.cpp +++ b/src/apps/deskbar/BeMenu.cpp @@ -34,7 +34,9 @@ All rights reserved. #include #include +#include #include +#include #include #include #include @@ -50,6 +52,9 @@ All rights reserved. #include "StatusView.h" #include "tracker_private.h" +#undef TR_CONTEXT +#define TR_CONTEXT "BeMenu" + #define ROSTER_SIG "application/x-vnd.Be-ROST" #ifdef MOUNT_MENU_IN_DESKBAR @@ -67,6 +72,8 @@ class DeskbarMountMenu : public BPrivate::MountMenu { namespace BPrivate { BMenu* TrackerBuildRecentFindItemsMenu(const char*); } + + using namespace BPrivate; @@ -134,7 +141,7 @@ void TBeMenu::DoneBuildingItemList() { if (fItemList->CountItems() <= 0) { - BMenuItem* item = new BMenuItem("", 0); + BMenuItem* item = new BMenuItem(TR(""), 0); item->SetEnabled(false); AddItem(item); } else @@ -150,8 +157,8 @@ TBeMenu::AddNextItem() TrackingHookData* data = fBarView->GetTrackingHookData(); if (fAddState == kAddingRecents) { - const char* recentTitle[] = {"Recent documents", "Recent folders", - "Recent applications"}; + static const char* recentTitle[] = {TR_MARK("Recent documents"), + TR_MARK("Recent folders"), TR_MARK("Recent applications")}; const int recentType[] = {kRecentDocuments, kRecentFolders, kRecentApplications}; const int recentTypes = 3; @@ -160,7 +167,7 @@ TBeMenu::AddNextItem() bool enabled = false; for (int i = 0; i < recentTypes; i++) { - recentItem[i] = new TRecentsMenu(recentTitle[i], fBarView, + recentItem[i] = new TRecentsMenu(TR(recentTitle[i]), fBarView, recentType[i]); if (recentItem[i]) @@ -226,63 +233,75 @@ TBeMenu::AddStandardBeMenuItems() BMenuItem* item; BRoster roster; if (!roster.IsRunning(kTrackerSignature)) { - item = new BMenuItem("Restart Tracker", new BMessage(kRestartTracker)); + item = new BMenuItem(TR("Restart Tracker"), new BMessage(kRestartTracker)); AddItem(item); AddSeparatorItem(); } + static const char* kAboutHaikuMenuItemStr = TR_MARK( + "About Haiku" B_UTF8_ELLIPSIS); + static const char* kAboutThisSystemMenuItemStr = TR_MARK( + "About this system" B_UTF8_ELLIPSIS); + item = new BMenuItem( #ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL - "About Haiku" + TR(kAboutHaikuMenuItemStr) #else - "About this system" + TR(kAboutThisSystemMenuItemStr) #endif - B_UTF8_ELLIPSIS, new BMessage(kShowSplash)); + , new BMessage(kShowSplash)); item->SetEnabled(!dragging); AddItem(item); + static const char* kFindMenuItemStr = TR_MARK("Find" B_UTF8_ELLIPSIS); + #ifdef SHOW_RECENT_FIND_ITEMS - item = new BMenuItem(TrackerBuildRecentFindItemsMenu("Find"B_UTF8_ELLIPSIS), + item = new BMenuItem( + TrackerBuildRecentFindItemsMenu(kFindMenuItemStr), new BMessage(kFindButton)); #else - item = new BMenuItem("Find"B_UTF8_ELLIPSIS, new BMessage(kFindButton)); + item = new BMenuItem(TR(kFindMenuItemStr), new BMessage(kFindButton)); #endif item->SetEnabled(!dragging); AddItem(item); - item = new BMenuItem("Show replicants", new BMessage(kToggleDraggers)); + item = new BMenuItem(TR("Show replicants"), new BMessage(kToggleDraggers)); item->SetEnabled(!dragging); item->SetMarked(BDragger::AreDraggersDrawn()); AddItem(item); + static const char* kMountMenuStr = TR_MARK("Mount"); + #ifdef MOUNT_MENU_IN_DESKBAR - DeskbarMountMenu* mountMenu = new DeskbarMountMenu("Mount"); + DeskbarMountMenu* mountMenu = new DeskbarMountMenu(TR(kMountMenuStr)); mountMenu->SetEnabled(!dragging); AddItem(mountMenu); #endif - item = new BMenuItem("Deskbar preferences" B_UTF8_ELLIPSIS, + item = new BMenuItem(TR("Deskbar preferences" B_UTF8_ELLIPSIS), new BMessage(kConfigShow)); item->SetTarget(be_app); AddItem(item); AddSeparatorItem(); - BMenu* shutdownMenu = new BMenu("Shutdown" B_UTF8_ELLIPSIS); + BMenu* shutdownMenu = new BMenu(TR("Shutdown" B_UTF8_ELLIPSIS)); - item = new BMenuItem("Restart system", new BMessage(kRebootSystem)); + item = new BMenuItem(TR("Restart system"), new BMessage(kRebootSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); + static const char* kSuspendMenuItemStr = TR_MARK("Suspend"); + #ifdef APM_SUPPORT if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) { - item = new BMenuItem("Suspend", new BMessage(kSuspendSystem)); + item = new BMenuItem(kSuspendMenuItemStr), new BMessage(kSuspendSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); } #endif - item = new BMenuItem("Power off", new BMessage(kShutdownSystem)); + item = new BMenuItem(TR("Power off"), new BMessage(kShutdownSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); shutdownMenu->SetFont(be_plain_font); @@ -367,10 +386,10 @@ TBeMenu::ScreenLocation() if (expando && vertical && fBarView->Left()) { PRINT(("Left\n")); - point = rect.RightTop() + BPoint(0,3); + point = rect.RightTop() + BPoint(0, 3); } else if (expando && vertical && !fBarView->Left()) { PRINT(("Right\n")); - point = rect.LeftTop() - BPoint(Bounds().Width(), 0) + BPoint(0,3); + point = rect.LeftTop() - BPoint(Bounds().Width(), 0) + BPoint(0, 3); } else point = BMenu::ScreenLocation(); @@ -633,5 +652,6 @@ DeskbarMountMenu::AddDynamicItem(add_state s) return false; } + #endif diff --git a/src/apps/deskbar/Jamfile b/src/apps/deskbar/Jamfile index 18e7702d90..2e741b3d53 100644 --- a/src/apps/deskbar/Jamfile +++ b/src/apps/deskbar/Jamfile @@ -39,6 +39,15 @@ Application Deskbar : ResourceSet.cpp Switcher.cpp $(targetSource) - : be tracker $(targetLib) $(TARGET_LIBSUPC++) + : be tracker liblocale.so $(targetLib) $(TARGET_LIBSUPC++) ; +DoCatalogs Deskbar : + application/x-vnd.Be-TSKB + : + BeMenu.cpp + PreferencesWindow.cpp + StatusView.cpp + TimeView.cpp + WindowMenu.cpp + ; diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index e6e89b2390..cbd94d03f6 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -9,8 +9,10 @@ #include "PreferencesWindow.h" +#include #include #include +#include #include #include #include @@ -22,17 +24,20 @@ #include "StatusView.h" +#undef TR_CONTEXT +#define TR_CONTEXT "PreferencesWindow" + PreferencesWindow::PreferencesWindow(BRect frame) : - BWindow(frame, "Deskbar preferences", B_TITLED_WINDOW, + BWindow(frame, TR("Deskbar preferences"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE) { // Controls - fMenuRecentDocuments = new BCheckBox("Recent documents:", + fMenuRecentDocuments = new BCheckBox(TR("Recent documents:"), new BMessage(kUpdateRecentCounts)); - fMenuRecentApplications = new BCheckBox("Recent applications:", + fMenuRecentApplications = new BCheckBox(TR("Recent applications:"), new BMessage(kUpdateRecentCounts)); - fMenuRecentFolders = new BCheckBox("Recent folders:", + fMenuRecentFolders = new BCheckBox(TR("Recent folders:"), new BMessage(kUpdateRecentCounts)); fMenuRecentDocumentCount = new BTextControl(NULL, NULL, @@ -42,25 +47,25 @@ PreferencesWindow::PreferencesWindow(BRect frame) fMenuRecentFolderCount = new BTextControl(NULL, NULL, new BMessage(kUpdateRecentCounts)); - fAppsSort = new BCheckBox("Sort running applications", + fAppsSort = new BCheckBox(TR("Sort running applications"), new BMessage(kSortRunningApps)); - fAppsSortTrackerFirst = new BCheckBox("Tracker always first", + fAppsSortTrackerFirst = new BCheckBox(TR("Tracker always first"), new BMessage(kTrackerFirst)); - fAppsShowExpanders = new BCheckBox("Show application expander", + fAppsShowExpanders = new BCheckBox(TR("Show application expander"), new BMessage(kSuperExpando)); - fAppsExpandNew = new BCheckBox("Expand new applications", + fAppsExpandNew = new BCheckBox(TR("Expand new applications"), new BMessage(kExpandNewTeams)); - fClock24Hours = new BCheckBox("24 hour clock", new BMessage(kMilTime)); - fClockSeconds = new BCheckBox("Show seconds", + fClock24Hours = new BCheckBox(TR("24 hour clock"), new BMessage(kMilTime)); + fClockSeconds = new BCheckBox(TR("Show seconds"), new BMessage(kShowSeconds)); - fClockEuropeanDate = new BCheckBox("European date", + fClockEuropeanDate = new BCheckBox(TR("European date"), new BMessage(kEuroDate)); - fClockFullDate = new BCheckBox("Full date", new BMessage(kFullDate)); + fClockFullDate = new BCheckBox(TR("Full date"), new BMessage(kFullDate)); - fWindowAlwaysOnTop = new BCheckBox("Always on top", + fWindowAlwaysOnTop = new BCheckBox(TR("Always on top"), new BMessage(kAlwaysTop)); - fWindowAutoRaise = new BCheckBox("Auto-raise", new BMessage(kAutoRaise)); + fWindowAutoRaise = new BCheckBox(TR("Auto-raise"), new BMessage(kAutoRaise)); BTextView* docTextView = fMenuRecentDocumentCount->TextView(); BTextView* appTextView = fMenuRecentApplicationCount->TextView(); @@ -149,10 +154,10 @@ PreferencesWindow::PreferencesWindow(BRect frame) fClockBox = new BBox("fClockBox"); fWindowBox = new BBox("fWindowBox"); - fMenuBox->SetLabel("Menu"); - fAppsBox->SetLabel("Applications"); - fClockBox->SetLabel("Clock"); - fWindowBox->SetLabel("Window"); + fMenuBox->SetLabel(TR("Menu")); + fAppsBox->SetLabel(TR("Applications")); + fClockBox->SetLabel(TR("Clock")); + fWindowBox->SetLabel(TR("Window")); BView* view; view = BLayoutBuilder::Group<>() @@ -169,7 +174,7 @@ PreferencesWindow::PreferencesWindow(BRect frame) .Add(fMenuRecentApplicationCount) .End() .End() - .Add(new BButton("Edit menu" B_UTF8_ELLIPSIS, + .Add(new BButton(TR("Edit menu" B_UTF8_ELLIPSIS), new BMessage(kEditMenuInTracker))) .SetInsets(10, 10, 10, 10) .End() diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index f331a70b92..19bac9fdd9 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -47,9 +47,11 @@ All rights reserved. #include #include #include +#include #include #include #include +#include #include #include #include @@ -118,6 +120,9 @@ DumpList(BList* itemlist) #endif /* DB_ADDONS */ +#undef TR_CONTEXT +#define TR_CONTEXT "Tray" + // don't change the name of this view to anything other than "Status"! TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) @@ -163,6 +168,7 @@ TReplicantTray::AttachedToWindow() Window()->SetPulseRate(1000000); DealWithClock(fBarView->ShowingClock()); + #ifdef DB_ADDONS // load addons and rehydrate archives #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) @@ -412,7 +418,7 @@ TReplicantTray::ShowReplicantMenu(BPoint point) if (fBarView->ShowingClock()) fClock->ShowClockOptions(ConvertToScreen(point)); else { - BMenuItem* item = new BMenuItem("Show Time", new BMessage('time')); + BMenuItem* item = new BMenuItem(TR("Show Time"), new BMessage('time')); menu->AddItem(item); menu->SetTargetForItems(this); BPoint where = ConvertToScreen(point); @@ -562,7 +568,7 @@ TReplicantTray::RunAddOnQuery(BVolume* volume, const char* predicate) bool -TReplicantTray::IsAddOn(entry_ref &ref) +TReplicantTray::IsAddOn(entry_ref& ref) { BFile file(&ref, B_READ_ONLY); @@ -574,7 +580,7 @@ TReplicantTray::IsAddOn(entry_ref &ref) DeskbarItemInfo* -TReplicantTray::DeskbarItemFor(node_ref &nodeRef) +TReplicantTray::DeskbarItemFor(node_ref& nodeRef) { for (int32 i = fItemList->CountItems(); i-- > 0 ;) { DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->ItemAt(i); @@ -606,7 +612,7 @@ TReplicantTray::DeskbarItemFor(int32 id) bool -TReplicantTray::NodeExists(node_ref &nodeRef) +TReplicantTray::NodeExists(node_ref& nodeRef) { return DeskbarItemFor(nodeRef) != NULL; } @@ -837,7 +843,7 @@ TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool force) status_t -TReplicantTray::AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddOn) +TReplicantTray::AddItem(int32 id, node_ref nodeRef, BEntry& entry, bool isAddOn) { DeskbarItemInfo* item = new DeskbarItemInfo; if (item == NULL) @@ -1200,7 +1206,7 @@ TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex) *index = -1; BView* view; - if (byIndex){ + if (byIndex) { if (fShelf->ReplicantAt(target, &view, (uint32*)id)) { if (view) { *index = target; @@ -1386,7 +1392,7 @@ TReplicantTray::RealignReplicants(int32 startIndex) fRightBottomReplicant.Set(0, 0, 0, 0); BView* view = NULL; - for (int32 i = startIndex ; i < count ; i++){ + for (int32 i = startIndex ; i < count ; i++) { fShelf->ReplicantAt(i, &view); if (view != NULL) { BPoint loc = LocationForReplicant(i, view->Frame().Width()); @@ -1459,9 +1465,9 @@ TDragRegion::FrameMoved(BPoint) { if (fBarView->Left() && fBarView->Vertical() && fDragLocation != kNoDragRegion) - fChild->MoveTo(5,2); + fChild->MoveTo(5, 2); else - fChild->MoveTo(2,2); + fChild->MoveTo(2, 2); } @@ -1572,7 +1578,7 @@ TDragRegion::DragRegion() const dragRegion.top += kTopBottomInset; dragRegion.bottom -= kTopBottomInset; - bool placeOnLeft=false; + bool placeOnLeft = false; if (fDragLocation == kAutoPlaceDragRegion) { if (fBarView->Vertical() && fBarView->Left()) placeOnLeft = true; @@ -1608,7 +1614,7 @@ TDragRegion::MouseDown(BPoint thePoint) if (!dragRegion.Contains(thePoint)) return; - while(true) { + while (true) { GetMouse(&where, &buttons); if (!buttons) break; diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 94cbadfcb1..95500352a0 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -37,7 +37,9 @@ All rights reserved. #include +#include #include +#include #include #include #include @@ -66,6 +68,9 @@ enum { }; +#undef TR_CONTEXT +#define TR_CONTEXT "TimeView" + TTimeView::TTimeView(float maxWidth, float height, bool showSeconds, bool milTime, bool fullDate, bool euroDate, bool) : @@ -171,12 +176,12 @@ TTimeView::GetPreferredSize(float* width, float* height) // overlap the bevels in the parent view. if (ShowingDate()) *width = fOrientation ? - min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fDateStr)) - : kHMargin + StringWidth(fDateStr); + min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fDateStr)) + : kHMargin + StringWidth(fDateStr); else { *width = fOrientation ? - min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr)) - : kHMargin + StringWidth(fTimeStr); + min_c(fMaxWidth - kHMargin, kHMargin + StringWidth(fTimeStr)) + : kHMargin + StringWidth(fTimeStr); } } @@ -295,7 +300,7 @@ TTimeView::StartLongClickNotifier(BPoint where) // use the doubleClickSpeed as a threshold fLongClickMessageRunner = new BMessageRunner(BMessenger(this), - &longClickMessage, longClickThreshold, 1); + &longClickMessage, longClickThreshold, 1); } @@ -323,7 +328,7 @@ TTimeView::GetCurrentTime() } // remove leading 0 from time when hour is less than 10 - const char *str = tmp; + const char* str = tmp; if (str[0] == '0') str++; @@ -544,7 +549,7 @@ TTimeView::CalculateTextPlacement() BRect rectArray[1]; escapement_delta delta = { 0.0, 0.0 }; font.GetBoundingBoxesForStrings(stringArray, 1, B_SCREEN_METRIC, &delta, - rectArray); + rectArray); fTimeLocation.y = fDateLocation.y = ceilf((bounds.Height() - rectArray[0].Height() + 1.0) / 2.0 - rectArray[0].top); @@ -558,14 +563,14 @@ TTimeView::ShowClockOptions(BPoint point) menu->SetFont(be_plain_font); BMenuItem* item; - item = new BMenuItem("Change time" B_UTF8_ELLIPSIS, + item = new BMenuItem(TR("Change time" B_UTF8_ELLIPSIS), new BMessage(kChangeClock)); menu->AddItem(item); - item = new BMenuItem("Hide time", new BMessage('time')); + item = new BMenuItem(TR("Hide time"), new BMessage('time')); menu->AddItem(item); - item = new BMenuItem("Show calendar" B_UTF8_ELLIPSIS, + item = new BMenuItem(TR("Show calendar" B_UTF8_ELLIPSIS), new BMessage(kShowCalendar)); menu->AddItem(item); diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp index 89958a38ed..029e48a60a 100644 --- a/src/apps/deskbar/WindowMenu.cpp +++ b/src/apps/deskbar/WindowMenu.cpp @@ -35,6 +35,8 @@ All rights reserved. #include #include #include +#include +#include #include #include "BarApp.h" @@ -58,6 +60,9 @@ const int32 kListFloater = 5; const int32 kSystemFloater = 6; +#undef TR_CONTEXT +#define TR_CONTEXT "WindowMenu" + bool TWindowMenu::WindowShouldBeListed(uint32 behavior) { @@ -173,7 +178,7 @@ TWindowMenu::AttachedToWindow() int32 itemCount = CountItems() + parentMenuItems; if (itemCount < 1) { TWindowMenuItem* noWindowsItem = - new TWindowMenuItem("No windows", -1, false, false); + new TWindowMenuItem(TR("No windows"), -1, false, false); noWindowsItem->SetEnabled(false); @@ -183,7 +188,7 @@ TWindowMenu::AttachedToWindow() // it. (but we only add this option if the application is not Tracker.) if (fApplicationSignature.ICompare(kTrackerSignature) != 0) { AddSeparatorItem(); - AddItem(new TShowHideMenuItem("Quit application", fTeam, + AddItem(new TShowHideMenuItem(TR("Quit application"), fTeam, B_QUIT_REQUESTED)); } } else { @@ -191,11 +196,11 @@ TWindowMenu::AttachedToWindow() // to the menu if (!dragging) { TShowHideMenuItem* hide = - new TShowHideMenuItem("Hide all", fTeam, B_MINIMIZE_WINDOW); + new TShowHideMenuItem(TR("Hide all"), fTeam, B_MINIMIZE_WINDOW); TShowHideMenuItem* show = - new TShowHideMenuItem("Show all", fTeam, B_BRING_TO_FRONT); + new TShowHideMenuItem(TR("Show all"), fTeam, B_BRING_TO_FRONT); TShowHideMenuItem* close = - new TShowHideMenuItem("Close all", fTeam, B_QUIT_REQUESTED); + new TShowHideMenuItem(TR("Close all"), fTeam, B_QUIT_REQUESTED); if (miniCount == itemCount) hide->SetEnabled(false);