delete slave during Session::destroy
[ardour.git] / libs / widgets / widgets / prompter.h
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 */
19
20 #ifndef _WIDGETS_PROMPTER_H_
21 #define _WIDGETS_PROMPTER_H_
22
23 #include <string>
24 #include <gtkmm/box.h>
25 #include <gtkmm/entry.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/dialog.h>
28 #include <sigc++/sigc++.h>
29
30 #include "widgets/visibility.h"
31
32 namespace Gtk {
33         class Window;
34 }
35
36 namespace ArdourWidgets {
37
38 class LIBWIDGETS_API Prompter : public Gtk::Dialog
39 {
40 public:
41         Prompter (bool modal = false);
42         Prompter (Gtk::Window& parent, bool modal = false);
43         ~Prompter () {};
44
45         void set_prompt (std::string prompt) {
46                 entryLabel.set_label (prompt);
47         }
48
49         void set_initial_text (std::string txt) {
50                 entry.set_text (txt);
51                 entry.select_region (0, entry.get_text_length());
52         }
53
54         void change_labels (std::string ok, std::string cancel);
55
56         void get_result (std::string &str, bool strip=true);
57
58 protected:
59         Gtk::Entry& the_entry() { return entry; }
60
61         void on_entry_changed ();
62         void on_show ();
63
64 private:
65         Gtk::Entry entry;
66         Gtk::HBox entryBox;
67         Gtk::Label entryLabel;
68         bool first_show;
69         bool can_accept_from_entry;
70
71         void init ();
72         void entry_activated ();
73 };
74
75 } /* namespace */
76
77 #endif