From c651bff4be13834ad3be14eca9737c563fdf7d1f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Jul 2014 19:49:15 +0000 Subject: Support saving the same preset several times. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5414 a436a847-0d15-0410-975c-d299462d15a1 --- src/jalv_gtk.c | 9 ++++++++- src/jalv_internal.h | 3 +++ src/state.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index 8e9259f..91dca45 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -257,9 +257,16 @@ on_save_preset_activate(GtkWidget* widget, void* ptr) jalv_save_preset(jalv, dir, (strlen(uri) ? uri : NULL), basename, file); - // Load preset so it is now known to LilvWorld SerdNode sdir = serd_node_new_file_uri((const uint8_t*)dir, 0, 0, 0); LilvNode* ldir = lilv_new_uri(jalv->world, (const char*)sdir.buf); + + // Unload all presets and any old information from this bundle + jalv_unload_presets(jalv); + printf("Unload bundle %s\n", lilv_node_as_string(ldir)); + lilv_world_unload_bundle(jalv->world, ldir); + + // Load preset so it is now known to LilvWorld + printf("Load bundle %s\n", lilv_node_as_string(ldir)); lilv_world_load_bundle(jalv->world, ldir); serd_node_free(&sdir); lilv_node_free(ldir); diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 64b490a..af562f9 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -265,6 +265,9 @@ typedef int (*PresetSink)(Jalv* jalv, int jalv_load_presets(Jalv* jalv, PresetSink sink, void* data); +int +jalv_unload_presets(Jalv* jalv); + int jalv_apply_preset(Jalv* jalv, const LilvNode* preset); diff --git a/src/state.c b/src/state.c index 4e9cdd7..108723d 100644 --- a/src/state.c +++ b/src/state.c @@ -101,6 +101,7 @@ jalv_load_presets(Jalv* jalv, PresetSink sink, void* data) jalv->nodes.pset_Preset); LILV_FOREACH(nodes, i, presets) { const LilvNode* preset = lilv_nodes_get(presets, i); + printf("Preset: %s\n", lilv_node_as_uri(preset)); lilv_world_load_resource(jalv->world, preset); LilvNodes* labels = lilv_world_find_nodes( jalv->world, preset, jalv->nodes.rdfs_label, NULL); @@ -118,6 +119,20 @@ jalv_load_presets(Jalv* jalv, PresetSink sink, void* data) return 0; } +int +jalv_unload_presets(Jalv* jalv) +{ + LilvNodes* presets = lilv_plugin_get_related(jalv->plugin, + jalv->nodes.pset_Preset); + LILV_FOREACH(nodes, i, presets) { + const LilvNode* preset = lilv_nodes_get(presets, i); + lilv_world_unload_resource(jalv->world, preset); + } + lilv_nodes_free(presets); + + return 0; +} + static void set_port_value(const char* port_symbol, void* user_data, -- cgit v1.2.1