2010-11-09 01:03:51 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2010-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2014-2015 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
* Copyright (C) 2014 John Emmas <john@creativepost.co.uk>
|
|
|
|
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/replace_all.h"
|
|
|
|
#include "pbd/strsplit.h"
|
2013-07-15 08:05:37 -04:00
|
|
|
#include "pbd/search_path.h"
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
#include "ardour/session.h"
|
2015-10-15 05:24:15 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
#include "missing_file_dialog.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2021-07-06 18:33:50 -04:00
|
|
|
MissingFileDialog::MissingFileDialog (Gtk::Window& parent, Session* s, const std::string& path, DataType type)
|
|
|
|
: ArdourDialog (parent, _("Missing File"), true, false)
|
2017-02-22 04:26:58 -05:00
|
|
|
, filetype (type)
|
2017-02-22 04:38:43 -05:00
|
|
|
, is_absolute_path (Glib::path_is_absolute (path))
|
2017-02-22 04:26:58 -05:00
|
|
|
, chooser (_("Select a folder to search"), FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
|
|
|
, use_chosen (_("Add chosen folder to search path, and try again"))
|
|
|
|
, choice_group (use_chosen.get_group())
|
|
|
|
, stop_loading_button (choice_group, _("Stop loading this session"), false)
|
|
|
|
, all_missing_ok (choice_group, _("Skip all missing files"), false)
|
|
|
|
, this_missing_ok (choice_group, _("Skip this file"), false)
|
2010-11-09 01:03:51 -05:00
|
|
|
{
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
/* This dialog is always shown programmatically. Center the window.*/
|
2015-10-22 11:14:03 -04:00
|
|
|
set_position (Gtk::WIN_POS_CENTER);
|
|
|
|
|
|
|
|
set_session (s);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
add_button (_("Done"), RESPONSE_OK);
|
|
|
|
set_default_response (RESPONSE_OK);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
string typestr;
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
switch (type) {
|
|
|
|
case DataType::AUDIO:
|
|
|
|
typestr = _("audio");
|
|
|
|
break;
|
|
|
|
case DataType::MIDI:
|
|
|
|
typestr = _("MIDI");
|
|
|
|
break;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2013-07-15 08:05:37 -04:00
|
|
|
vector<string> source_dirs = s->source_search_path (type);
|
|
|
|
vector<string>::iterator i = source_dirs.begin();
|
|
|
|
ostringstream oss;
|
|
|
|
oss << *i << endl;
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2013-07-15 08:05:37 -04:00
|
|
|
while (++i != source_dirs.end()) {
|
|
|
|
oss << *i << endl;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
msg.set_justify (JUSTIFY_LEFT);
|
|
|
|
msg.set_markup (string_compose (_("%1 cannot find the %2 file\n\n<i>%3</i>\n\nin any of these folders:\n\n\
|
|
|
|
<tt>%4</tt>\n\n"), PROGRAM_NAME, typestr, Gtkmm2ext::markup_escape_text (path), Gtkmm2ext::markup_escape_text (oss.str())));
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
HBox* hbox = manage (new HBox);
|
|
|
|
hbox->pack_start (msg, false, true);
|
|
|
|
hbox->show ();
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
get_vbox()->pack_start (*hbox, false, false);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
VBox* button_packer_box = manage (new VBox);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
button_packer_box->set_spacing (6);
|
|
|
|
button_packer_box->set_border_width (12);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
button_packer_box->pack_start (use_chosen, false, false);
|
|
|
|
button_packer_box->pack_start (this_missing_ok, false, false);
|
|
|
|
button_packer_box->pack_start (all_missing_ok, false, false);
|
|
|
|
button_packer_box->pack_start (stop_loading_button, false, false);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
button_packer_box->show_all ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
get_vbox()->set_spacing (6);
|
|
|
|
get_vbox()->set_border_width (25);
|
|
|
|
get_vbox()->set_homogeneous (false);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
hbox = manage (new HBox);
|
|
|
|
hbox->pack_start (*button_packer_box, false, true);
|
|
|
|
hbox->show ();
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
get_vbox()->pack_start (*hbox, false, false);
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
hbox = manage (new HBox);
|
|
|
|
Label* label = manage (new Label);
|
|
|
|
label->set_text (_("Click to choose an additional folder"));
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
hbox->set_spacing (6);
|
|
|
|
hbox->set_border_width (12);
|
|
|
|
hbox->pack_start (*label, false, false);
|
|
|
|
hbox->pack_start (chooser, true, true);
|
|
|
|
hbox->show_all ();
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
get_vbox()->pack_start (*hbox, true, true);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
msg.show ();
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2019-01-02 11:37:03 -05:00
|
|
|
Gtkmm2ext::add_volume_shortcuts (chooser);
|
2017-02-22 04:26:58 -05:00
|
|
|
chooser.set_current_folder (Glib::get_home_dir());
|
|
|
|
chooser.set_create_folders (false);
|
2010-11-09 01:03:51 -05:00
|
|
|
}
|
|
|
|
|
2017-02-22 04:38:43 -05:00
|
|
|
void
|
|
|
|
MissingFileDialog::set_absolute ()
|
|
|
|
{
|
|
|
|
_session->set_missing_file_replacement (chooser.get_filename ());
|
|
|
|
}
|
|
|
|
|
2010-11-09 01:03:51 -05:00
|
|
|
void
|
|
|
|
MissingFileDialog::add_chosen ()
|
|
|
|
{
|
2017-02-22 04:26:58 -05:00
|
|
|
string str;
|
|
|
|
string newdir;
|
|
|
|
vector<string> dirs;
|
|
|
|
|
|
|
|
switch (filetype) {
|
|
|
|
case DataType::AUDIO:
|
|
|
|
str = _session->config.get_audio_search_path();
|
|
|
|
break;
|
|
|
|
case DataType::MIDI:
|
|
|
|
str = _session->config.get_midi_search_path();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
split (str, dirs, G_SEARCHPATH_SEPARATOR);
|
|
|
|
|
|
|
|
newdir = chooser.get_filename ();
|
|
|
|
|
|
|
|
for (vector<string>::iterator d = dirs.begin(); d != dirs.end(); d++) {
|
|
|
|
if (*d == newdir) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!str.empty()) {
|
|
|
|
str += G_SEARCHPATH_SEPARATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
str += newdir;
|
|
|
|
|
|
|
|
switch (filetype) {
|
|
|
|
case DataType::AUDIO:
|
|
|
|
_session->config.set_audio_search_path (str);
|
|
|
|
break;
|
|
|
|
case DataType::MIDI:
|
|
|
|
_session->config.set_midi_search_path (str);
|
|
|
|
break;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
MissingFileDialog::get_action ()
|
|
|
|
{
|
2017-02-22 04:26:58 -05:00
|
|
|
if (use_chosen.get_active ()) {
|
2017-02-22 04:38:43 -05:00
|
|
|
if (is_absolute_path) {
|
|
|
|
set_absolute ();
|
|
|
|
} else {
|
|
|
|
add_chosen ();
|
|
|
|
}
|
2017-02-22 04:26:58 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
if (this_missing_ok.get_active()) {
|
|
|
|
return -1;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
if (all_missing_ok.get_active ()) {
|
|
|
|
return 3;
|
|
|
|
}
|
2010-11-09 01:03:51 -05:00
|
|
|
|
2017-02-22 04:26:58 -05:00
|
|
|
return 1;
|
2010-11-09 01:03:51 -05:00
|
|
|
}
|