More tweaks
[ardour.git] / libs / gtkmm2ext / prompter.cc
1 /*
2     Copyright (C) 1999 Paul Barton-Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <string>
22
23 #include <gtkmm/stock.h>
24 #include <gtkmm2ext/prompter.h>
25
26 #include "i18n.h"
27
28 using namespace std;
29 using namespace Gtkmm2ext;
30
31 Prompter::Prompter (Gtk::Window& parent, bool modal)
32         : Gtk::Dialog ("", parent, modal)
33 {
34         init ();
35 }
36
37 Prompter::Prompter (bool modal)
38         : Gtk::Dialog ("", modal)
39 {
40         init ();
41 }
42
43 void
44 Prompter::init ()
45 {
46         set_position (Gtk::WIN_POS_MOUSE);
47         set_name ("Prompter");
48
49         set_default_response (Gtk::RESPONSE_ACCEPT);
50         
51         add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
52         add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
53         
54         entryLabel.set_line_wrap (true);
55         entryLabel.set_name ("PrompterLabel");
56
57         entryBox.set_homogeneous (false);
58         entryBox.set_spacing (5);
59         entryBox.set_border_width (10);
60         entryBox.pack_start (entryLabel);
61         entryBox.pack_start (entry, false, false);
62
63         get_vbox()->pack_start (entryBox);
64         show_all_children();
65
66         entry.signal_activate().connect (bind (mem_fun (*this, &Prompter::response), Gtk::RESPONSE_ACCEPT));
67 }       
68
69 void
70 Prompter::change_labels (string okstr, string cancelstr)
71 {
72         // dynamic_cast<Gtk::Label*>(ok.get_child())->set_text (okstr);
73         // dynamic_cast<Gtk::Label*>(cancel.get_child())->set_text (cancelstr);
74 }
75
76 void
77 Prompter::get_result (string &str)
78
79 {
80         str = entry.get_text ();
81 }