strip keyboard.cc of noxious focus handling stuff, and cleanup
[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 {
32         session = 0;
33         kbd_input = false;
34         running = false;
35         _run_status = 0;
36         _within_hiding = false;
37         hide_on_stop = true;
38 }
39
40 ArdourDialog::~ArdourDialog ()
41 {
42 }
43
44 bool
45 ArdourDialog::on_enter_notify_event (GdkEventCrossing *ev)
46 {
47         if (ev->detail != GDK_NOTIFY_INFERIOR) {
48                 // GTK2FIX
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                 // GTK2FIX
59                 //Keyboard::the_keyboard().set_current_dialog (0);
60         }
61         return false;
62 }
63
64 void
65 ArdourDialog::on_unmap ()
66 {
67         _within_hiding = true;
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                 hide_all ();
83         }
84
85         if (running) {
86                 if (rr == 0) {
87                         response (GTK_RESPONSE_ACCEPT);
88                 } else {
89                         response (GTK_RESPONSE_CANCEL);
90                 }
91                 running = false;
92         }
93 }
94
95 void
96 ArdourDialog::run ()
97 {
98         show_all ();
99
100         running = true;
101         switch (Dialog::run ()) {
102         case GTK_RESPONSE_ACCEPT:
103                 _run_status = 0;
104                 break;
105                 
106         case GTK_RESPONSE_DELETE_EVENT:
107                 _run_status = -1;
108                 break;
109
110         default:
111                 _run_status = -1;
112         }
113
114         hide_all ();
115 }
116
117 void
118 ArdourDialog::set_keyboard_input (bool yn)
119 {
120         kbd_input = yn;
121 }
122
123 int
124 ArdourDialog::run_status ()
125 {
126         return _run_status;
127 }