/*
- 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;
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);
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);