use -r argument with JACK if realtime is not requested in engine dialog (also applied...
[ArdourMidi.git] / libs / gtkmm2ext / bindable_button.cc
blob5c0cc3c958b6fc22a76c563b73c3b9d43eca049d
1 /*
2 Copyright (C) 2004 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.
17 $Id$
20 #include <string>
21 #include <iostream>
23 #include "pbd/controllable.h"
25 #include "gtkmm2ext/gtk_ui.h"
26 #include "gtkmm2ext/bindable_button.h"
27 #include "gtkmm2ext/gui_thread.h"
29 #include "i18n.h"
31 using namespace Gtkmm2ext;
32 using namespace std;
33 using namespace PBD;
35 void
36 BindableToggleButton::set_controllable (boost::shared_ptr<PBD::Controllable> c)
38 watch_connection.disconnect ();
39 binding_proxy.set_controllable (c);
42 void
43 BindableToggleButton::watch ()
45 boost::shared_ptr<Controllable> c (binding_proxy.get_controllable ());
47 if (!c) {
48 warning << _("button cannot watch state of non-existing Controllable\n") << endl;
49 return;
52 c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&BindableToggleButton::controllable_changed, this), gui_context());
55 void
56 BindableToggleButton::controllable_changed ()
58 float val = binding_proxy.get_controllable()->get_value();
59 set_active (fabs (val) >= 0.5f);