2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "pbd/compose.h"
20 #include "pbd/replace_all.h"
21 #include "pbd/strsplit.h"
23 #include "ardour/session.h"
25 #include "missing_file_dialog.h"
29 using namespace ARDOUR;
32 MissingFileDialog::MissingFileDialog (Session* s, const std::string& path, DataType type)
33 : ArdourDialog (_("Missing File!"), true, false)
35 , chooser (FILE_CHOOSER_ACTION_SELECT_FOLDER)
36 , use_chosen (_("Add chosen folder to search path, and try again"))
37 , choice_group (use_chosen.get_group())
38 , use_chosen_and_no_more_questions (choice_group, _("Add chosen folder to search path, try again but don't ask me again"), false)
39 , stop_loading_button (choice_group, _("Stop loading this session"), false)
40 , all_missing_ok (choice_group, _("This and all other missing files are OK"), false)
41 , this_missing_ok (choice_group, _("This missing file is OK"), false)
45 add_button (_("Done"), RESPONSE_OK);
51 typestr = _("An audio");
54 typestr = _("A MIDI");
60 dirstr = s->source_search_path (type);
61 replace_all (dirstr, ":", "\n");
63 msg.set_markup (string_compose (_("%1 file (\"%2\") cannot be found.\n\n\
64 Currently, Ardour has searched in the following folders for this file:\n\n\
66 The following options are available:"), typestr, path, dirstr));
68 VBox* button_packer_box = manage (new VBox);
70 button_packer_box->set_spacing (6);
71 button_packer_box->set_border_width (12);
73 button_packer_box->pack_start (use_chosen, false, false);
74 button_packer_box->pack_start (use_chosen_and_no_more_questions, false, false);
75 button_packer_box->pack_start (this_missing_ok, false, false);
76 button_packer_box->pack_start (all_missing_ok, false, false);
77 button_packer_box->pack_start (stop_loading_button, false, false);
79 button_packer_box->show_all ();
81 get_vbox()->set_spacing (6);
82 get_vbox()->set_border_width (12);
83 get_vbox()->set_homogeneous (false);
85 get_vbox()->pack_start (msg, false, false);
87 HBox* hbox = manage (new HBox);
88 hbox->pack_start (*button_packer_box, false, true);
91 get_vbox()->pack_start (*hbox, false, false);
92 get_vbox()->pack_start (chooser, true, true);
95 chooser.set_size_request (-1, 300);
97 chooser.set_current_folder (Glib::get_home_dir());
98 chooser.set_create_folders (false);
102 MissingFileDialog::add_chosen ()
109 case DataType::AUDIO:
110 str = _session->config.get_audio_search_path();
113 str = _session->config.get_midi_search_path();
117 split (str, dirs, ':');
119 newdir = chooser.get_filename ();
121 for (vector<string>::iterator d = dirs.begin(); d != dirs.end(); d++) {
134 case DataType::AUDIO:
135 _session->config.set_audio_search_path (str);
138 _session->config.set_midi_search_path (str);
144 MissingFileDialog::get_action ()
147 if (use_chosen.get_active ()) {
152 if (use_chosen_and_no_more_questions.get_active()) {
157 if (this_missing_ok.get_active()) {
161 if (all_missing_ok.get_active ()) {