diff options
author | David Robillard <d@drobilla.net> | 2015-08-30 04:26:55 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-08-30 04:26:55 +0000 |
commit | ef6f6a6718b7b1e9a326b75ad6e4069274a4314f (patch) | |
tree | ceaddd7f2aa27e582909b61bad5acdf7960efcf5 | |
parent | 46d2639b9b10adaa32067d8bf43da48e46c7fafb (diff) | |
download | jalv-ef6f6a6718b7b1e9a326b75ad6e4069274a4314f.tar.gz jalv-ef6f6a6718b7b1e9a326b75ad6e4069274a4314f.tar.bz2 jalv-ef6f6a6718b7b1e9a326b75ad6e4069274a4314f.zip |
Add option to load preset from the command line.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5717 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/jalv.c | 15 | ||||
-rw-r--r-- | src/jalv_gtk.c | 30 | ||||
-rw-r--r-- | src/jalv_internal.h | 1 | ||||
-rw-r--r-- | src/state.c | 4 |
4 files changed, 46 insertions, 4 deletions
@@ -1088,6 +1088,21 @@ main(int argc, char** argv) return EXIT_FAILURE; } + /* Load preset, if specified */ + if (jalv.opts.preset) { + LilvNode* preset = lilv_new_uri(jalv.world, jalv.opts.preset); + + jalv_load_presets(&jalv, NULL, NULL); + state = lilv_state_new_from_world(jalv.world, &jalv.map, preset); + jalv.preset = state; + lilv_node_free(preset); + if (!state) { + fprintf(stderr, "Failed to find preset <%s>\n", jalv.opts.preset); + lilv_world_free(world); + return EXIT_FAILURE; + } + } + /* Check that any required features are supported */ LilvNodes* req_feats = lilv_plugin_get_required_features(jalv.plugin); LILV_FOREACH(nodes, f, req_feats) { diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index 2e95941..e720100 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -87,6 +87,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) "UUID for Jack session restoration", "UUID" }, { "load", 'l', 0, G_OPTION_ARG_STRING, &opts->load, "Load state from save directory", "DIR" }, + { "preset", 'p', 0, G_OPTION_ARG_STRING, &opts->preset, + "Load state from preset", "URI" }, { "dump", 'd', 0, G_OPTION_ARG_NONE, &opts->dump, "Dump plugin <=> UI communication", NULL }, { "show-hidden", 's', 0, G_OPTION_ARG_NONE, &opts->show_hidden, @@ -180,6 +182,22 @@ symbolify(const char* in) } static void +set_window_title(Jalv* jalv) +{ + LilvNode* name = lilv_plugin_get_name(jalv->plugin); + const char* plugin = lilv_node_as_string(name); + if (jalv->preset) { + const char* preset_label = lilv_state_get_label(jalv->preset); + char* title = g_strdup_printf("%s - %s", plugin, preset_label); + gtk_window_set_title(GTK_WINDOW(jalv->window), title); + free(title); + } else { + gtk_window_set_title(GTK_WINDOW(jalv->window), plugin); + } + lilv_node_free(name); +} + +static void on_preset_activate(GtkWidget* widget, gpointer data) { if (GTK_CHECK_MENU_ITEM(widget) != active_preset_item) { @@ -191,6 +209,7 @@ on_preset_activate(GtkWidget* widget, gpointer data) active_preset_item = GTK_CHECK_MENU_ITEM(widget); gtk_check_menu_item_set_active(active_preset_item, TRUE); + set_window_title(record->jalv); } } @@ -395,8 +414,9 @@ on_save_preset_activate(GtkWidget* widget, void* ptr) lilv_world_load_bundle(jalv->world, ldir); lilv_node_free(ldir); - // Rebuild preset menu + // Rebuild preset menu and update window title rebuild_preset_menu(jalv, GTK_CONTAINER(gtk_widget_get_parent(widget))); + set_window_title(jalv); g_free(dir); g_free(file); @@ -438,6 +458,10 @@ on_delete_preset_activate(GtkWidget* widget, void* ptr) rebuild_preset_menu(jalv, GTK_CONTAINER(gtk_widget_get_parent(widget))); } + lilv_state_free(jalv->preset); + jalv->preset = NULL; + set_window_title(jalv); + g_free(msg); gtk_widget_destroy(text); gtk_widget_destroy(dialog); @@ -999,9 +1023,7 @@ jalv_open_ui(Jalv* jalv) g_signal_connect(window, "destroy", G_CALLBACK(on_window_destroy), jalv); - LilvNode* name = lilv_plugin_get_name(jalv->plugin); - gtk_window_set_title(GTK_WINDOW(window), lilv_node_as_string(name)); - lilv_node_free(name); + set_window_title(jalv); GtkWidget* vbox = new_box(false, 0); gtk_window_set_role(GTK_WINDOW(window), "plugin_ui"); diff --git a/src/jalv_internal.h b/src/jalv_internal.h index caf9505..abaf994 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -87,6 +87,7 @@ typedef struct { typedef struct { char* uuid; ///< Session UUID char* load; ///< Path for state to load + char* preset; ///< URI of preset to load char** controls; ///< Control values uint32_t buffer_size; ///< Plugin <= >UI communication buffer size double update_rate; ///< UI update rate in Hz diff --git a/src/state.c b/src/state.c index 618bbf3..4c76859 100644 --- a/src/state.c +++ b/src/state.c @@ -97,6 +97,10 @@ jalv_load_presets(Jalv* jalv, PresetSink sink, void* data) LILV_FOREACH(nodes, i, presets) { const LilvNode* preset = lilv_nodes_get(presets, i); lilv_world_load_resource(jalv->world, preset); + if (!sink) { + continue; + } + LilvNodes* labels = lilv_world_find_nodes( jalv->world, preset, jalv->nodes.rdfs_label, NULL); if (labels) { |