From 9254b0c4df832efd3352bc980acc33ca0fa0c1cf Mon Sep 17 00:00:00 2001 From: Joachim Seemer Date: Fri, 10 Jun 2011 13:43:06 +0000 Subject: [PATCH] Applied localization patch by mt, removed About menu/window as we decided those are not needed with system software. Fixes #7656. Compiling, working cosmetics, I'd say +alpha. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42085 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/desklink/DeskButton.cpp | 13 +++++---- src/bin/desklink/Jamfile | 10 ++++++- src/bin/desklink/MediaReplicant.cpp | 43 ++++++++++++++--------------- src/bin/desklink/VolumeControl.cpp | 26 ++++++++--------- src/bin/desklink/VolumeControl.h | 3 +- 5 files changed, 52 insertions(+), 43 deletions(-) diff --git a/src/bin/desklink/DeskButton.cpp b/src/bin/desklink/DeskButton.cpp index 0890b329ad..5076f53553 100644 --- a/src/bin/desklink/DeskButton.cpp +++ b/src/bin/desklink/DeskButton.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,11 @@ #define OPEN_REF 'opre' #define DO_ACTION 'doac' + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "DeskButton" + + extern const char *kAppSignature; // from desklink.cpp @@ -107,14 +113,10 @@ void DeskButton::MessageReceived(BMessage *message) { switch (message->what) { - case B_ABOUT_REQUESTED: - (new BAlert("About Desklink", "Desklink (Replicant)\n" - " Brought to you by Jérôme DUVAL.\n\n" - "Copyright " B_UTF8_COPYRIGHT "2003-2009, Haiku","OK"))->Go(); - break; case OPEN_REF: be_roster->Launch(&fRef); break; + case DO_ACTION: { BString action; @@ -124,6 +126,7 @@ DeskButton::MessageReceived(BMessage *message) } break; } + default: BView::MessageReceived(message); break; diff --git a/src/bin/desklink/Jamfile b/src/bin/desklink/Jamfile index 74bf55d059..bad7c9004f 100644 --- a/src/bin/desklink/Jamfile +++ b/src/bin/desklink/Jamfile @@ -12,6 +12,14 @@ BinCommand desklink : VolumeControl.cpp VolumeWindow.cpp - : be libmedia.so $(TARGET_LIBSUPC++) + : be libmedia.so $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++) : desklink.rdef ; + +DoCatalogs Mail : + x-vnd.Haiku-desklink + : + DeskButton.cpp + MediaReplicant.cpp + VolumeControl.cpp +; diff --git a/src/bin/desklink/MediaReplicant.cpp b/src/bin/desklink/MediaReplicant.cpp index 2506f7d3d1..b37c9b8233 100644 --- a/src/bin/desklink/MediaReplicant.cpp +++ b/src/bin/desklink/MediaReplicant.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,10 @@ #include "VolumeWindow.h" +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "MediaReplicant" + + static const uint32 kMsgOpenMediaSettings = 'mese'; static const uint32 kMsgOpenSoundSettings = 'sose'; static const uint32 kMsgOpenMediaPlayer = 'omep'; @@ -88,9 +93,9 @@ public: MixerControl control; control.Connect(fWhich); - char text[256]; - snprintf(text, sizeof(text), "%g dB", control.Volume()); - fView->SetText(text); + BString text; + text.SetToFormat(B_TRANSLATE("%g dB"), control.Volume()); + fView->SetText(text.String()); Unlock(); } @@ -218,35 +223,33 @@ MediaReplicant::MouseDown(BPoint point) BPopUpMenu* menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); - menu->AddItem(new BMenuItem("Media preferences" B_UTF8_ELLIPSIS, + menu->AddItem(new BMenuItem( + B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenMediaSettings))); - menu->AddItem(new BMenuItem("Sound preferences" B_UTF8_ELLIPSIS, + menu->AddItem(new BMenuItem( + B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenSoundSettings))); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("Open MediaPlayer", + menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"), new BMessage(kMsgOpenMediaPlayer))); menu->AddSeparatorItem(); - BMenu* subMenu = new BMenu("Options"); + BMenu* subMenu = new BMenu(B_TRANSLATE("Options")); menu->AddItem(subMenu); - BMenuItem* item = new BMenuItem("Control physical output", + BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"), new BMessage(kMsgVolumeWhich)); item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT); subMenu->AddItem(item); - item = new BMenuItem("Beep", new BMessage(kMsgToggleBeep)); + item = new BMenuItem(B_TRANSLATE("Beep"), + new BMessage(kMsgToggleBeep)); item->SetMarked(!fDontBeep); subMenu->AddItem(item); - menu->AddSeparatorItem(); - - menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, - new BMessage(B_ABOUT_REQUESTED))); - menu->SetTargetForItems(this); subMenu->SetTargetForItems(this); @@ -265,13 +268,6 @@ void MediaReplicant::MessageReceived(BMessage* message) { switch (message->what) { - case B_ABOUT_REQUESTED: - (new BAlert("About Volume Control", "Volume Control\n" - " Brought to you by Jérôme DUVAL.\n\n" - "Copyright " B_UTF8_COPYRIGHT "2003-2010, Haiku", - "OK"))->Go(NULL); - break; - case kMsgOpenMediaPlayer: _Launch("MediaPlayer", "application/x-vnd.Haiku-MediaPlayer", B_SYSTEM_APPS_DIRECTORY, "MediaPlayer"); @@ -391,10 +387,11 @@ MediaReplicant::_Launch(const char* prettyName, const char* signature, // launch the application if (_LaunchBySignature(signature) != B_OK && _LaunchByPath(path.Path()) != B_OK) { - BString message = "Couldn't launch "; + BString message = B_TRANSLATE("Couldn't launch "); message << prettyName; - (new BAlert("desklink", message.String(), "OK"))->Go(); + (new BAlert(B_TRANSLATE("desklink"), message.String(), + B_TRANSLATE("OK")))->Go(); } } diff --git a/src/bin/desklink/VolumeControl.cpp b/src/bin/desklink/VolumeControl.cpp index f61b0866ed..f4bb019511 100644 --- a/src/bin/desklink/VolumeControl.cpp +++ b/src/bin/desklink/VolumeControl.cpp @@ -14,9 +14,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -29,6 +29,12 @@ #include "VolumeWindow.h" + + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "VolumeControl" + + static const char* kMediaServerSignature = "application/x-vnd.Be.media-server"; static const char* kAddOnServerSignature = "application/x-vnd.Be.addon-host"; @@ -37,7 +43,8 @@ static const uint32 kMsgReconnectVolume = 'rcms'; VolumeControl::VolumeControl(int32 volumeWhich, bool beep, BMessage* message) : - BSlider("VolumeControl", "Volume", message, 0, 1, B_HORIZONTAL), + BSlider("VolumeControl", B_TRANSLATE("Volume"), + message, 0, 1, B_HORIZONTAL), fMixerControl(new MixerControl(volumeWhich)), fBeep(beep), fSnapping(false), @@ -284,13 +291,6 @@ VolumeControl::MessageReceived(BMessage* msg) SetValue((int32)fMixerControl->Volume()); break; - case B_ABOUT_REQUESTED: - (new BAlert("About Volume Control", "Volume Control\n" - " Written by Jérôme DUVAL, and Axel Dörfler.\n\n" - "Copyright " B_UTF8_COPYRIGHT "2003-2009, Haiku", - "OK"))->Go(NULL); - break; - case B_SOME_APP_LAUNCHED: case B_SOME_APP_QUIT: { @@ -308,7 +308,7 @@ VolumeControl::MessageReceived(BMessage* msg) if (isMediaServer || isAddOnServer) { if (!fMediaServerRunning && !fAddOnServerRunning) { // No media server around - SetLabel("No media server running"); + SetLabel(B_TRANSLATE("No media server running")); SetEnabled(false); } else if (fMediaServerRunning && fAddOnServerRunning) { // HACK! @@ -389,8 +389,8 @@ VolumeControl::UpdateText() const if (!IsEnabled()) return NULL; - snprintf(fText, sizeof(fText), "%ld dB", Value()); - return fText; + fText.SetToFormat(B_TRANSLATE("%ld dB"), Value()); + return fText.String(); } @@ -418,7 +418,7 @@ VolumeControl::_ConnectVolume() SetLabel(errorString); SetLimits(-60, 18); } else { - SetLabel("Volume"); + SetLabel(B_TRANSLATE("Volume")); SetLimits((int32)floorf(fMixerControl->Minimum()), (int32)ceilf(fMixerControl->Maximum())); diff --git a/src/bin/desklink/VolumeControl.h b/src/bin/desklink/VolumeControl.h index 8fe9ab6c64..ea4e5f7965 100644 --- a/src/bin/desklink/VolumeControl.h +++ b/src/bin/desklink/VolumeControl.h @@ -11,6 +11,7 @@ #define VOLUME_SLIDER_H +#include #include class MixerControl; @@ -47,7 +48,7 @@ private: bool _IsReplicant() const; float _PointForValue(int32 value) const; - mutable char fText[64]; + mutable BString fText; MixerControl* fMixerControl; int32 fOriginalValue; bool fBeep;