Add blib event callback to BaseUI, with a virtual method to be overridden by derived classes.
This commit is contained in:
parent
8bd465fc61
commit
b7d22508fa
|
@ -60,6 +60,7 @@ BaseUI::BaseUI (const string& loop_name)
|
||||||
, m_context(MainContext::get_default())
|
, m_context(MainContext::get_default())
|
||||||
, run_loop_thread (0)
|
, run_loop_thread (0)
|
||||||
, request_channel (true)
|
, request_channel (true)
|
||||||
|
, glib_event_callback (boost::bind (&BaseUI::event_loop_precall, this))
|
||||||
{
|
{
|
||||||
base_ui_instance = this;
|
base_ui_instance = this;
|
||||||
request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
|
request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
|
||||||
|
@ -120,6 +121,12 @@ BaseUI::run ()
|
||||||
_main_loop = MainLoop::create (m_context);
|
_main_loop = MainLoop::create (m_context);
|
||||||
attach_request_source ();
|
attach_request_source ();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* every time the main loop runs (i.e. before any actual event handling)
|
||||||
|
*/
|
||||||
|
|
||||||
|
glib_event_callback.attach (m_context);
|
||||||
|
|
||||||
Glib::Threads::Mutex::Lock lm (_run_lock);
|
Glib::Threads::Mutex::Lock lm (_run_lock);
|
||||||
run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread));
|
run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread));
|
||||||
_running.wait (_run_lock);
|
_running.wait (_run_lock);
|
||||||
|
@ -175,3 +182,8 @@ BaseUI::attach_request_source ()
|
||||||
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name()));
|
DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name()));
|
||||||
request_channel.attach (m_context);
|
request_channel.attach (m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BaseUI::event_loop_precall ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "pbd/libpbd_visibility.h"
|
#include "pbd/libpbd_visibility.h"
|
||||||
#include "pbd/crossthread.h"
|
#include "pbd/crossthread.h"
|
||||||
#include "pbd/event_loop.h"
|
#include "pbd/event_loop.h"
|
||||||
|
#include "pbd/glib_event_source.h"
|
||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
|
|
||||||
/** A BaseUI is an abstraction designed to be used with any "user
|
/** A BaseUI is an abstraction designed to be used with any "user
|
||||||
|
@ -75,6 +76,12 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
|
||||||
*/
|
*/
|
||||||
void quit ();
|
void quit ();
|
||||||
|
|
||||||
|
/* derived classes can override this in order to call code once per
|
||||||
|
main loop iteration (i.e. before any event dispatching is done
|
||||||
|
within the main loop)
|
||||||
|
*/
|
||||||
|
virtual void event_loop_precall ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _ok;
|
bool _ok;
|
||||||
|
|
||||||
|
@ -122,6 +129,8 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
|
||||||
|
|
||||||
int setup_request_pipe ();
|
int setup_request_pipe ();
|
||||||
void main_thread ();
|
void main_thread ();
|
||||||
|
|
||||||
|
GlibEventLoopCallback glib_event_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __pbd_base_ui_h__ */
|
#endif /* __pbd_base_ui_h__ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user