Reenable the correct sort column and type when redisplaying regions
[ardour.git] / gtk2_ardour / pt_import_selector.cc
index 9980321a8e5236e32d7c87dfbb72ffb68b625369..da65bcb7231aadda30a43253cf4449ec6bcf7aa2 100644 (file)
@@ -1,34 +1,36 @@
 /*
-    Copyright (C) 2018 Paul Davis
-    Author: Damien Zammit
-
-    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.
-
-*/
+ * Copyright (C) 2018-2019 Damien Zammit <damien@zamaudio.com>
+ *
+ * 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 <pbd/error.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <iostream>
+
 #include "pbd/gstdio_compat.h"
 #include "pbd/i18n.h"
 #include "pbd/file_utils.h"
 
-#include "ptformat/ptfformat.h"
+#include "ptformat/ptformat.h"
 
 #include "ardour/session_handle.h"
+
+#include "gtkmm2ext/utils.h"
+
 #include "pt_import_selector.h"
 
 using namespace Gtk;
@@ -66,6 +68,7 @@ PTImportSelector::PTImportSelector (PTFFormat& ptf) :
        match_pt_filter.add_pattern ("*.ptx");
        match_pt_filter.set_name (_("All PT sessions"));
 
+       Gtkmm2ext::add_volume_shortcuts (ptimport_ptf_chooser);
        ptimport_ptf_chooser.add_filter (match_pt_filter);
        ptimport_ptf_chooser.set_select_multiple (false);
        //XXX ptimport_ptf_chooser.set_current_folder (dstdir);
@@ -106,24 +109,35 @@ void
 PTImportSelector::update_ptf()
 {
        if (ptimport_ptf_chooser.get_filename ().size () > 0) {
+               int err = 0;
                 std::string path = ptimport_ptf_chooser.get_filename ();
                bool ok = Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK)
                                && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR);
                if (ok) {
-                       if (_ptf->load (path, _session_rate) == -1) {
+                       err = _ptf->load (path, _session_rate);
+                       if (err == -1) {
+                               ptimport_info_text.get_buffer ()->set_text ("Cannot decrypt PT session\n");
+                               ptimport_import_button.set_sensitive(false);
+                       } else if (err == -2) {
                                ptimport_info_text.get_buffer ()->set_text ("Cannot detect PT session\n");
                                ptimport_import_button.set_sensitive(false);
+                       } else if (err == -3) {
+                               ptimport_info_text.get_buffer ()->set_text ("Incompatible PT version\n");
+                               ptimport_import_button.set_sensitive(false);
+                       } else if (err == -4) {
+                               ptimport_info_text.get_buffer ()->set_text ("Cannot parse PT session\n");
+                               ptimport_import_button.set_sensitive(false);
                        } else {
                                std::string ptinfo = string_compose (_("PT Session [ VALID ]\n\nSession Info:\n\n\nPT v%1 Session @ %2Hz\n\n%3 audio files\n%4 audio regions\n%5 active audio regions\n%6 midi regions\n%7 active midi regions\n\n"),
-                                       (int)_ptf->version,
-                                       _ptf->sessionrate,
-                                       _ptf->audiofiles.size (),
-                                       _ptf->regions.size (),
-                                       _ptf->tracks.size (),
-                                       _ptf->midiregions.size (),
-                                       _ptf->miditracks.size ()
+                                       (int)_ptf->version (),
+                                       _ptf->sessionrate (),
+                                       _ptf->audiofiles ().size (),
+                                       _ptf->regions ().size (),
+                                       _ptf->tracks ().size (),
+                                       _ptf->midiregions ().size (),
+                                       _ptf->miditracks ().size ()
                                );
-                               if (_session_rate != _ptf->sessionrate) {
+                               if (_session_rate != _ptf->sessionrate ()) {
                                        ptinfo = string_compose (_("%1WARNING:\n\nSample rate mismatch,\nwill be resampling\n"), ptinfo);
                                }
                                ptimport_info_text.get_buffer ()->set_text (ptinfo);