mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-22 14:32:58 +02:00
Locate and position the current Audacity source code, and clear a variety of old junk out of the way into junk-branches
This commit is contained in:
88
src/commands/SetTrackInfoCommand.cpp
Normal file
88
src/commands/SetTrackInfoCommand.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity - A Digital Audio Editor
|
||||
Copyright 1999-2009 Audacity Team
|
||||
License: wxwidgets
|
||||
|
||||
Dan Horgan
|
||||
|
||||
******************************************************************//**
|
||||
|
||||
\file SetTrackInfoCommand.cpp
|
||||
\brief Definitions for SetTrackInfoCommand and SetTrackInfoCommandType classes
|
||||
|
||||
\class SetTrackInfoCommand
|
||||
\brief Command that sets track information (currently name only)
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "SetTrackInfoCommand.h"
|
||||
#include "../Project.h"
|
||||
#include "../Track.h"
|
||||
|
||||
wxString SetTrackInfoCommandType::BuildName()
|
||||
{
|
||||
return wxT("SetTrackInfo");
|
||||
}
|
||||
|
||||
void SetTrackInfoCommandType::BuildSignature(CommandSignature &signature)
|
||||
{
|
||||
IntValidator *trackIndexValidator = new IntValidator();
|
||||
signature.AddParameter(wxT("TrackIndex"), 0, trackIndexValidator);
|
||||
|
||||
OptionValidator *infoTypeValidator = new OptionValidator();
|
||||
infoTypeValidator->AddOption(wxT("Name"));
|
||||
signature.AddParameter(wxT("Type"), wxT("Name"), infoTypeValidator);
|
||||
Validator *nameValidator = new Validator();
|
||||
signature.AddParameter(wxT("Name"), wxT("Unnamed"), nameValidator);
|
||||
}
|
||||
|
||||
Command *SetTrackInfoCommandType::Create(CommandOutputTarget *target)
|
||||
{
|
||||
return new SetTrackInfoCommand(*this, target);
|
||||
}
|
||||
|
||||
bool SetTrackInfoCommand::Apply(CommandExecutionContext context)
|
||||
{
|
||||
wxString mode = GetString(wxT("Type"));
|
||||
|
||||
long trackIndex = GetLong(wxT("TrackIndex"));
|
||||
|
||||
// (Note: track selection ought to be somewhere else)
|
||||
long i = 0;
|
||||
TrackListIterator iter(context.proj->GetTracks());
|
||||
Track *t = iter.First();
|
||||
while (t && i != trackIndex)
|
||||
{
|
||||
t = iter.Next();
|
||||
++i;
|
||||
}
|
||||
if (i != trackIndex || !t)
|
||||
{
|
||||
Error(wxT("TrackIndex was invalid."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode.IsSameAs(wxT("Name")))
|
||||
{
|
||||
wxString name = GetString(wxT("Name"));
|
||||
t->SetName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(wxT("Invalid info type!"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
|
||||
// version control system. Please do not modify past this point.
|
||||
//
|
||||
// Local Variables:
|
||||
// c-basic-offset: 3
|
||||
// indent-tabs-mode: nil
|
||||
// End:
|
||||
//
|
||||
// vim: et sts=3 sw=3
|
||||
// arch-tag: TBD
|
Reference in New Issue
Block a user