2010-11-09 01:03:51 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Paul Davis
|
|
|
|
|
|
|
|
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 "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"
|
|
|
|
|
|
|
|
#include "missing_file_dialog.h"
|
2011-04-22 23:34:42 -04:00
|
|
|
#include "i18n.h"
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
MissingFileDialog::MissingFileDialog (Session* s, const std::string& path, DataType type)
|
2014-07-15 07:59:22 -04:00
|
|
|
: ArdourDialog (_("Missing File"), true, false)
|
2010-11-09 01:03:51 -05:00
|
|
|
, filetype (type)
|
2010-11-09 18:50:20 -05:00
|
|
|
, chooser (_("Select a folder to search"), FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
2010-11-09 01:03:51 -05:00
|
|
|
, 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)
|
2010-11-09 18:50:20 -05:00
|
|
|
, 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
|
|
|
{
|
|
|
|
set_session (s);
|
|
|
|
|
|
|
|
add_button (_("Done"), RESPONSE_OK);
|
2011-11-09 05:58:02 -05:00
|
|
|
set_default_response (RESPONSE_OK);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
string typestr;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case DataType::AUDIO:
|
2010-11-09 18:50:20 -05:00
|
|
|
typestr = _("audio");
|
2010-11-09 01:03:51 -05:00
|
|
|
break;
|
|
|
|
case DataType::MIDI:
|
2010-11-09 18:50:20 -05:00
|
|
|
typestr = _("MIDI");
|
2010-11-09 01:03:51 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-07-15 07:59:22 -04:00
|
|
|
msg.set_justify (JUSTIFY_LEFT);
|
2010-12-25 21:43:00 -05:00
|
|
|
msg.set_markup (string_compose (_("%1 cannot find the %2 file\n\n<i>%3</i>\n\nin any of these folders:\n\n\
|
2013-07-15 08:05:37 -04:00
|
|
|
<tt>%4</tt>\n\n"), PROGRAM_NAME, typestr, Glib::Markup::escape_text(path), Glib::Markup::escape_text (oss.str())));
|
2010-11-09 18:50:20 -05:00
|
|
|
|
|
|
|
HBox* hbox = manage (new HBox);
|
|
|
|
hbox->pack_start (msg, false, true);
|
|
|
|
hbox->show ();
|
|
|
|
|
|
|
|
get_vbox()->pack_start (*hbox, false, false);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
VBox* button_packer_box = manage (new VBox);
|
|
|
|
|
|
|
|
button_packer_box->set_spacing (6);
|
|
|
|
button_packer_box->set_border_width (12);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
button_packer_box->show_all ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-09 01:03:51 -05:00
|
|
|
get_vbox()->set_spacing (6);
|
2010-11-09 18:50:20 -05:00
|
|
|
get_vbox()->set_border_width (25);
|
2010-11-09 01:03:51 -05:00
|
|
|
get_vbox()->set_homogeneous (false);
|
|
|
|
|
|
|
|
|
2010-11-09 18:50:20 -05:00
|
|
|
hbox = manage (new HBox);
|
2010-11-09 01:03:51 -05:00
|
|
|
hbox->pack_start (*button_packer_box, false, true);
|
|
|
|
hbox->show ();
|
|
|
|
|
|
|
|
get_vbox()->pack_start (*hbox, false, false);
|
2010-11-09 18:50:20 -05:00
|
|
|
|
|
|
|
hbox = manage (new HBox);
|
|
|
|
Label* label = manage (new Label);
|
|
|
|
label->set_text (_("Click to choose an additional folder"));
|
|
|
|
|
|
|
|
hbox->set_spacing (6);
|
|
|
|
hbox->set_border_width (12);
|
|
|
|
hbox->pack_start (*label, false, false);
|
|
|
|
hbox->pack_start (chooser, true, true);
|
|
|
|
hbox->show_all ();
|
|
|
|
|
|
|
|
get_vbox()->pack_start (*hbox, true, true);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
msg.show ();
|
2010-11-09 18:50:20 -05:00
|
|
|
|
2010-11-09 01:03:51 -05:00
|
|
|
chooser.set_current_folder (Glib::get_home_dir());
|
|
|
|
chooser.set_create_folders (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MissingFileDialog::add_chosen ()
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-04-11 10:36:04 -04:00
|
|
|
split (str, dirs, G_SEARCHPATH_SEPARATOR);
|
2010-11-09 01:03:51 -05:00
|
|
|
|
|
|
|
newdir = chooser.get_filename ();
|
|
|
|
|
|
|
|
for (vector<string>::iterator d = dirs.begin(); d != dirs.end(); d++) {
|
|
|
|
if (*d == newdir) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!str.empty()) {
|
2014-04-11 10:36:04 -04:00
|
|
|
str += G_SEARCHPATH_SEPARATOR;
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
|
|
|
|
2010-11-09 01:03:51 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
MissingFileDialog::get_action ()
|
|
|
|
{
|
|
|
|
if (use_chosen.get_active ()) {
|
|
|
|
add_chosen ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this_missing_ok.get_active()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (all_missing_ok.get_active ()) {
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|