Also use overwrite_file_dialog at all the other places.
authorAndré Nusser <andre.nusser@googlemail.com>
Mon, 12 Oct 2015 11:01:05 +0000 (13:01 +0200)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 22 Oct 2015 03:28:44 +0000 (23:28 -0400)
gtk2_ardour/editor_export_audio.cc
gtk2_ardour/utils_videotl.cc

index 57baf2ce2d17f3de0c9c8b977964eb174c3a7064..c886885dd23849fd6fa5652620bd0e6316748c69 100644 (file)
@@ -51,6 +51,7 @@
 #include "public_editor.h"
 #include "selection.h"
 #include "time_axis_view.h"
+#include "utils.h"
 
 #include "i18n.h"
 
@@ -141,35 +142,18 @@ Editor::export_region ()
                string path = dialog.get_path ();
 
                if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
+                       bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (_("Confirm MIDI File Overwrite"),
+                                                                                _("A file with the same name already exists. Do you want to overwrite it?"));
 
-                       MessageDialog checker (_("File Exists!"),
-                                              true,
-                                              Gtk::MESSAGE_WARNING,
-                                              Gtk::BUTTONS_NONE);
-
-                       checker.set_title (_("File Exists!"));
-
-                       checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
-                       checker.add_button (_("Overwrite Existing File"), RESPONSE_ACCEPT);
-                       checker.set_default_response (RESPONSE_CANCEL);
-
-                       checker.set_wmclass (X_("midi_export_file_exists"), PROGRAM_NAME);
-                       checker.set_position (Gtk::WIN_POS_MOUSE);
-
-                       ret = checker.run ();
-
-                       switch (ret) {
-                       case Gtk::RESPONSE_ACCEPT:
-                               /* force ::g_unlink because the backend code will
-                                  go wrong if it tries to open an existing
-                                  file for writing.
-                               */
-                               ::g_unlink (path.c_str());
-                               break;
-                       default:
+                       if (!overwrite) {
                                return;
                        }
 
+                       /* force ::g_unlink because the backend code will
+                          go wrong if it tries to open an existing
+                          file for writing.
+                       */
+                       ::g_unlink (path.c_str());
                }
 
                (void) midi_region->clone (path);
index 51cbe1a1dded7b295af7c3c735e8767011e6d0b1..0c94f378f02bfa9ac3376cfc2d3507a252af1de7 100644 (file)
@@ -28,6 +28,7 @@
 #include "ardour/session_directory.h"
 #include "video_image_frame.h"
 #include "utils_videotl.h"
+#include "utils.h"
 
 #ifdef WAF_BUILD
 #include "gtk2ardour-version.h"
@@ -67,13 +68,12 @@ VideoUtils::confirm_video_outfn (std::string outfn, std::string docroot)
        }
 
        if (Glib::file_test(outfn, Glib::FILE_TEST_EXISTS)) {
-               ArdourDialog confirm (_("Confirm Overwrite"), true);
-               Label m (_("A file with the same name already exists.  Do you want to overwrite it?"));
-               confirm.get_vbox()->pack_start (m, true, true);
-               confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-               confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
-               confirm.show_all ();
-               if (confirm.run() == RESPONSE_CANCEL) { return false; }
+               bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (_("Confirm Overwrite"),
+                                                                        _("A file with the same name already exists. Do you want to overwrite it?"));
+
+               if (!overwrite) {
+                       return false;
+               }
        }
 
        std::string dir = Glib::path_get_dirname (outfn);