From 883b9b94bae3e3ba1164d09ca398b2b1f856b35a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 14 Oct 2016 21:49:20 -0400 Subject: Fix initial display of embedded GUIs --- src/gui/NodeModule.cpp | 25 ++++++++++++++++++++++++- src/gui/NodeModule.hpp | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index f368d15f..56fc0e42 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -57,6 +57,7 @@ NodeModule::NodeModule(GraphCanvas& canvas, , _block(block) , _gui_widget(NULL) , _gui_window(NULL) + , _initialised(false) { block->signal_new_port().connect( sigc::mem_fun(this, &NodeModule::new_port_view)); @@ -85,6 +86,15 @@ NodeModule::NodeModule(GraphCanvas& canvas, for (const auto& p : block->properties()) { property_changed(p.first, p.second); } + + if (_block->has_property(app().uris().ingen_uiEmbedded, + app().uris().forge.make(true))) { + // Schedule idle callback to embed GUI once ports arrive + Glib::signal_timeout().connect( + sigc::mem_fun(*this, &NodeModule::idle_init), 25, G_PRIORITY_DEFAULT_IDLE); + } else { + _initialised = true; + } } NodeModule::~NodeModule() @@ -93,6 +103,19 @@ NodeModule::~NodeModule() delete _gui_window; } +bool +NodeModule::idle_init() +{ + if (_block->ports().size() == 0) { + return true; // Need to embed GUI, but ports haven't shown up yet + } + + // Ports have arrived, embed GUI and deregister this callback + embed_gui(true); + _initialised = true; + return false; +} + bool NodeModule::show_menu(GdkEventButton* ev) { @@ -442,7 +465,7 @@ NodeModule::property_changed(const Raul::URI& key, const Atom& value) } else if (value.type() == uris.forge.Bool) { if (key == uris.ingen_polyphonic) { set_stacked(value.get()); - } else if (key == uris.ingen_uiEmbedded) { + } else if (key == uris.ingen_uiEmbedded && _initialised) { if (value.get() && !_gui_widget) { embed_gui(true); } else if (!value.get() && _gui_widget) { diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index 2d9a3333..86103a03 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -69,6 +69,7 @@ protected: virtual bool on_double_click(GdkEventButton* ev); + bool idle_init(); bool on_event(GdkEvent* ev); void on_embed_gui_toggled(bool embed); @@ -94,6 +95,7 @@ protected: SPtr _plugin_ui; Gtk::Widget* _gui_widget; Gtk::Window* _gui_window; ///< iff popped up + bool _initialised; }; } // namespace GUI -- cgit v1.2.1