enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[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 "pbd/compose.h"
22 #include "ambiguous_file_dialog.h"
23 #include "pbd/i18n.h"
24
25 using namespace std;
26 using namespace ARDOUR;
27 using namespace Gtk;
28
29 AmbiguousFileDialog::AmbiguousFileDialog (const string& file, const vector<string>& paths)
30         : ArdourDialog (_("Ambiguous File"), true, false)
31 {
32         /* This dialog is always shown programatically. Center the window.*/
33         set_position (Gtk::WIN_POS_CENTER);
34
35         get_vbox()->set_spacing (6);
36         Label* l = manage (new Label);
37         l->set_markup (string_compose (_("%1 has found the file <i>%2</i> in the following places:\n\n"), PROGRAM_NAME, file));
38         get_vbox()->pack_start (*l);
39
40         for (vector<string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
41                 _radio_buttons.push_back (manage (new RadioButton (_group, *i)));
42                 get_vbox()->pack_start (*_radio_buttons.back ());
43                 _radio_buttons.back()->signal_button_press_event().connect (sigc::mem_fun (*this, &AmbiguousFileDialog::rb_button_press), false);
44         }
45
46         get_vbox()->pack_start (*manage (new Label (_("\n\nPlease select the path that you want to get the file from."))));
47
48         add_button (_("Done"), RESPONSE_OK);
49         set_default_response (RESPONSE_OK);
50
51         show_all ();
52 }
53
54 bool
55 AmbiguousFileDialog::rb_button_press (GdkEventButton* ev)
56 {
57         if (ev->type == GDK_2BUTTON_PRESS) {
58                 response (RESPONSE_OK);
59         }
60         return false;
61 }
62
63 int
64 AmbiguousFileDialog::get_which () const
65 {
66         int i = 0;
67         vector<RadioButton*>::const_iterator j = _radio_buttons.begin ();
68         while (j != _radio_buttons.end() && !(*j)->get_active ()) {
69                 ++i;
70                 ++j;
71         }
72
73         if (j == _radio_buttons.end()) {
74                 return 0;
75         }
76
77         return i;
78 }