c++ - Gtkmm: Adding Window at later time -
because i´m writting "generic" application behaving different when facing other configurations, i´m forced show gtk windows if dont yet know them @ startup. there might requirement multiple windows need visisble (not modal dialogs standalone windows) @ same time. but, great if 1 can start 1 gtk event loop @ startup.
is somehow possible add windows loop after has been started? while found gtk::application class seems support indented behaviour i´m restricted use gtk::main class.
there's single gtk::main object allowed. widgets should created in same thread main event loop being run in. work around limitation need develop way pass window creation commands gtk thread.
the simplest way use glib::dispatcher
struct windowbuilder { /**/ glib::dispatcher* signal_create; void create_window() { //from main thread... signal_create->emit(); } } void create_mainwnd() { new ui::mainwnd(); } //from gtk thread... builder->signal_create->connect(sigc::ptr_fun(create_mainwnd)); gtk::main::run(); glib::dispatcher doesn't take arguments it, next step figure out how pass arguments around between threads.
for different types of windows can use different disptachers.
boost::asio::io_service can pass messages around.
while(!exit) { io_service.reset(); io_service.poll(); while(gtk::main::events_pending()) gtk::main::iteration(); sleep(0); }
Comments
Post a Comment