diff --git a/src/preferences/notifications/DisplayView.cpp b/src/preferences/notifications/DisplayView.cpp index fca5fcacaf..ebc10b76ef 100644 --- a/src/preferences/notifications/DisplayView.cpp +++ b/src/preferences/notifications/DisplayView.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,9 @@ #include "DisplayView.h" #include "SettingsHost.h" -#define _T(str) (str) + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "DisplayView" DisplayView::DisplayView(SettingsHost* host) @@ -37,26 +40,27 @@ DisplayView::DisplayView(SettingsHost* host) SettingsPane("display", host) { // Window width - fWindowWidth = new BTextControl(_T("Window width:"), NULL, + fWindowWidth = new BTextControl(B_TRANSLATE("Window width:"), NULL, new BMessage(kSettingChanged)); // Icon size fIconSize = new BMenu("iconSize"); - fIconSize->AddItem(new BMenuItem(_T("Mini icon"), + fIconSize->AddItem(new BMenuItem(B_TRANSLATE("Mini icon"), new BMessage(kSettingChanged))); - fIconSize->AddItem(new BMenuItem(_T("Large icon"), + fIconSize->AddItem(new BMenuItem(B_TRANSLATE("Large icon"), new BMessage(kSettingChanged))); fIconSize->SetLabelFromMarked(true); - fIconSizeField = new BMenuField(_T("Icon size:"), fIconSize); + fIconSizeField = new BMenuField(B_TRANSLATE("Icon size:"), fIconSize); // Title position fTitlePosition = new BMenu("titlePosition"); - fTitlePosition->AddItem(new BMenuItem(_T("Above icon"), + fTitlePosition->AddItem(new BMenuItem(B_TRANSLATE("Above icon"), new BMessage(kSettingChanged))); - fTitlePosition->AddItem(new BMenuItem(_T("Right of icon"), + fTitlePosition->AddItem(new BMenuItem(B_TRANSLATE("Right of icon"), new BMessage(kSettingChanged))); fTitlePosition->SetLabelFromMarked(true); - fTitlePositionField = new BMenuField(_T("Title position:"), fTitlePosition); + fTitlePositionField = new BMenuField(B_TRANSLATE("Title position:"), + fTitlePosition); // Load settings Load(); @@ -111,9 +115,9 @@ DisplayView::Load() if (create_directory(path.Path(), 0755) != B_OK) { BAlert* alert = new BAlert("", - _T("There was a problem saving the preferences.\n" + B_TRANSLATE("There was a problem saving the preferences.\n" "It's possible you don't have write access to the " - "settings directory."), "OK", NULL, NULL, + "settings directory."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); } @@ -205,9 +209,9 @@ DisplayView::Save() status_t ret = settings.Flatten(&file); if (ret != B_OK) { BAlert* alert = new BAlert("", - _T("Can't save preferenes, you probably don't have write " - "access to the settings directory or the disk is full."), "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_STOP_ALERT); + B_TRANSLATE("Can't save preferenes, you probably don't have " + "write access to the settings directory or the disk is full."), + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return ret; } diff --git a/src/preferences/notifications/GeneralView.cpp b/src/preferences/notifications/GeneralView.cpp index e8de047c86..0334c0f2b4 100644 --- a/src/preferences/notifications/GeneralView.cpp +++ b/src/preferences/notifications/GeneralView.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -36,14 +37,14 @@ #include "GeneralView.h" #include "SettingsHost.h" -#define _T(str) (str) - +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "GeneralView" const int32 kServer = '_TSR'; -const char* kStartServer = _T("Enable notifications"); -const char* kStopServer = _T("Disable notifications"); -const char* kStarted = _T("Events are notified"); -const char* kStopped = _T("Events are not notified"); +const char* kStartServer = B_TRANSLATE("Enable notifications"); +const char* kStopServer = B_TRANSLATE("Disable notifications"); +const char* kStarted = B_TRANSLATE("Events are notified"); +const char* kStopped = B_TRANSLATE("Events are not notified"); GeneralView::GeneralView(SettingsHost* host) @@ -71,13 +72,14 @@ GeneralView::GeneralView(SettingsHost* host) // Autostart fAutoStart = new BCheckBox("autostart", - _T("Enable notifications at startup"), new BMessage(kSettingChanged)); + B_TRANSLATE("Enable notifications at startup"), + new BMessage(kSettingChanged)); // Display time - fTimeout = new BTextControl(_T("Hide notifications from screen after"), NULL, - new BMessage(kSettingChanged)); + fTimeout = new BTextControl(B_TRANSLATE("Hide notifications from screen" + " after"), NULL, new BMessage(kSettingChanged)); BStringView* displayTimeLabel = new BStringView("dt_label", - _T("seconds of inactivity")); + B_TRANSLATE("seconds of inactivity"); // Default position // TODO: Here will come a screen representation with the four corners clickable @@ -129,11 +131,11 @@ GeneralView::MessageReceived(BMessage* msg) // Check if server is available if (!_CanFindServer(&ref)) { - BAlert* alert = new BAlert(_T("Notifications"), - _T("The notifications server cannot be found, " - "this means your InfoPopper installation was not " - "successfully completed."), _T("OK"), NULL, - NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert(B_TRANSLATE("Notifications"), + B_TRANSLATE("The notifications server cannot be" + " found, this means your InfoPopper installation was" + " not successfully completed."), B_TRANSLATE("OK"), + NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return; } @@ -146,20 +148,22 @@ GeneralView::MessageReceived(BMessage* msg) status_t ret = B_ERROR; BMessenger messenger(kNotificationServerSignature, team, &ret); if (ret != B_OK) { - BAlert* alert = new BAlert(_T("Notifications"), - _T("Notifications cannot be stopped, because " - "the server can't be reached."), - _T("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert(B_TRANSLATE( + "Notifications"), B_TRANSLATE("Notifications " + "cannot be stopped, because the server can't be" + " reached."), B_TRANSLATE("OK"), NULL, NULL, + B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return; } // Send quit message if (messenger.SendMessage(new BMessage(B_QUIT_REQUESTED)) != B_OK) { - BAlert* alert = new BAlert(_T("Notifications"), - _T("Cannot disable notifications because the server " - "can't be reached."), _T("OK"), NULL, - NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert(B_TRANSLATE( + "Notifications"), B_TRANSLATE("Cannot disable" + " notifications because the server can't be " + "reached."), B_TRANSLATE("OK"), + NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return; } @@ -170,11 +174,13 @@ GeneralView::MessageReceived(BMessage* msg) // Start server status_t err = be_roster->Launch(kNotificationServerSignature); if (err != B_OK) { - BAlert* alert = new BAlert(_T("Notifications"), - _T("Cannot enable notifications because the server " - "cannot be found.\nThis means your InfoPopper " - "installation was not successfully completed."), - _T("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert(B_TRANSLATE( + "Notifications"), B_TRANSLATE("Cannot enable" + " notifications because the server cannot be " + "found.\nThis means your InfoPopper installation" + " was not successfully completed.")), + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, + B_STOP_ALERT); (void)alert->Go(); return; } @@ -205,9 +211,9 @@ GeneralView::Load() if (create_directory(path.Path(), 0755) != B_OK) { BAlert* alert = new BAlert("", - _T("There was a problem saving the preferences.\n" + B_TRANSLATE("There was a problem saving the preferences.\n" "It's possible you don't have write access to the " - "settings directory."), "OK", NULL, NULL, + "settings directory."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); } @@ -261,9 +267,9 @@ GeneralView::Save() ret = settings.Flatten(&file); if (ret != B_OK) { BAlert* alert = new BAlert("", - _T("An error is occurred saving the preferences.\n" + B_TRANSLATE("An error occurred saving the preferences.\n" "It's possible you are running out of disk space."), - "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return ret; } @@ -272,9 +278,9 @@ GeneralView::Save() entry_ref ref; if (!_CanFindServer(&ref)) { BAlert* alert = new BAlert("", - _T("The notifications server cannot be found.\n" + B_TRANSLATE("The notifications server cannot be found.\n" "A possible cause is an installation not done correctly"), - "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return B_ERROR; } @@ -286,8 +292,9 @@ GeneralView::Save() ret = find_directory(B_USER_BOOT_DIRECTORY, &path, true); if (ret != B_OK) { BAlert* alert = new BAlert("", - _T("Can't save preferences, you probably don't have write " - "access to the boot settings directory."), "OK", NULL, NULL, + B_TRANSLATE"Can't save preferences, you probably don't have " + "write access to the boot settings directory."), B_TRANSLATE("OK"), + NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return ret; @@ -305,8 +312,9 @@ GeneralView::Save() if ((ret = directory.CreateSymLink(serverPath.Leaf(), serverPath.Path(), NULL) != B_OK)) { BAlert* alert = new BAlert("", - _T("Can't enable notifications at startup time, you probably don't have " - "write permission to the boot settings directory."), "OK", NULL, NULL, + B_TRANSLATE("Can't enable notifications at startup time, " + "you probably don't have write permission to the boot settings" + " directory."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return ret; diff --git a/src/preferences/notifications/Jamfile b/src/preferences/notifications/Jamfile index 43805cde33..4bd1820db2 100644 --- a/src/preferences/notifications/Jamfile +++ b/src/preferences/notifications/Jamfile @@ -14,9 +14,19 @@ Application Notifications : NotificationsView.cpp IconRule.cpp IconItem.cpp - : be translation libcolumnlistview.a libnotification.a $(TARGET_LIBSTDC++) + : be translation libcolumnlistview.a libnotification.a $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS) : Notifications.rdef ; Depends Notifications : libcolumnlistview.a ; Depends Notifications : libnotification.a ; + +DoCatalogs Notifications : + x-vnd.Haiku-Notifications + : + DisplayView.cpp + GeneralView.cpp + PrefletWin.cpp + PrefletView.cpp + NotificationsView.cpp + ; diff --git a/src/preferences/notifications/NotificationsView.cpp b/src/preferences/notifications/NotificationsView.cpp index 890437e1e9..9fcdbef212 100644 --- a/src/preferences/notifications/NotificationsView.cpp +++ b/src/preferences/notifications/NotificationsView.cpp @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -25,7 +26,8 @@ #include "NotificationsView.h" -#define _T(str) (str) +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "NotificationView" const float kEdgePadding = 5.0; const float kCLVTitlePadding = 8.0; @@ -55,47 +57,47 @@ NotificationsView::NotificationsView() BRect rect(0, 0, 100, 100); // Search application field - fSearch = new BTextControl(_T("Search:"), NULL, + fSearch = new BTextControl(B_TRANSLATE("Search:"), NULL, new BMessage(kSettingChanged)); // Applications list - fApplications = new BColumnListView(rect, _T("Applications"), + fApplications = new BColumnListView(rect, B_TRANSLATE("Applications"), 0, B_WILL_DRAW, B_FANCY_BORDER, true); fApplications->SetSelectionMode(B_SINGLE_SELECTION_LIST); - fAppCol = new BStringColumn(_T("Application"), 200, - be_plain_font->StringWidth(_T("Application")) + (kCLVTitlePadding * 2), - rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); + fAppCol = new BStringColumn(B_TRANSLATE("Application"), 200, + be_plain_font->StringWidth(B_TRANSLATE("Application")) + + (kCLVTitlePadding * 2), rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); fApplications->AddColumn(fAppCol, kAppIndex); - fAppEnabledCol = new BStringColumn(_T("Enabled"), 10, - be_plain_font->StringWidth(_T("Enabled")) + (kCLVTitlePadding * 2), - rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); + fAppEnabledCol = new BStringColumn(B_TRANSLATE("Enabled"), 10, + be_plain_font->StringWidth(B_TRANSLATE("Enabled")) + + (kCLVTitlePadding * 2), rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); fApplications->AddColumn(fAppEnabledCol, kAppEnabledIndex); // Notifications list - fNotifications = new BColumnListView(rect, _T("Notifications"), + fNotifications = new BColumnListView(rect, B_TRANSLATE("Notifications"), 0, B_WILL_DRAW, B_FANCY_BORDER, true); fNotifications->SetSelectionMode(B_SINGLE_SELECTION_LIST); - fTitleCol = new BStringColumn(_T("Title"), 100, - be_plain_font->StringWidth(_T("Title")) + (kCLVTitlePadding * 2), - rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); + fTitleCol = new BStringColumn(B_TRANSLATE("Title"), 100, + be_plain_font->StringWidth(B_TRANSLATE"Title")) + + (kCLVTitlePadding * 2), rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); fNotifications->AddColumn(fTitleCol, kTitleIndex); - fDateCol = new BDateColumn(_T("Last Received"), 100, - be_plain_font->StringWidth(_T("Last Received")) + (kCLVTitlePadding * 2), - rect.Width(), B_ALIGN_LEFT); + fDateCol = new BDateColumn(B_TRANSLATE("Last Received"), 100, + be_plain_font->StringWidth(B_TRANSLATE("Last Received")) + + (kCLVTitlePadding * 2), rect.Width(), B_ALIGN_LEFT); fNotifications->AddColumn(fDateCol, kDateIndex); - fTypeCol = new BStringColumn(_T("Type"), 100, - be_plain_font->StringWidth(_T("Type")) + (kCLVTitlePadding * 2), - rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); + fTypeCol = new BStringColumn(B_TRANSLATE("Type"), 100, + be_plain_font->StringWidth(B_TRANSLATE("Type")) + + (kCLVTitlePadding * 2), rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); fNotifications->AddColumn(fTypeCol, kTypeIndex); - fAllowCol = new BStringColumn(_T("Allowed"), 100, - be_plain_font->StringWidth(_T("Allowed")) + (kCLVTitlePadding * 2), - rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); + fAllowCol = new BStringColumn(B_TRANSLATE("Allowed"), 100, + be_plain_font->StringWidth(B_TRANSLATE("Allowed")) + + (kCLVTitlePadding * 2), rect.Width(), B_TRUNCATE_END, B_ALIGN_LEFT); fNotifications->AddColumn(fAllowCol, kAllowIndex); // Load the applications list @@ -177,9 +179,9 @@ NotificationsView::_LoadAppUsage() if (create_directory(path.Path(), 0755) != B_OK) { BAlert* alert = new BAlert("", - _T("There was a problem saving the preferences.\n" + B_TRANSLATE("There was a problem saving the preferences.\n" "It's possible you don't have write access to the " - "settings directory."), "OK", NULL, NULL, + "settings directory."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); return B_ERROR; @@ -247,24 +249,25 @@ NotificationsView::_Populate(AppUsage* usage) for (int32 i = 0; i < size; i++) { NotificationReceived* notification = usage->NotificationAt(i); time_t updated = notification->LastReceived(); - const char* allow = notification->Allowed() ? _T("Yes") : _T("No"); + const char* allow = notification->Allowed() ? B_TRANSLATE("Yes") + : B_TRANSLATE("No"); const char* type = ""; switch (notification->Type()) { case B_INFORMATION_NOTIFICATION: - type = _T("Information"); + type = B_TRANSLATE("Information"); break; case B_IMPORTANT_NOTIFICATION: - type = _T("Important"); + type = B_TRANSLATE("Important"); break; case B_ERROR_NOTIFICATION: - type = _T("Error"); + type = B_TRANSLATE("Error"); break; case B_PROGRESS_NOTIFICATION: - type = _T("Progress"); + type = B_TRANSLATE("Progress"); break; default: - type = _T("Unknown"); + type = B_TRANSLATE("Unknown"); } BRow* row = new BRow(); diff --git a/src/preferences/notifications/PrefletView.cpp b/src/preferences/notifications/PrefletView.cpp index 61bf2f62ff..0a6acb03c5 100644 --- a/src/preferences/notifications/PrefletView.cpp +++ b/src/preferences/notifications/PrefletView.cpp @@ -7,6 +7,7 @@ * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com */ +#include #include #include #include @@ -20,7 +21,10 @@ #include "DisplayView.h" #include "NotificationsView.h" -#define _T(str) (str) + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "PrefletView" + const int32 kPageSelected = '_LCH'; @@ -32,9 +36,9 @@ PrefletView::PrefletView(SettingsHost* host) // Page selector fRule = new BIconRule("icon_rule"); fRule->SetSelectionMessage(new BMessage(kPageSelected)); - fRule->AddIcon(_T("General"), NULL); - fRule->AddIcon(_T("Display"), NULL); - //fRule->AddIcon(_T("Notifications"), NULL); + fRule->AddIcon(B_TRANSLATE("General"), NULL); + fRule->AddIcon(B_TRANSLATE("Display"), NULL); + //fRule->AddIcon(B_TRANSLATE("Notifications"), NULL); // View for card layout fPagesView = new BView("pages", B_WILL_DRAW); diff --git a/src/preferences/notifications/PrefletWin.cpp b/src/preferences/notifications/PrefletWin.cpp index 6925ac3e38..0d0d85636f 100644 --- a/src/preferences/notifications/PrefletWin.cpp +++ b/src/preferences/notifications/PrefletWin.cpp @@ -11,11 +11,15 @@ #include #include #include +#include #include "PrefletWin.h" #include "PrefletView.h" -#define _T(str) (str) + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "PrefletWin" + const int32 kRevert = '_RVT'; const int32 kSave = '_SAV'; @@ -23,16 +27,18 @@ const int32 kSave = '_SAV'; PrefletWin::PrefletWin() : - BWindow(BRect(0, 0, 1, 1), "Notifications", B_TITLED_WINDOW, B_NOT_ZOOMABLE - | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) + BWindow(BRect(0, 0, 1, 1), B_TRANSLATE("Notifications"), B_TITLED_WINDOW, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS + | B_AUTO_UPDATE_SIZE_LIMITS) { // Preflet container view fMainView = new PrefletView(this); // Save and revert buttons - fRevert = new BButton("revert", _T("Revert"), new BMessage(kRevert)); + fRevert = new BButton("revert", B_TRANSLATE("Revert"), + new BMessage(kRevert)); fRevert->SetEnabled(false); - fSave = new BButton("save", _T("Save"), new BMessage(kSave)); + fSave = new BButton("save", B_TRANSLATE("Save"), new BMessage(kSave)); fSave->SetEnabled(false); // Calculate inset