use new method in MidiPatchManager to use MIDNAM data when setting a MidiTimeAxisView
[ardour.git] / gtk2_ardour / export_format_selector.cc
index f66d13d62e67bd24644445797118f8ecfca48eee..f2d2b5b15775fb9a27e470d4a18958b0402c1ae0 100644 (file)
@@ -1,31 +1,33 @@
 /*
-    Copyright (C) 2008 Paul Davis
-    Author: Sakari Bergen
+ * Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2008 Sakari Bergen <sakari.bergen@beatwaves.net>
+ * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/stock.h>
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+#include "ardour/export_format_specification.h"
+#include "ardour/export_profile_manager.h"
 
 #include "export_format_selector.h"
-
 #include "export_format_dialog.h"
 
-#include "ardour/export_format_specification.h"
-#include "ardour/export_profile_manager.h"
-
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 ExportFormatSelector::ExportFormatSelector () :
   edit_button (Gtk::Stock::EDIT),
@@ -37,13 +39,8 @@ ExportFormatSelector::ExportFormatSelector () :
        pack_start (remove_button, false, false, 3);
        pack_start (new_button, false, false, 3);
 
-       format_combo.set_name ("PaddedButton");
-       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 */
@@ -122,7 +119,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 +127,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);
 }
 
@@ -148,6 +160,9 @@ ExportFormatSelector::open_edit_dialog (bool new_dialog)
                update_format_description ();
                FormatEdited (state->format);
                CriticalSelectionChanged();
+       } else {
+               FormatReverted (state->format);
+               CriticalSelectionChanged();
        }
        return response;
 }