13
0

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:
Paul Davis 2020-11-19 19:19:51 -07:00
parent e7d84a7c47
commit 09c84d1de8
3 changed files with 53 additions and 0 deletions

View 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;
}

View 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__ */

View File

@ -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',