13
0

Properly create new presets, i.e. without duplicate id's on save-after-rename

git-svn-id: svn://localhost/ardour2/branches/3.0@9132 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sakari Bergen 2011-03-12 21:28:58 +00:00
parent 72928df58f
commit 751cc84dd2
4 changed files with 32 additions and 3 deletions

View File

@ -51,7 +51,7 @@ ExportPresetSelector::ExportPresetSelector () :
select_connection = entry.signal_changed().connect (sigc::mem_fun (*this, &ExportPresetSelector::update_selection));
save_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportPresetSelector::save_current));
new_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportPresetSelector::save_current));
new_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportPresetSelector::create_new));
remove_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportPresetSelector::remove_current));
show_all_children ();
@ -127,6 +127,16 @@ ExportPresetSelector::update_selection ()
new_button.set_sensitive (!current && !text.empty() && !preset_name_exists);
}
void
ExportPresetSelector::create_new ()
{
if (!profile_manager) { return; }
previous = current = profile_manager->new_preset (entry.get_entry()->get_text());
sync_with_manager ();
update_selection (); // Update preset widget states
}
void
ExportPresetSelector::save_current ()
{

View File

@ -48,6 +48,7 @@ class ExportPresetSelector : public Gtk::HBox
void sync_with_manager ();
void update_selection ();
void create_new ();
void save_current ();
void remove_current ();

View File

@ -66,6 +66,7 @@ class ExportProfileManager
PresetList const & get_presets () { return preset_list; }
bool load_preset (PresetPtr preset);
PresetPtr new_preset (std::string const & name);
PresetPtr save_preset (std::string const & name);
void remove_preset ();
@ -79,6 +80,7 @@ class ExportProfileManager
HandlerPtr handler;
Session & session;
std::string preset_filename (std::string const & preset_name);
void load_presets ();
void load_preset_from_disk (PBD::sys::path const & path);

View File

@ -181,11 +181,27 @@ ExportProfileManager::load_presets ()
}
}
std::string
ExportProfileManager::preset_filename (std::string const & preset_name)
{
string safe_name = legalize_for_path (preset_name);
return export_config_dir.to_string() + "/" + safe_name + export_preset_suffix;
}
ExportProfileManager::PresetPtr
ExportProfileManager::new_preset (string const & name)
{
// Generate new ID and do regular save
string filename = preset_filename (name);
current_preset.reset (new ExportPreset (filename, session));
preset_list.push_back (current_preset);
return save_preset (name);
}
ExportProfileManager::PresetPtr
ExportProfileManager::save_preset (string const & name)
{
string safe_name = legalize_for_path (name);
string filename = export_config_dir.to_string() + "/" + safe_name + export_preset_suffix;
string filename = preset_filename (name);
if (!current_preset) {
current_preset.reset (new ExportPreset (filename, session));