1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 08:38:39 +02:00
audacity/src/commands/PreferenceCommands.cpp
martynshaw99 4ce2643d5f Remove the
// Indentation settings for Vim and Emacs
etc. lines from all files, as Campbell's patch (except for other changes to Languages.cpp)
2013-09-24 00:14:37 +00:00

82 lines
2.1 KiB
C++

/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2009 Audacity Team
File License: wxWidgets
Dan Horgan
******************************************************************//**
\file PreferenceCommands.cpp
\brief Contains definitions for the GetPreferenceCommand and
SetPreferenceCommand classes
*//*******************************************************************/
#include "PreferenceCommands.h"
#include "../Prefs.h"
// GetPreference
wxString GetPreferenceCommandType::BuildName()
{
return wxT("GetPreference");
}
void GetPreferenceCommandType::BuildSignature(CommandSignature &signature)
{
Validator *prefNameValidator(new Validator());
signature.AddParameter(wxT("PrefName"), wxT(""), prefNameValidator);
}
Command *GetPreferenceCommandType::Create(CommandOutputTarget *target)
{
return new GetPreferenceCommand(*this, target);
}
bool GetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context))
{
wxString prefName = GetString(wxT("PrefName"));
wxString prefValue;
if (!gPrefs->Read(prefName, &prefValue))
{
return false;
}
Status(prefValue);
return true;
}
GetPreferenceCommand::~GetPreferenceCommand()
{ }
// SetPreference
wxString SetPreferenceCommandType::BuildName()
{
return wxT("SetPreference");
}
void SetPreferenceCommandType::BuildSignature(CommandSignature &signature)
{
Validator *prefNameValidator(new Validator());
signature.AddParameter(wxT("PrefName"), wxT(""), prefNameValidator);
Validator *prefValueValidator(new Validator());
signature.AddParameter(wxT("PrefValue"), wxT(""), prefValueValidator);
}
Command *SetPreferenceCommandType::Create(CommandOutputTarget *target)
{
return new SetPreferenceCommand(*this, target);
}
bool SetPreferenceCommand::Apply(CommandExecutionContext WXUNUSED(context))
{
wxString prefName = GetString(wxT("PrefName"));
wxString prefValue = GetString(wxT("PrefValue"));
return (gPrefs->Write(prefName, prefValue) && gPrefs->Flush());
}
SetPreferenceCommand::~SetPreferenceCommand()
{ }