X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fexport_format_selector.cc;h=dbc74908d1e3469ae429a3065e28e0dbdf39486e;hb=38e94875647782fa6c28e25be471f0cff6c97d2a;hp=6032b495de54101341000e41a9bed3dea85bc1c6;hpb=41c892802f75e62e452399f0b1c7319fee61e677;p=ardour.git diff --git a/gtk2_ardour/export_format_selector.cc b/gtk2_ardour/export_format_selector.cc index 6032b495de..dbc74908d1 100644 --- a/gtk2_ardour/export_format_selector.cc +++ b/gtk2_ardour/export_format_selector.cc @@ -17,16 +17,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include -#include "export_format_selector.h" +#include "ardour/export_format_specification.h" +#include "ardour/export_profile_manager.h" +#include "export_format_selector.h" #include "export_format_dialog.h" -#include -#include -#include - -#include "i18n.h" +#include "pbd/i18n.h" ExportFormatSelector::ExportFormatSelector () : edit_button (Gtk::Stock::EDIT), @@ -38,21 +38,18 @@ ExportFormatSelector::ExportFormatSelector () : pack_start (remove_button, false, false, 3); pack_start (new_button, false, false, 3); - edit_button.set_name ("PaddedButton"); - remove_button.set_name ("PaddedButton"); - new_button.set_name ("PaddedButton"); - edit_button.signal_clicked().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &ExportFormatSelector::open_edit_dialog), false))); - remove_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatSelector::remove_format)); + remove_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &ExportFormatSelector::remove_format), true)); new_button.signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatSelector::add_new_format)); - + /* Format combo */ - + format_list = Gtk::ListStore::create (format_cols); + format_list->set_sort_column (format_cols.label, Gtk::SORT_ASCENDING); format_combo.set_model (format_list); format_combo.pack_start (format_cols.label); format_combo.set_active (0); - + format_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatSelector::update_format_combo)); } @@ -64,9 +61,10 @@ ExportFormatSelector::~ExportFormatSelector () void ExportFormatSelector::set_state (ARDOUR::ExportProfileManager::FormatStatePtr const state_, ARDOUR::Session * session_) { - session = session_; + SessionHandlePtr::set_session (session_); + state = state_; - + update_format_list (); } @@ -93,10 +91,10 @@ ExportFormatSelector::update_format_list () tree_it->set_value (format_cols.label, (*it)->description()); } - if (format_combo.get_active_row_number() == -1) { + if (format_combo.get_active_row_number() == -1 && format_combo.get_model()->children().size() > 0) { format_combo.set_active (0); } - + select_format (format_to_select); } @@ -110,7 +108,7 @@ ExportFormatSelector::select_format (FormatPtr f) break; } } - + CriticalSelectionChanged(); } @@ -118,9 +116,9 @@ void ExportFormatSelector::add_new_format () { FormatPtr new_format = state->format = NewFormat (state->format); - + if (open_edit_dialog (true) != Gtk::RESPONSE_APPLY) { - remove_format(); + remove_format(false); if (state->list->empty()) { state->format.reset (); } @@ -128,11 +126,26 @@ ExportFormatSelector::add_new_format () } void -ExportFormatSelector::remove_format () +ExportFormatSelector::remove_format (bool called_from_button) { + if (called_from_button) { + Gtk::MessageDialog dialog (_("Do you really want to remove the format?"), + false, + Gtk::MESSAGE_QUESTION, + Gtk::BUTTONS_YES_NO); + + if (Gtk::RESPONSE_YES != dialog.run ()) { + /* User has selected "no" or closed the dialog, better + * abort + */ + return; + } + } + FormatPtr remove; Gtk::TreeModel::iterator it = format_combo.get_active(); remove = it->get_value (format_cols.format); + FormatRemoved (remove); } @@ -140,7 +153,7 @@ int ExportFormatSelector::open_edit_dialog (bool new_dialog) { ExportFormatDialog dialog (state->format, new_dialog); - dialog.set_session (session); + dialog.set_session (_session); Gtk::ResponseType response = (Gtk::ResponseType) dialog.run(); if (response == Gtk::RESPONSE_APPLY) { update_format_description (); @@ -162,7 +175,7 @@ ExportFormatSelector::update_format_combo () edit_button.set_sensitive (false); remove_button.set_sensitive (false); } - + CriticalSelectionChanged(); }