[Summary] file sample rate mismatch dialog rework
authorNikolay <MPolianovskyi@wavesglobal.com>
Tue, 4 Nov 2014 12:56:07 +0000 (14:56 +0200)
committerNikolay <MPolianovskyi@wavesglobal.com>
Tue, 4 Nov 2014 12:56:07 +0000 (14:56 +0200)
[Reviewed] GZharun

gtk2_ardour/editor_audio_import.cc
gtk2_ardour/file_sample_rate_mismatch_dialog.cc [new file with mode: 0644]
gtk2_ardour/file_sample_rate_mismatch_dialog.h [new file with mode: 0644]
gtk2_ardour/macosx/tracks.xcodeproj/project.pbxproj
gtk2_ardour/ui/file_sample_rate_mismatch_dialog.xml [new file with mode: 0644]
gtk2_ardour/wscript

index e5ac8c6c725231b2666186f1742e9020e7d6d0aa..1655add62fdce7da5ae5ed2a0bf20e2d6a3de573 100644 (file)
@@ -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<string> 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 (file)
index 0000000..4517055
--- /dev/null
@@ -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 <string.h>
+#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 (file)
index 0000000..d938193
--- /dev/null
@@ -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 <string.h>
+#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__ */
index f77ed78114e90956d257713514d7ace43fd54910..bb8c84d75d83ea88d0bdbbe3267575ae310d0308 100644 (file)
                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 */; };
                43B351EE194F12FB0038C140 /* waves_audiobackend.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = waves_audiobackend.xcodeproj; path = ../../libs/backends/wavesaudio/macosx/waves_audiobackend.xcodeproj; sourceTree = "<group>"; };
                43B351F4194F130C0038C140 /* libardour.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libardour.xcodeproj; path = ../../libs/ardour/macosx/libardour.xcodeproj; sourceTree = "<group>"; };
                43B351FA194F131D0038C140 /* pbd.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = pbd.xcodeproj; path = ../../libs/pbd/macosx/pbd.xcodeproj; sourceTree = "<group>"; };
+               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 = "<group>"; };
+               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 = "<group>"; };
+               95176F7D1A08E76F00E32046 /* file_sample_rate_mismatch_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = file_sample_rate_mismatch_dialog.xml; sourceTree = "<group>"; };
                954DCFBC1A0239DA00B7160E /* about_dialog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = about_dialog.cc; path = ../about_dialog.cc; sourceTree = "<group>"; };
                954DCFBE1A0239EC00B7160E /* about_dialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = about_dialog.h; path = ../about_dialog.h; sourceTree = "<group>"; };
                954DCFBF1A023AAB00B7160E /* about_dialog.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = about_dialog.xml; sourceTree = "<group>"; };
                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 */,
                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 */,
                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 */,
                                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 */,
                                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 (file)
index 0000000..e641fef
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Dialog title="File sample rate mismatch" resizeable="False">
+  
+  <style name="generic_control"
+  winfont ="Arial Bold 12"
+  macfont ="Helvetica Bold 12"
+  fgnormal="#BFBFBF"
+  bgnormal="#6C6C6C"
+  fgactive="#BFBFBF"
+  bgactive="#454545"
+  fghover="#CCCCCC"
+  bghover="#898989"/>
+  
+  <Layout width="420"
+          height="90"
+          bgnormal="#EDECE8">
+      <VBox width="420"
+            x="0"
+            y="20">
+          <Label id="info_label_1"
+                 style="generic_control"
+                 fgnormal="#6D6E72"
+                 horzalignment="center"/>
+          <Label id="info_label_2"
+                 style="generic_control"
+                 fgnormal="#6D6E72"
+                 horzalignment="center"/>
+      </VBox>
+      
+      <Button id="cancel_button"
+              style="generic_control"
+              text="Cancel"
+              fgnormal="#6D6E72"
+              bgnormal="#CACAC5"
+              fgactive="#EDECE8"
+              bgactive="#6D6E72"
+              borderwidth="0 0 0 0"
+              bordercolor="#6D6E72"
+              width="80"
+              height="22"
+              x="240"
+              y="58"/>
+              
+      <Button id="ignore_button"
+              style="generic_control"
+              text="Ignore"
+              fgnormal="#6D6E72"
+              bgnormal="#CACAC5"
+              fgactive="#EDECE8"
+              bgactive="#6D6E72"
+              borderwidth="0 0 0 0"
+              bordercolor="#6D6E72"
+              width="80"
+              height="22"
+              x="330"
+              y="58"/>
+  </Layout>
+  
+</Dialog>
\ No newline at end of file
index 73f347c29f237e502531ed96a41e70c3e7599871..ffc5d76a8ef514b0cd683d3ed65ae02ed2f3cb02 100644 (file)
@@ -112,6 +112,7 @@ gtk2_ardour_sources = [
         'export_format_selector.cc',
         'export_preset_selector.cc',
         'export_timespan_selector.cc',
+        'file_sample_rate_mismatch_dialog.cc',
         'fft.cc',
         'fft_graph.cc',
         'fft_result.cc',