2 Copyright (C) 2006 Paul Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <pbd/controllable.h>
26 #include <gtkmm2ext/binding_proxy.h>
30 using namespace Gtkmm2ext
;
34 BindingProxy::BindingProxy (Controllable
* c
)
38 bind_statemask (Gdk::CONTROL_MASK
)
43 BindingProxy::BindingProxy (Controllable
& c
)
47 bind_statemask (Gdk::CONTROL_MASK
)
52 BindingProxy::~BindingProxy ()
60 BindingProxy::set_controllable (Controllable
* c
)
67 BindingProxy::set_bind_button_state (guint button
, guint statemask
)
70 bind_statemask
= statemask
;
74 BindingProxy::get_bind_button_state (guint
&button
, guint
&statemask
)
77 statemask
= bind_statemask
;
81 BindingProxy::button_press_handler (GdkEventButton
*ev
)
83 if ((ev
->state
& bind_statemask
) && ev
->button
== bind_button
) {
84 if (Controllable::StartLearning (controllable
)) {
85 string prompt
= _("operate controller now");
87 prompter
= new PopUp (Gtk::WIN_POS_MOUSE
, 30000, false);
88 prompter
->signal_unmap_event().connect (mem_fun (*this, &BindingProxy::prompter_hiding
));
90 prompter
->set_text (prompt
);
91 prompter
->touch (); // shows popup
92 learning_connection
= controllable
->LearningFinished
.connect (mem_fun (*this, &BindingProxy::learning_finished
));
101 BindingProxy::learning_finished ()
103 learning_connection
.disconnect ();
105 prompter
->touch (); // hides popup
111 BindingProxy::prompter_hiding (GdkEventAny
*ev
)
113 learning_connection
.disconnect ();
114 Controllable::StopLearning (controllable
);