#include "pbd/abstract_ui.cc" /* instantiate the template */
MidiControlUI::MidiControlUI (Session& s)
- : AbstractUI<MidiUIRequest> (_("midiui"))
+ : AbstractUI<MidiUIRequest> (X_("midiui"))
, _session (s)
{
MIDI::Manager::instance()->PortsChanged.connect_same_thread (rebind_connection, boost::bind (&MidiControlUI::change_midi_ports, this));
UI::UI (string namestr, int *argc, char ***argv)
: AbstractUI<UIRequest> (namestr)
+ , _receiver (*this)
+
{
theMain = new Main (argc, argv);
void
UI::run (Receiver &old_receiver)
{
- listen_to (error);
- listen_to (info);
- listen_to (warning);
- listen_to (fatal);
+ _receiver.listen_to (error);
+ _receiver.listen_to (info);
+ _receiver.listen_to (warning);
+ _receiver.listen_to (fatal);
/* stop the old receiver (text/console) once we hit the first idle */
theMain->run ();
_active = false;
stopping ();
- hangup ();
+ _receiver.hangup ();
return;
}
}
};
-class UI : public Receiver, public AbstractUI<UIRequest>
+class UI : public AbstractUI<UIRequest>
{
+ private:
+ class MyReceiver : public Receiver {
+ public:
+ MyReceiver (UI& ui) : _ui (ui) {}
+ void receive (Transmitter::Channel chn, const char *msg) {
+ _ui.receive (chn, msg);
+ }
+ private:
+ UI& _ui;
+ };
+
+ MyReceiver _receiver;
+
public:
UI (std::string name, int *argc, char **argv[]);
virtual ~UI ();
bool color_picked;
void do_request (UIRequest*);
+
};
} /* namespace */
BaseUI::main_thread ()
{
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_self()));
+ std::cerr << string_compose ("%1: event loop running in thread %2\n", name(), pthread_self());
set_event_loop_for_thread (this);
thread_init ();
+ _main_loop->get_context()->signal_idle().connect (sigc::mem_fun (*this, &BaseUI::signal_running));
_main_loop->run ();
}
+bool
+BaseUI::signal_running ()
+{
+ Glib::Mutex::Lock lm (_run_lock);
+ _running.signal ();
+
+ return false; // don't call it again
+}
+
void
BaseUI::run ()
{
/* glibmm hack - drop the refptr to the IOSource now before it can hurt */
request_channel.drop_ios ();
+ Glib::Mutex::Lock lm (_run_lock);
run_loop_thread = Thread::create (mem_fun (*this, &BaseUI::main_thread), true);
+ std::cerr << "wait for " << name() << " thread to start\n";
+ _running.wait (_run_lock);
+ std::cerr << "\tthread now running\n";
}
void
*/
-class BaseUI : virtual public sigc::trackable, public PBD::EventLoop
+class BaseUI : public sigc::trackable, public PBD::EventLoop
{
public:
BaseUI (const std::string& name);
Glib::RefPtr<Glib::MainLoop> _main_loop;
Glib::Thread* run_loop_thread;
+ Glib::Mutex _run_lock;
+ Glib::Cond _running;
+
+ /* this signals _running from within the event loop,
+ from an idle callback
+ */
+
+ bool signal_running ();
/** Derived UI objects can implement thread_init()
* which will be called by the event loop thread
class strstream;
-class Receiver : virtual public sigc::trackable
+class Receiver : public sigc::trackable
{
public:
Receiver ();
testobj.includes = obj.includes + ['test', '../pbd']
testobj.uselib = 'CPPUNIT XML SNDFILE'
testobj.use = 'libpbd'
+ testobj.name = 'libpbd-tests'
if sys.platform != 'darwin':
testobj.linkflags = ['-lrt']
class Session;
class Bundle;
-class ControlProtocol : public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
+class ControlProtocol : public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI
+{
public:
ControlProtocol (Session&, std::string name);
virtual ~ControlProtocol();