add new GSource-derived object that can be attached to a Glib::MainContext to execute code before other sources have their dispatch() method invoked
This commit is contained in:
parent
e7d84a7c47
commit
09c84d1de8
19
libs/pbd/glib_event_source.cc
Normal file
19
libs/pbd/glib_event_source.cc
Normal file
@ -0,0 +1,19 @@
|
||||
#include "pbd/glib_event_source.h"
|
||||
|
||||
bool
|
||||
GlibEventLoopSource::prepare (int& timeout)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
GlibEventLoopSource::check ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
GlibEventLoopSource::dispatch (sigc::slot_base*)
|
||||
{
|
||||
return false;
|
||||
}
|
33
libs/pbd/pbd/glib_event_source.h
Normal file
33
libs/pbd/pbd/glib_event_source.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef __libpbd_glib_event_source_h__
|
||||
#define __libpbd_glib_event_source_h__
|
||||
|
||||
#include <boost/function.hpp>
|
||||
|
||||
#include <glibmm/main.h>
|
||||
|
||||
class GlibEventLoopSource : public Glib::Source
|
||||
{
|
||||
public:
|
||||
GlibEventLoopSource () {};
|
||||
|
||||
bool prepare (int& timeout);
|
||||
bool check();
|
||||
bool dispatch (sigc::slot_base*);
|
||||
};
|
||||
|
||||
|
||||
class GlibEventLoopCallback : public GlibEventLoopSource
|
||||
{
|
||||
public:
|
||||
GlibEventLoopCallback (boost::function<void()> callback) : _callback (callback) {}
|
||||
|
||||
bool check() {
|
||||
_callback();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
boost::function<void()> _callback;
|
||||
};
|
||||
|
||||
#endif /* __libpbd_glib_event_source_h__ */
|
@ -51,6 +51,7 @@ libpbd_sources = [
|
||||
'file_archive.cc',
|
||||
'file_utils.cc',
|
||||
'fpu.cc',
|
||||
'glib_event_source.cc',
|
||||
'id.cc',
|
||||
'locale_guard.cc',
|
||||
'localtime_r.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user