aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-02-16 21:37:27 +0100
committerDavid Robillard <d@drobilla.net>2020-02-23 21:05:01 +0100
commit6dd191bef44ebab3a67a1d76b256386b801350c2 (patch)
tree1720115d81744b9e80aa677302ae205d3632d088
parent15f779a8603bc3f020e7000189900c52964771cd (diff)
downloadjalv-ui-request-parameter.tar.gz
jalv-ui-request-parameter.tar.bz2
jalv-ui-request-parameter.zip
WIP: Implement ui:requestValueui-request-parameter
-rw-r--r--src/jalv.c5
-rw-r--r--src/jalv_gtk.c38
-rw-r--r--src/jalv_internal.h3
-rw-r--r--wscript2
4 files changed, 47 insertions, 1 deletions
diff --git a/src/jalv.c b/src/jalv.c
index adee072..b48b6b6 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -411,6 +411,7 @@ jalv_ui_instantiate(Jalv* jalv, const char* native_ui_type, void* parent)
&parent_feature,
&jalv->features.options_feature,
&idle_feature,
+ &jalv->features.request_value_feature,
NULL
};
@@ -844,6 +845,10 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv)
init_feature(&jalv->features.log_feature,
LV2_LOG__log, &jalv->features.llog);
+ jalv->features.request_value.handle = jalv;
+ init_feature(&jalv->features.request_value_feature,
+ LV2_UI__requestValue, &jalv->features.request_value);
+
zix_sem_init(&jalv->done, 0);
zix_sem_init(&jalv->paused, 0);
diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c
index 71259bd..5cf9a97 100644
--- a/src/jalv_gtk.c
+++ b/src/jalv_gtk.c
@@ -630,6 +630,42 @@ patch_put_get(Jalv* jalv,
return 0;
}
+static LV2UI_Request_Value_Status
+on_request_value(LV2UI_Feature_Handle handle,
+ const LV2_URID key,
+ const LV2_URID type,
+ const LV2_Feature* const* features)
+{
+ Jalv* jalv = (Jalv*)handle;
+ ControlID* control = get_property_control(&jalv->controls, key);
+
+ if (!control) {
+ return LV2UI_REQUEST_VALUE_ERR_UNKNOWN;
+ } else if (control->value_type != jalv->forge.Path) {
+ return LV2UI_REQUEST_VALUE_ERR_UNSUPPORTED;
+ }
+
+ GtkWidget* dialog =
+ gtk_file_chooser_dialog_new("Choose file",
+ GTK_WINDOW(jalv->window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+ char* path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+ set_control(control, strlen(path), jalv->forge.Path, path);
+
+ g_free(path);
+ }
+
+ gtk_widget_destroy(dialog);
+
+ return 0;
+}
+
static void
property_changed(Jalv* jalv, LV2_URID key, const LV2_Atom* value)
{
@@ -1197,6 +1233,8 @@ jalv_open_ui(Jalv* jalv)
jalv_ui_instantiate(jalv, jalv_native_ui_type(), alignment);
}
+ jalv->features.request_value.request = on_request_value;
+
if (jalv->ui_instance) {
GtkWidget* widget = (GtkWidget*)suil_instance_get_widget(
jalv->ui_instance);
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 4d25109..b48ca5d 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -39,6 +39,7 @@
#include "lv2/options/options.h"
#include "lv2/resize-port/resize-port.h"
#include "lv2/state/state.h"
+#include "lv2/ui/ui.h"
#include "lv2/urid/urid.h"
#include "lv2/worker/worker.h"
@@ -278,6 +279,8 @@ typedef struct {
LV2_Options_Option options[6];
LV2_Feature options_feature;
LV2_Feature safe_restore_feature;
+ LV2UI_Request_Value request_value;
+ LV2_Feature request_value_feature;
LV2_Extension_Data_Feature ext_data;
} JalvFeatures;
diff --git a/wscript b/wscript
index af363ca..1df76d8 100644
--- a/wscript
+++ b/wscript
@@ -42,7 +42,7 @@ def configure(conf):
conf.load('autowaf', cache=True)
autowaf.set_c_lang(conf, 'c99')
- conf.check_pkg('lv2 >= 1.16.0', uselib_store='LV2')
+ conf.check_pkg('lv2 >= 1.17.2', uselib_store='LV2')
conf.check_pkg('lilv-0 >= 0.24.0', uselib_store='LILV')
conf.check_pkg('serd-0 >= 0.24.0', uselib_store='SERD')
conf.check_pkg('sord-0 >= 0.14.0', uselib_store='SORD')