+ if( ret >= 0 && gui )
+ gui->handle_child();
+ return ret;
+}
+
+int PluginLV2ChildUI::send_host(int64_t token, const void *data, int bytes)
+{
+ return is_forked() ? send_parent(token, data, bytes) : 0;
+}
+
+PluginLV2GUI::PluginLV2GUI(PluginLV2ChildUI *child_ui)
+{
+ this->child_ui = child_ui;
+ top_level = 0;
+}
+
+PluginLV2GUI::~PluginLV2GUI()
+{
+}
+
+PluginLV2ChildGtkUI::PluginLV2ChildGtkUI(PluginLV2ChildUI *child_ui)
+ : PluginLV2GUI(child_ui)
+{
+ gtk_set_locale();
+ gtk_init(&child_ui->ac, &child_ui->av);
+}
+
+PluginLV2ChildGtkUI::~PluginLV2ChildGtkUI()
+{
+}
+
+void PluginLV2ChildGtkUI::reset_gui()
+{
+ GtkWidget *top_level = (GtkWidget *)this->top_level;
+ if( top_level ) { gtk_widget_destroy(top_level); this->top_level = 0; }
+}
+
+static void lilv_gtk_destroy(GtkWidget* widget, gpointer data)
+{
+ PluginLV2ChildGtkUI *gui = (PluginLV2ChildGtkUI*)data;
+ gui->child_ui->hidden = -1;
+}
+
+void PluginLV2ChildGtkUI::start_gui()
+{
+ this->top_level = (void *)gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ GtkWidget *top_level = (GtkWidget *)this->top_level;
+ g_signal_connect(top_level, "destroy", G_CALLBACK(lilv_gtk_destroy), this);
+ char *title = child_ui->PluginLV2UI::title;
+ gtk_window_set_title(GTK_WINDOW(top_level), title);
+
+ GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+ gtk_window_set_role(GTK_WINDOW(top_level), "plugin_ui");
+ gtk_container_add(GTK_CONTAINER(top_level), vbox);
+
+ GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1.0, 1.0);
+ gtk_box_pack_start(GTK_BOX(vbox), alignment, TRUE, TRUE, 0);
+ gtk_widget_show(alignment);
+ child_ui->lv2ui_instantiate(alignment);
+ GtkWidget* widget = (GtkWidget*)suil_instance_get_widget(child_ui->sinst);
+ gtk_container_add(GTK_CONTAINER(alignment), widget);
+ gtk_window_set_resizable(GTK_WINDOW(top_level), child_ui->lv2ui_resizable());
+ gtk_widget_show_all(vbox);
+ gtk_widget_grab_focus(widget);
+ gtk_window_present(GTK_WINDOW(top_level));
+}
+
+int PluginLV2ChildGtkUI::handle_child()
+{
+ if( gtk_events_pending() ) {
+ gtk_main_iteration();
+ }
+ return 1;
+}
+
+PluginLV2ChildWgtUI::PluginLV2ChildWgtUI(PluginLV2ChildUI *child_ui)
+ : PluginLV2GUI(child_ui)
+{
+}
+
+PluginLV2ChildWgtUI::~PluginLV2ChildWgtUI()
+{
+}
+
+void PluginLV2ChildWgtUI::reset_gui()
+{
+ lv2_external_ui *top_level = (lv2_external_ui *)this->top_level;
+ if( top_level ) { LV2_EXTERNAL_UI_HIDE(top_level); this->top_level = 0; }
+}
+
+void PluginLV2ChildWgtUI::start_gui()
+{
+ child_ui->lv2ui_instantiate(0);
+ this->top_level = (void *)suil_instance_get_widget(child_ui->sinst);
+ lv2_external_ui *top_level = (lv2_external_ui *)this->top_level;
+ if( top_level ) LV2_EXTERNAL_UI_SHOW(top_level);
+}
+
+int PluginLV2ChildWgtUI::handle_child()
+{
+ lv2_external_ui *top_level = (lv2_external_ui *)this->top_level;
+ if( top_level )
+ LV2_EXTERNAL_UI_RUN(top_level);