1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 14:20:06 +02:00

TranslatableString for toolbar button labels

This commit is contained in:
Paul Licameli 2019-12-22 14:37:01 -05:00
parent 75996a851c
commit c682718ee4
13 changed files with 54 additions and 46 deletions

View File

@ -1758,7 +1758,7 @@ void AdornedRulerPanel::UpdateButtonStates()
AButton &button, const CommandID &commandName, const TranslatableString &label) { AButton &button, const CommandID &commandName, const TranslatableString &label) {
ComponentInterfaceSymbol command{ commandName, label }; ComponentInterfaceSymbol command{ commandName, label };
ToolBar::SetButtonToolTip( *mProject, button, &command, 1u ); ToolBar::SetButtonToolTip( *mProject, button, &command, 1u );
button.SetLabel(button.GetToolTipText()); button.SetLabel( Verbatim( button.GetToolTipText() ) );
button.UpdateStatus(); button.UpdateStatus();
}; };

View File

@ -151,7 +151,7 @@ AButton *ControlToolBar::MakeButton(ControlToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, int id,
bool processdownevents, bool processdownevents,
const wxChar *label) const TranslatableString &label)
{ {
AButton *r = ToolBar::MakeButton(pBar, AButton *r = ToolBar::MakeButton(pBar,
bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge, bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
@ -190,10 +190,10 @@ void ControlToolBar::Populate()
MakeButtonBackgroundsLarge(); MakeButtonBackgroundsLarge();
mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled, mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled,
ID_PAUSE_BUTTON, true, _("Pause")); ID_PAUSE_BUTTON, true, XO("Pause"));
mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled, mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled,
ID_PLAY_BUTTON, true, _("Play")); ID_PLAY_BUTTON, true, XO("Play"));
MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled); MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled);
MakeAlternateImages(*mPlay, 2, MakeAlternateImages(*mPlay, 2,
bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled); bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled);
@ -204,16 +204,16 @@ void ControlToolBar::Populate()
mPlay->FollowModifierKeys(); mPlay->FollowModifierKeys();
mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled , mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled ,
ID_STOP_BUTTON, false, _("Stop")); ID_STOP_BUTTON, false, XO("Stop"));
mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled, mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled,
ID_REW_BUTTON, false, _("Skip to Start")); ID_REW_BUTTON, false, XO("Skip to Start"));
mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled, mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled,
ID_FF_BUTTON, false, _("Skip to End")); ID_FF_BUTTON, false, XO("Skip to End"));
mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled, mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled,
ID_RECORD_BUTTON, false, _("Record")); ID_RECORD_BUTTON, false, XO("Record"));
bool bPreferNewTrack; bool bPreferNewTrack;
gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false); gPrefs->Read("/GUI/PreferNewTrackRecord",&bPreferNewTrack, false);

View File

@ -88,7 +88,7 @@ class ControlToolBar final : public ToolBar {
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, int id,
bool processdownevents, bool processdownevents,
const wxChar *label); const TranslatableString &label);
static static
void MakeAlternateImages(AButton &button, int idx, void MakeAlternateImages(AButton &button, int idx,

View File

@ -104,7 +104,7 @@ AButton *EditToolBar::AddButton(
EditToolBar *pBar, EditToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, int id,
const wxChar *label, const TranslatableString &label,
bool toggle) bool toggle)
{ {
AButton *&r = pBar->mButtons[id]; AButton *&r = pBar->mButtons[id];
@ -134,28 +134,28 @@ void EditToolBar::Populate()
/* Buttons */ /* Buttons */
// Tooltips slightly more verbose than the menu entries are. // Tooltips slightly more verbose than the menu entries are.
AddButton(this, bmpCut, bmpCut, bmpCutDisabled, ETBCutID, AddButton(this, bmpCut, bmpCut, bmpCutDisabled, ETBCutID,
_("Cut selection")); XO("Cut selection"));
AddButton(this, bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID, AddButton(this, bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID,
_("Copy selection")); XO("Copy selection"));
AddButton(this, bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID, AddButton(this, bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID,
_("Paste")); XO("Paste"));
AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID, AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
_("Trim audio outside selection")); XO("Trim audio outside selection"));
AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID, AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
_("Silence audio selection")); XO("Silence audio selection"));
AddSeparator(); AddSeparator();
AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID, AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
_("Undo")); XO("Undo"));
AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID, AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
_("Redo")); XO("Redo"));
AddSeparator(); AddSeparator();
#ifdef OPTION_SYNC_LOCK_BUTTON #ifdef OPTION_SYNC_LOCK_BUTTON
AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID, AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
_("Sync-Lock Tracks"), true); XO("Sync-Lock Tracks"), true);
AddSeparator(); AddSeparator();
#endif #endif
@ -163,17 +163,17 @@ void EditToolBar::Populate()
// Tooltips match menu entries. // Tooltips match menu entries.
// We previously had longer tooltips which were not more clear. // We previously had longer tooltips which were not more clear.
AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID, AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
_("Zoom In")); XO("Zoom In"));
AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID, AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
_("Zoom Out")); XO("Zoom Out"));
AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID, AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
_("Zoom to Selection")); XO("Zoom to Selection"));
AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID, AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
_("Fit to Width")); XO("Fit to Width"));
#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON #ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID, AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
_("Zoom Toggle")); XO("Zoom Toggle"));
#endif #endif
@ -195,7 +195,7 @@ void EditToolBar::Populate()
#if defined(EXPERIMENTAL_EFFECTS_RACK) #if defined(EXPERIMENTAL_EFFECTS_RACK)
AddSeparator(); AddSeparator();
AddButton(this, bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID, AddButton(this, bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID,
_("Show Effects Rack"), true); XO("Show Effects Rack"), true);
#endif #endif
RegenerateTooltips(); RegenerateTooltips();

