From 561a43b0513a698653a5e883e81d0acf3c0e9747 Mon Sep 17 00:00:00 2001 From: Nikolay Date: Tue, 4 Nov 2014 14:56:07 +0200 Subject: [PATCH] [Summary] file sample rate mismatch dialog rework [Reviewed] GZharun --- gtk2_ardour/editor_audio_import.cc | 35 ++++---- .../file_sample_rate_mismatch_dialog.cc | 80 +++++++++++++++++++ .../file_sample_rate_mismatch_dialog.h | 48 +++++++++++ .../macosx/tracks.xcodeproj/project.pbxproj | 10 +++ .../ui/file_sample_rate_mismatch_dialog.xml | 59 ++++++++++++++ gtk2_ardour/wscript | 1 + 6 files changed, 212 insertions(+), 21 deletions(-) create mode 100644 gtk2_ardour/file_sample_rate_mismatch_dialog.cc create mode 100644 gtk2_ardour/file_sample_rate_mismatch_dialog.h create mode 100644 gtk2_ardour/ui/file_sample_rate_mismatch_dialog.xml diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index e5ac8c6c72..1655add62f 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -45,6 +45,7 @@ #include "ardour/utils.h" #include "pbd/memento_command.h" +#include "file_sample_rate_mismatch_dialog.h" #include "ardour_ui.h" #include "editor.h" #include "sfdb_ui.h" @@ -576,27 +577,19 @@ Editor::embed_sndfiles (vector paths, bool multifile, goto out; } } else { - choices.push_back (_("Cancel")); - choices.push_back (_("Embed it anyway")); - - Gtkmm2ext::Choice rate_choice ( - _("Sample rate"), - string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path), - choices, false - ); - - int resx = rate_choice.run (); - - switch (resx) { - case 0: /* don't import */ - ret = -1; - goto out; - case 1: /* do it */ - break; - default: - ret = -2; - goto out; - } + + FileSampleRateMismatchDialog fsrm_dialog(path); + switch ( fsrm_dialog.run () ) { + case Gtk::RESPONSE_CANCEL: /* don't import */ + ret = -1; + goto out; + + case Gtk::RESPONSE_ACCEPT: /* do it */ + break; + default: + ret = -2; + goto out; + } } } diff --git a/gtk2_ardour/file_sample_rate_mismatch_dialog.cc b/gtk2_ardour/file_sample_rate_mismatch_dialog.cc new file mode 100644 index 0000000000..4517055350 --- /dev/null +++ b/gtk2_ardour/file_sample_rate_mismatch_dialog.cc @@ -0,0 +1,80 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + 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 "file_sample_rate_mismatch_dialog.h" +#include "utils.h" +#include +#include "i18n.h" + +using namespace Gtk; +using namespace Gdk; +using namespace std; +using namespace ARDOUR; +using namespace PBD; + +FileSampleRateMismatchDialog::FileSampleRateMismatchDialog ( std::string file_name ) + : WavesDialog (_("file_sample_rate_mismatch_dialog.xml"), true, false) + , _cancel_button ( get_waves_button ("cancel_button") ) + , _ignore_button ( get_waves_button ("ignore_button") ) + , _info_label_1 ( get_label("info_label_1") ) + , _info_label_2 ( get_label("info_label_2") ) +{ + set_modal (true); + set_resizable (false); + + _cancel_button.signal_clicked.connect (sigc::mem_fun (*this, &FileSampleRateMismatchDialog::cancel_button_pressed)); + _ignore_button.signal_clicked.connect (sigc::mem_fun (*this, &FileSampleRateMismatchDialog::ignore_button_pressed)); + + _info_label_1.set_text ( file_name ); + _info_label_2.set_text ( _("This audiofile's sample rate doesn't match the session sample rate!") ); + + show_all (); +} + +void +FileSampleRateMismatchDialog::on_esc_pressed () +{ + hide (); + response (Gtk::RESPONSE_CANCEL); +} + +void +FileSampleRateMismatchDialog::on_enter_pressed () +{ + hide (); + response (Gtk::RESPONSE_ACCEPT); +} + +void +FileSampleRateMismatchDialog::cancel_button_pressed (WavesButton*) +{ + hide (); + response (Gtk::RESPONSE_CANCEL); +} + +void +FileSampleRateMismatchDialog::ignore_button_pressed (WavesButton*) +{ + hide (); + response (Gtk::RESPONSE_ACCEPT); +} + +FileSampleRateMismatchDialog::~FileSampleRateMismatchDialog () +{ +} diff --git a/gtk2_ardour/file_sample_rate_mismatch_dialog.h b/gtk2_ardour/file_sample_rate_mismatch_dialog.h new file mode 100644 index 0000000000..d938193659 --- /dev/null +++ b/gtk2_ardour/file_sample_rate_mismatch_dialog.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + 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. + +*/ + +#ifndef __sample_rate_mismatch_dialog_h__ +#define __sample_rate_mismatch_dialog_h__ + +#include "waves_dialog.h" +#include "ardour_button.h" +#include +#include "utils.h" + +class FileSampleRateMismatchDialog : public WavesDialog +{ +public: + FileSampleRateMismatchDialog(std::string file_name); + ~FileSampleRateMismatchDialog(); + +protected: + void on_esc_pressed (); + void on_enter_pressed (); + +private: + void cancel_button_pressed (WavesButton*); + void ignore_button_pressed (WavesButton*); + + WavesButton& _cancel_button; + WavesButton& _ignore_button; + Gtk::Label& _info_label_1; + Gtk::Label& _info_label_2; +}; + +#endif /* __sample_rate_mismatch_dialog_h__ */ diff --git a/gtk2_ardour/macosx/tracks.xcodeproj/project.pbxproj b/gtk2_ardour/macosx/tracks.xcodeproj/project.pbxproj index f77ed78114..bb8c84d75d 100644 --- a/gtk2_ardour/macosx/tracks.xcodeproj/project.pbxproj +++ b/gtk2_ardour/macosx/tracks.xcodeproj/project.pbxproj @@ -269,6 +269,8 @@ 43279460194F0062003C9FEA /* tracks_preferences.xml in Resources */ = {isa = PBXBuildFile; fileRef = 43279430194F0062003C9FEA /* tracks_preferences.xml */; }; 4327947F194F009E003C9FEA /* tracks.menus.in in Resources */ = {isa = PBXBuildFile; fileRef = 43279475194F009E003C9FEA /* tracks.menus.in */; }; 43B351ED194F04E00038C140 /* step_editing.bindings in Resources */ = {isa = PBXBuildFile; fileRef = 43B351C0194F04E00038C140 /* step_editing.bindings */; }; + 95176F7A1A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */; }; + 95176F7E1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */; }; 954DCFBD1A0239DA00B7160E /* about_dialog.cc in Sources */ = {isa = PBXBuildFile; fileRef = 954DCFBC1A0239DA00B7160E /* about_dialog.cc */; }; 954DCFC11A023AAB00B7160E /* about_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 954DCFBF1A023AAB00B7160E /* about_dialog.xml */; }; 954DCFC21A023AAB00B7160E /* license_dialog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 954DCFC01A023AAB00B7160E /* license_dialog.xml */; }; @@ -1119,6 +1121,9 @@ 43B351EE194F12FB0038C140 /* waves_audiobackend.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = waves_audiobackend.xcodeproj; path = ../../libs/backends/wavesaudio/macosx/waves_audiobackend.xcodeproj; sourceTree = ""; }; 43B351F4194F130C0038C140 /* libardour.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libardour.xcodeproj; path = ../../libs/ardour/macosx/libardour.xcodeproj; sourceTree = ""; }; 43B351FA194F131D0038C140 /* pbd.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = pbd.xcodeproj; path = ../../libs/pbd/macosx/pbd.xcodeproj; sourceTree = ""; }; + 95176F781A08E6D800E32046 /* file_sample_rate_mismatch_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = file_sample_rate_mismatch_dialog.h; path = ../file_sample_rate_mismatch_dialog.h; sourceTree = ""; }; + 95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = file_sample_rate_mismatch_dialog.cc; path = ../file_sample_rate_mismatch_dialog.cc; sourceTree = ""; }; + 95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = file_sample_rate_mismatch_dialog.xml; sourceTree = ""; }; 954DCFBC1A0239DA00B7160E /* about_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = about_dialog.cc; path = ../about_dialog.cc; sourceTree = ""; }; 954DCFBE1A0239EC00B7160E /* about_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = about_dialog.h; path = ../about_dialog.h; sourceTree = ""; }; 954DCFBF1A023AAB00B7160E /* about_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = about_dialog.xml; sourceTree = ""; }; @@ -1217,6 +1222,7 @@ 43279040194EFF38003C9FEA /* source */ = { isa = PBXGroup; children = ( + 95176F791A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc */, 954DCFE01A07C70400B7160E /* sample_rate_mismatch_dialog.cc */, 954DCFDB1A07A07600B7160E /* read_only_session_dialog.cc */, 954DCFBC1A0239DA00B7160E /* about_dialog.cc */, @@ -1822,6 +1828,7 @@ 43279429194F0062003C9FEA /* ui */ = { isa = PBXGroup; children = ( + 95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */, 954DCFE41A07D1C800B7160E /* sample_rate_mismatch_dialog.xml */, 954DCFDD1A07A14E00B7160E /* read_only_session_dialog.xml */, 954DCFBF1A023AAB00B7160E /* about_dialog.xml */, @@ -1868,6 +1875,7 @@ 43279480194F00CB003C9FEA /* headers */ = { isa = PBXGroup; children = ( + 95176F781A08E6D800E32046 /* file_sample_rate_mismatch_dialog.h */, 954DCFDF1A07C6F200B7160E /* sample_rate_mismatch_dialog.h */, 954DCFD71A07A06300B7160E /* read_only_session_dialog.h */, 954DCFBE1A0239EC00B7160E /* about_dialog.h */, @@ -2445,6 +2453,7 @@ 432793D2194F003A003C9FEA /* tool_waveform_zoom_active.png in Resources */, 432793D3194F003A003C9FEA /* tool_waveform_zoom_prelight.png in Resources */, 432793D4194F003A003C9FEA /* tool_zoom.png in Resources */, + 95176F7E1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml in Resources */, 432793D5194F003A003C9FEA /* tool_zoom_active.png in Resources */, 432793D6194F003A003C9FEA /* tool_zoom_ardour.png in Resources */, 432793D7194F003A003C9FEA /* tool_zoom_prelight.png in Resources */, @@ -2578,6 +2587,7 @@ CE1C6DE01987A924006BDB03 /* master_bus_ui.cc in Sources */, 954DCFBD1A0239DA00B7160E /* about_dialog.cc in Sources */, CE1A907A199A37AE00ECA62B /* add_tracks_dialog.cc in Sources */, + 95176F7A1A08E6E800E32046 /* file_sample_rate_mismatch_dialog.cc in Sources */, CE294C7519CAD54500D12768 /* marker_io_dialog.cc in Sources */, CE294C7619CAD54500D12768 /* mixer_bridge_view.cc in Sources */, CE294C7719CAD54500D12768 /* open_file_dialog_nix.cc in Sources */, diff --git a/gtk2_ardour/ui/file_sample_rate_mismatch_dialog.xml b/gtk2_ardour/ui/file_sample_rate_mismatch_dialog.xml new file mode 100644 index 0000000000..e641fef3d8 --- /dev/null +++ b/gtk2_ardour/ui/file_sample_rate_mismatch_dialog.xml @@ -0,0 +1,59 @@ + + + +