Restore state of analyze and soundcloud upload checkboxes in ExportDialog

This should be a proper fix for bug #7003, now that I've spent a bit more time
reading the code. The options are now stored as part of the export format
state.
This commit is contained in:
Tim Mayberry 2016-09-14 20:00:29 +10:00
parent b66d5e842b
commit 1ee63d2610
2 changed files with 31 additions and 37 deletions

View File

@ -112,53 +112,27 @@ ExportFileNotebook::update_soundcloud_upload ()
soundcloud_export_selector->set_visible (show_credentials_entry);
}
void
ExportFileNotebook::FilePage::on_show ()
{
VBox::on_show ();
restore_state ();
}
void
ExportFileNotebook::FilePage::on_hide ()
{
VBox::on_hide ();
store_state ();
if (save_format_on_hide) {
profile_manager->save_format_to_disk (format_state->format);
save_format_on_hide = false;
}
}
void
ExportFileNotebook::FilePage::analysis_changed ()
{
format_state->format->set_analyse (analysis_button.get_active ());
save_format_on_hide = true;
}
void
ExportFileNotebook::FilePage::store_state ()
ExportFileNotebook::FilePage::update_analysis_button ()
{
XMLNode node (X_("ExportFile"));
node.add_property ("analyze-audio", analysis_button.get_active () ? "yes" : "no");
node.add_property ("soundcloud-upload", soundcloud_upload_button.get_active () ? "yes" : "no");
Config->add_instant_xml (node);
}
void
ExportFileNotebook::FilePage::restore_state ()
{
XMLNode* node = Config->instant_xml (X_("ExportFile"));
if (!node) {
return;
}
XMLProperty const* prop;
if ((prop = node->property ("analyze-audio")) != 0) {
analysis_button.set_active (string_is_affirmative (prop->value()));
}
if ((prop = node->property ("soundcloud-upload")) != 0) {
soundcloud_upload_button.set_active (string_is_affirmative (prop->value()));
}
analysis_button.set_active (format_state->format->analyse());
}
void
@ -242,7 +216,8 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
filename_label (_("Location"), Gtk::ALIGN_LEFT),
soundcloud_upload_button (_("Upload to Soundcloud")),
analysis_button (_("Analyze Exported Audio")),
tab_number (number)
tab_number (number),
save_format_on_hide(false)
{
set_border_width (12);
@ -275,6 +250,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
format_selector.set_state (format_state, s);
filename_selector.set_state (filename_state, s);
analysis_button.set_active (format_state->format->analyse());
soundcloud_upload_button.set_active (format_state->format->soundcloud_upload());
/* Signals */
@ -292,6 +268,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
sigc::mem_fun (*this, &ExportFileNotebook::FilePage::critical_selection_changed));
soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*parent, &ExportFileNotebook::update_soundcloud_upload));
soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::soundcloud_upload_changed));
analysis_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::analysis_changed));
/* Tab widget */
@ -335,6 +312,18 @@ ExportFileNotebook::FilePage::get_soundcloud_upload () const
return soundcloud_upload_button.get_active ();
}
void
ExportFileNotebook::FilePage::soundcloud_upload_changed ()
{
save_format_on_hide = true;
}
void
ExportFileNotebook::FilePage::update_soundcloud_upload_button ()
{
soundcloud_upload_button.set_active (format_state->format->soundcloud_upload());
}
void
ExportFileNotebook::FilePage::save_format_to_manager (FormatPtr format)
{
@ -377,5 +366,7 @@ ExportFileNotebook::FilePage::critical_selection_changed ()
{
update_tab_label();
update_example_filename();
update_analysis_button();
update_soundcloud_upload_button();
CriticalSelectionChanged();
}

View File

@ -85,6 +85,9 @@ class ExportFileNotebook : public Gtk::Notebook, public ARDOUR::SessionHandlePtr
void update_example_filename();
void update_analysis_button ();
void update_soundcloud_upload_button ();
ARDOUR::ExportProfileManager::FormatStatePtr get_format_state () const { return format_state; }
ARDOUR::ExportProfileManager::FilenameStatePtr get_filename_state () const { return filename_state; }
@ -95,11 +98,9 @@ class ExportFileNotebook : public Gtk::Notebook, public ARDOUR::SessionHandlePtr
void update_tab_label ();
void critical_selection_changed ();
void analysis_changed ();
void soundcloud_upload_changed ();
void on_show ();
void on_hide ();
void store_state ();
void restore_state ();
ARDOUR::ExportProfileManager::FormatStatePtr format_state;
ARDOUR::ExportProfileManager::FilenameStatePtr filename_state;
@ -123,6 +124,8 @@ class ExportFileNotebook : public Gtk::Notebook, public ARDOUR::SessionHandlePtr
Gtk::Alignment tab_close_alignment;
Gtk::Button tab_close_button;
uint32_t tab_number;
bool save_format_on_hide;
};
};