View File

@ -91,7 +91,7 @@ class EditToolBar final : public ToolBar {
static AButton *AddButton( static AButton *AddButton(
EditToolBar *pBar, EditToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, const wxChar *label, bool toggle = false); int id, const TranslatableString &label, bool toggle = false);
void AddSeparator(); void AddSeparator();

View File

@ -89,7 +89,7 @@ AButton *ScrubbingToolBar::AddButton
(ScrubbingToolBar *pBar, (ScrubbingToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, int id,
const wxChar *label, const TranslatableString &label,
bool toggle) bool toggle)
{ {
AButton *&r = pBar->mButtons[id]; AButton *&r = pBar->mButtons[id];
@ -119,12 +119,12 @@ void ScrubbingToolBar::Populate()
/* Buttons */ /* Buttons */
AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID, AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
_("Scrub"), true); XO("Scrub"), true);
AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID, AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
_("Seek"), true); XO("Seek"), true);
AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler, AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
STBRulerID, STBRulerID,
_("Scrub Ruler"), true); XO("Scrub Ruler"), true);
RegenerateTooltips(); RegenerateTooltips();

View File

@ -62,7 +62,7 @@ private:
static AButton *AddButton( static AButton *AddButton(
ScrubbingToolBar *pBar, ScrubbingToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, const wxChar *label, bool toggle = false); int id, const TranslatableString &label, bool toggle = false);
void MakeButtons(); void MakeButtons();

View File

@ -173,7 +173,7 @@ void ToolsToolBar::UpdatePrefs()
AButton * ToolsToolBar::MakeTool( AButton * ToolsToolBar::MakeTool(
ToolsToolBar *pBar, teBmps eTool, ToolsToolBar *pBar, teBmps eTool,
int id, const wxChar *label) int id, const TranslatableString &label)
{ {
AButton *button = ToolBar::MakeButton(pBar, AButton *button = ToolBar::MakeButton(pBar,
bmpRecoloredUpSmall, bmpRecoloredUpSmall,
@ -198,12 +198,12 @@ void ToolsToolBar::Populate()
/* Tools */ /* Tools */
using namespace ToolCodes; using namespace ToolCodes;
mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, _("Selection Tool") ); mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, XO("Selection Tool") );
mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, _("Envelope Tool") ); mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, XO("Envelope Tool") );
mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, _("Draw Tool") ); mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, XO("Draw Tool") );
mTool[ zoomTool ] = MakeTool( this, bmpZoom, zoomTool, _("Zoom Tool") ); mTool[ zoomTool ] = MakeTool( this, bmpZoom, zoomTool, XO("Zoom Tool") );
mTool[ slideTool ] = MakeTool( this, bmpTimeShift, slideTool, _("Slide Tool") ); mTool[ slideTool ] = MakeTool( this, bmpTimeShift, slideTool, XO("Slide Tool") );
mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, _("Multi Tool") ); mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, XO("Multi Tool") );
mTool[mCurrentTool]->PushDown(); mTool[mCurrentTool]->PushDown();

