Add dialogue to ask user about ambiguous source files. Fixes #3603.
[ardour.git] / gtk2_ardour / ambiguous_file_dialog.cc
1 /*
2     Copyright (C) 2010 Paul Davis
3     Author: Carl Hetherington <cth@carlh.net>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gtkmm/label.h>
21 #include "ambiguous_file_dialog.h"
22
23 using namespace std;
24 using namespace ARDOUR;
25 using namespace Gtk;
26
27 AmbiguousFileDialog::AmbiguousFileDialog (const string& file, const vector<string>& paths)
28         : ArdourDialog (_("Ambiguous File"), true, false)
29 {
30         get_vbox()->set_spacing (6);
31
32         Label* l = manage (new Label);
33         l->set_markup (string_compose (_("Ardour has found the file <i>%1</i> in the following places:\n\n"), file));
34         get_vbox()->pack_start (*l);
35
36         for (vector<string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
37                 _radio_buttons.push_back (manage (new RadioButton (_group, *i)));
38                 get_vbox()->pack_start (*_radio_buttons.back ());
39         }
40
41         get_vbox()->pack_start (*manage (new Label (_("\n\nPlease select the path that you want to get the file from."))));
42                 
43         add_button (_("Done"), RESPONSE_OK);
44
45         show_all ();
46 }
47
48 int
49 AmbiguousFileDialog::get_which () const
50 {
51         int i = 0;
52         vector<RadioButton*>::const_iterator j = _radio_buttons.begin ();
53         while (j != _radio_buttons.end() && !(*j)->get_active ()) {
54                 ++i;
55                 ++j;
56         }
57
58         if (j == _radio_buttons.end()) {
59                 return 0;
60         }
61
62         return i;
63 }