52b7ab567c0583a01f7b61c9ea5b6596c81f3a96
[ardour.git] / gtk2_ardour / ardour_message.cc
1 /*
2     Copyright (C) 2004 Paul 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
22 #include "ardour_message.h"
23 #include "i18n.h"
24
25 using namespace std;
26 using namespace Gtk;
27
28
29 ArdourMessage::ArdourMessage (Gtk::Window* parent, 
30                               string name, string msg, 
31                               bool grab_focus, bool auto_run)
32         : ArdourDialog (name),
33           ok_button (_("OK"))
34 {
35         set_keyboard_input (true);
36
37         label.set_text (msg);
38         label.set_alignment (0.5, 0.5);
39         label.set_name (X_("PrompterLabel"));
40         
41         ok_button.set_name ("EditorGTKButton"); 
42         ok_button.clicked.connect (bind (slot (*this, &ArdourDialog::stop), 1));
43         
44         packer.set_spacing (10);
45         packer.set_border_width (10);
46         packer.pack_start (label);
47         packer.pack_start (ok_button);
48         
49         set_name (X_("Prompter"));
50         set_position (GTK_WIN_POS_MOUSE);
51         set_modal (true);
52         add (packer);
53         show_all ();
54         
55         realize();
56         get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
57
58         if (grab_focus) {
59                 ok_button.grab_focus ();
60         }
61
62         if (parent) {
63                 set_transient_for (*parent);
64         }
65
66         if (auto_run) {
67                 run ();
68         }
69 }
70
71 ArdourMessage::~ArdourMessage()
72 {
73 }