Prompt the user for confirmation before removing an export format.
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>
Wed, 19 Jun 2013 16:52:06 +0000 (18:52 +0200)
committerAdrian Knoth <adi@drcomp.erfurt.thur.de>
Wed, 19 Jun 2013 16:52:06 +0000 (18:52 +0200)
Requested by Radio SRB (http://srb.fm)

gtk2_ardour/export_format_selector.cc
gtk2_ardour/export_format_selector.h

index f66d13d62e67bd24644445797118f8ecfca48eee..a2ba3f352f8e502df7fa79457ad3333a1432072f 100644 (file)
@@ -43,7 +43,7 @@ ExportFormatSelector::ExportFormatSelector () :
        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 */
@@ -122,7 +122,7 @@ 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 ();
                }
@@ -130,11 +130,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);
 }
 
index 9533b15d9b3163fa633848ace5993d0f8c2ac2e2..4af647ac9c8e8355f57b29df142e0778a5465ba9 100644 (file)
@@ -63,7 +63,7 @@ class ExportFormatSelector : public Gtk::HBox, public ARDOUR::SessionHandlePtr
 
        void select_format (FormatPtr f);
        void add_new_format ();
-       void remove_format ();
+       void remove_format (bool called_from_button = false);
        int open_edit_dialog (bool new_dialog = false);
        void update_format_combo ();
        void update_format_description ();