From 6721ea54b752b183c45bac83d705f7de40e74fd1 Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Sun, 22 Oct 2017 18:30:20 +0200 Subject: Add a command line argument to select a specific UI --- NEWS | 3 ++- doc/jalv.1 | 4 ++++ doc/jalv.gtk.1 | 4 ++++ src/jalv.c | 9 +++++++++ src/jalv_console.c | 7 +++++++ src/jalv_gtk.c | 2 ++ src/jalv_internal.h | 1 + 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ad9abed..d22aa6a 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,9 @@ jalv (1.6.5) unstable; * Support port events for ui:showInterface UIs + * Add a command line argument to select a specific UI - -- David Robillard Sun, 05 Apr 2020 07:39:19 +0000 + -- David Robillard Sun, 05 Apr 2020 11:14:53 +0000 jalv (1.6.4) stable; diff --git a/doc/jalv.1 b/doc/jalv.1 index 9f65001..3f4fd73 100644 --- a/doc/jalv.1 +++ b/doc/jalv.1 @@ -20,6 +20,10 @@ Set control value (e.g. "vol=1.4"). \fB\-d\fR Dump plugin <=> UI communication. +.TP +\fB\-U URI\fR +Load the UI with the given URI. + .TP \fB\-h\fR Print the command line options. diff --git a/doc/jalv.gtk.1 b/doc/jalv.gtk.1 index 5177e1d..8062e06 100644 --- a/doc/jalv.gtk.1 +++ b/doc/jalv.gtk.1 @@ -20,6 +20,10 @@ Set control value (e.g. "vol=1.4"). \fB\-d\fR, \fB\-\-dump\fR Dump plugin <=> UI communication. +.TP +\fB\-U URI\fR +Load the UI with the given URI. + .TP \fB\-g\fR, \fB\-\-generic\-ui\fR Use Jalv generic UI and not the plugin UI. diff --git a/src/jalv.c b/src/jalv.c index c54d7ad..09b15e3 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -737,6 +737,15 @@ jalv_select_custom_ui(const Jalv* const jalv) { const char* const native_ui_type_uri = jalv_native_ui_type(); + if (jalv->opts.ui_uri) { + // Specific UI explicitly requested by user + LilvNode* uri = lilv_new_uri(jalv->world, jalv->opts.ui_uri); + const LilvUI* ui = lilv_uis_get_by_uri(jalv->uis, uri); + + lilv_node_free(uri); + return ui; + } + #ifdef HAVE_SUIL if (native_ui_type_uri) { // Try to find an embeddable UI diff --git a/src/jalv_console.c b/src/jalv_console.c index a97b388..2d4a197 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -38,6 +38,7 @@ print_usage(const char* name, bool error) fprintf(os, " -b SIZE Buffer size for plugin <=> UI communication\n"); fprintf(os, " -c SYM=VAL Set control value (e.g. \"vol=1.4\")\n"); fprintf(os, " -d Dump plugin <=> UI communication\n"); + fprintf(os, " -U URI Load the UI with the given URI\n"); fprintf(os, " -h Display this help and exit\n"); fprintf(os, " -l DIR Load state from save directory\n"); fprintf(os, " -n NAME JACK client name\n"); @@ -74,6 +75,12 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) opts->show_ui = true; } else if ((*argv)[a][1] == 'p') { opts->print_controls = true; + } else if ((*argv)[a][1] == 'U') { + if (++a == *argc) { + fprintf(stderr, "Missing argument for -U\n"); + return 1; + } + opts->ui_uri = jalv_strdup((*argv)[a]); } else if ((*argv)[a][1] == 'u') { if (++a == *argc) { fprintf(stderr, "Missing argument for -u\n"); diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index bd9bc36..375ea76 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -97,6 +97,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) "Load state from preset", "URI" }, { "dump", 'd', 0, G_OPTION_ARG_NONE, &opts->dump, "Dump plugin <=> UI communication", NULL }, + { "ui-uri", 'U', 0, G_OPTION_ARG_STRING, &opts->ui_uri, + "Load the UI with the given URI", "URI" }, { "trace", 't', 0, G_OPTION_ARG_NONE, &opts->trace, "Print trace messages from plugin", NULL }, { "show-hidden", 's', 0, G_OPTION_ARG_NONE, &opts->show_hidden, diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 0e76fd0..855cf62 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -175,6 +175,7 @@ typedef struct { int show_ui; ///< Show non-embedded UI int print_controls; ///< Print control changes to stdout int non_interactive; ///< Do not listen for commands on stdin + char* ui_uri; ///< URI of UI to load } JalvOptions; typedef struct { -- cgit v1.2.1