rename all GTK signals
[ardour.git] / gtk2_ardour / ardour_dialog.cc
1 /*
2     Copyright (C) 2002 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 */
19
20 #include <iostream>
21
22 #include <gtkmm2ext/doi.h>
23
24 #include "ardour_dialog.h"
25 #include "keyboard.h"
26 #include "ardour_ui.h"
27
28
29 ArdourDialog::ArdourDialog (string name)
30         : Dialog (name), 
31           KeyboardTarget (*this, name)
32 {
33         session = 0;
34         kbd_input = false;
35         running = false;
36         _run_status = 0;
37         _within_hiding = false;
38         hide_on_stop = true;
39 }
40
41 ArdourDialog::~ArdourDialog ()
42 {
43 }
44
45 bool
46 ArdourDialog::on_enter_notify_event (GdkEventCrossing *ev)
47 {
48         if (ev->detail != GDK_NOTIFY_INFERIOR) {
49                 Keyboard::the_keyboard().set_current_dialog (this);
50         }
51         return FALSE;
52 }
53
54 bool
55 ArdourDialog::on_leave_notify_event (GdkEventCrossing *ev)
56 {
57         if (ev->detail != GDK_NOTIFY_INFERIOR) {
58                 Keyboard::the_keyboard().set_current_dialog (0);
59         }
60         return FALSE;
61 }
62
63 void
64 ArdourDialog::on_unmap ()
65 {
66         _within_hiding = true;
67         Hiding (); /* EMIT_SIGNAL */
68         _within_hiding = false;
69         Dialog::on_unmap ();
70 }
71
72 void
73 ArdourDialog::set_hide_on_stop (bool yn)
74 {
75         hide_on_stop = yn;
76 }
77
78 void
79 ArdourDialog::stop (int rr)
80 {
81         if (hide_on_stop) {
82                 Hiding (); /* EMIT_SIGNAL */
83                 hide_all ();
84
85                 if (kbd_input) {
86                         ARDOUR_UI::instance()->allow_focus (false);
87                 }
88         }
89
90         if (running) {
91                 if (rr == 0) {
92                         response (GTK_RESPONSE_ACCEPT);
93                 } else {
94                         response (GTK_RESPONSE_CANCEL);
95                 }
96                 running = false;
97         }
98 }
99
100 void
101 ArdourDialog::run ()
102 {
103         show_all ();
104
105         if (kbd_input) {
106                 ARDOUR_UI::instance()->allow_focus (true);
107         }
108
109         running = true;
110         switch (Dialog::run ()) {
111         case GTK_RESPONSE_ACCEPT:
112                 _run_status = 0;
113                 break;
114                 
115         case GTK_RESPONSE_DELETE_EVENT:
116                 _run_status = -1;
117                 break;
118
119         default:
120                 _run_status = -1;
121         }
122
123         hide_all ();
124
125         if (kbd_input) {
126                 ARDOUR_UI::instance()->allow_focus (false);
127         }
128 }
129
130 void
131 ArdourDialog::set_keyboard_input (bool yn)
132 {
133         kbd_input = yn;
134 }
135
136 int
137 ArdourDialog::run_status ()
138 {
139         return _run_status;
140 }