aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg04-sampler.lv2
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/eg04-sampler.lv2')
-rw-r--r--plugins/eg04-sampler.lv2/sampler.ttl1
-rw-r--r--plugins/eg04-sampler.lv2/sampler_ui.c44
2 files changed, 45 insertions, 0 deletions
diff --git a/plugins/eg04-sampler.lv2/sampler.ttl b/plugins/eg04-sampler.lv2/sampler.ttl
index f705dd1..2a89dd2 100644
--- a/plugins/eg04-sampler.lv2/sampler.ttl
+++ b/plugins/eg04-sampler.lv2/sampler.ttl
@@ -59,6 +59,7 @@
<http://lv2plug.in/plugins/eg-sampler#ui>
a ui:GtkUI ;
lv2:requiredFeature urid:map ;
+ lv2:extensionData ui:showInterface ;
ui:portNotification [
ui:plugin <http://lv2plug.in/plugins/eg-sampler> ;
lv2:symbol "notify" ;
diff --git a/plugins/eg04-sampler.lv2/sampler_ui.c b/plugins/eg04-sampler.lv2/sampler_ui.c
index 3eb1279..d691c98 100644
--- a/plugins/eg04-sampler.lv2/sampler_ui.c
+++ b/plugins/eg04-sampler.lv2/sampler_ui.c
@@ -42,6 +42,7 @@ typedef struct {
GtkWidget* box;
GtkWidget* button;
GtkWidget* label;
+ GtkWidget* window; /* For optional show interface. */
} SamplerUI;
static void
@@ -101,6 +102,7 @@ instantiate(const LV2UI_Descriptor* descriptor,
ui->box = NULL;
ui->button = NULL;
ui->label = NULL;
+ ui->window = NULL;
*widget = NULL;
@@ -170,9 +172,51 @@ port_event(LV2UI_Handle handle,
}
}
+/* Optional non-embedded UI show interface. */
+static int
+ui_show(LV2UI_Handle handle)
+{
+ SamplerUI* ui = (SamplerUI*)handle;
+
+ int argc = 0;
+ gtk_init(&argc, NULL);
+
+ ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_container_add(GTK_CONTAINER(ui->window), ui->box);
+ gtk_widget_show_all(ui->window);
+ gtk_window_present(GTK_WINDOW(ui->window));
+
+ return 0;
+}
+
+/* Optional non-embedded UI hide interface. */
+static int
+ui_hide(LV2UI_Handle handle)
+{
+ return 0;
+}
+
+/* Idle interface for optional non-embedded UI. */
+static int
+ui_idle(LV2UI_Handle handle)
+{
+ SamplerUI* ui = (SamplerUI*)handle;
+ if (ui->window) {
+ gtk_main_iteration();
+ }
+ return 0;
+}
+
static const void*
extension_data(const char* uri)
{
+ static const LV2UI_Show_Interface show = { ui_show, ui_hide };
+ static const LV2UI_Idle_Interface idle = { ui_idle };
+ if (!strcmp(uri, LV2_UI__showInterface)) {
+ return &show;
+ } else if (!strcmp(uri, LV2_UI__idleInterface)) {
+ return &idle;
+ }
return NULL;
}