View File

@ -63,7 +63,7 @@ class ToolsToolBar final : public ToolBar {
void RegenerateTooltips() override; void RegenerateTooltips() override;
wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style); wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style);
static AButton *MakeTool( static AButton *MakeTool(
ToolsToolBar *pBar, teBmps eTool, int id, const wxChar *label); ToolsToolBar *pBar, teBmps eTool, int id, const TranslatableString &label);
enum { numTools = 6 }; enum { numTools = 6 };
AButton *mTool[numTools]; AButton *mTool[numTools];

View File

@ -167,7 +167,7 @@ AButton *TranscriptionToolBar::AddButton(
TranscriptionToolBar *pBar, TranscriptionToolBar *pBar,
teBmps eFore, teBmps eDisabled, teBmps eFore, teBmps eDisabled,
int id, int id,
const wxChar *label) const TranslatableString &label)
{ {
AButton *&r = pBar->mButtons[id]; AButton *&r = pBar->mButtons[id];
@ -206,7 +206,7 @@ void TranscriptionToolBar::Populate()
MakeButtonBackgroundsSmall(); MakeButtonBackgroundsSmall();
AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed, AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
_("Play at selected speed")); XO("Play at selected speed"));
MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1); MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1);
MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2); MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
mButtons[TTB_PlaySpeed]->FollowModifierKeys(); mButtons[TTB_PlaySpeed]->FollowModifierKeys();
@ -238,7 +238,7 @@ void TranscriptionToolBar::Populate()
#ifdef EXPERIMENTAL_VOICE_DETECTION #ifdef EXPERIMENTAL_VOICE_DETECTION
// If we need these strings translated, then search and replace // If we need these strings translated, then search and replace
// TRANSLATBLE by _ and remove this #define. // TRANSLATBLE by _ and remove this #define.
#define TRANSLATABLE( x ) wxT( x ) #define TRANSLATABLE( x ) Verbatim( x )
AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn, AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
TRANSLATABLE("Adjust left selection to next onset")); TRANSLATABLE("Adjust left selection to next onset"));
AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn, AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,

View File

@ -126,7 +126,7 @@ class TranscriptionToolBar final : public ToolBar {
TranscriptionToolBar *pBar, TranscriptionToolBar *pBar,
teBmps eFore, teBmps eDisabled, teBmps eFore, teBmps eDisabled,
int id, int id,
const wxChar *label); const TranslatableString &label);
void MakeAlternateImages( void MakeAlternateImages(
teBmps eFore, teBmps eDisabled, teBmps eFore, teBmps eDisabled,
int id, unsigned altIdx); int id, unsigned altIdx);

View File

@ -285,9 +285,14 @@ void AButton::UseDisabledAsDownHiliteImage(bool flag)
mUseDisabledAsDownHiliteImage = flag; mUseDisabledAsDownHiliteImage = flag;
} }
void AButton::SetToolTip( TranslatableString toolTip ) void AButton::SetToolTip( const TranslatableString &toolTip )
{ {
wxWindow::SetToolTip( toolTip.Strip().Translation() ); wxWindow::SetToolTip( toolTip.Stripped().Translation() );
}
void AButton::SetLabel( const TranslatableString &toolTip )
{
wxWindow::SetLabel( toolTip.Stripped().Translation() );
} }
// This compensates for a but in wxWidgets 3.0.2 for mac: // This compensates for a but in wxWidgets 3.0.2 for mac:

View File

@ -56,9 +56,12 @@ class AButton final : public wxWindow {
virtual ~ AButton(); virtual ~ AButton();
// overload and hide the inherited function that takes naked wxString: // hide the inherited function that takes naked wxString:
void SetToolTip(TranslatableString toolTip); void SetToolTip(const TranslatableString &toolTip);
// hide the inherited function that takes naked wxString:
void SetLabel(const TranslatableString &label);
bool AcceptsFocus() const override { return s_AcceptsFocus; } bool AcceptsFocus() const override { return s_AcceptsFocus; }
bool AcceptsFocusFromKeyboard() const override { return mEnabled; } bool AcceptsFocusFromKeyboard() const override { return mEnabled; }