diff options
author | David Robillard <d@drobilla.net> | 2011-04-22 06:26:38 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-22 06:26:38 +0000 |
commit | beccc26909e9976d33f3be2951b6ef8cd63353ff (patch) | |
tree | 16a48029560ae8f78580827c75ce53f7596ebc6d /src | |
parent | 12defde9074ff2b6f4588960151f3ce41441c266 (diff) | |
download | lilv-beccc26909e9976d33f3be2951b6ef8cd63353ff.tar.gz lilv-beccc26909e9976d33f3be2951b6ef8cd63353ff.tar.bz2 lilv-beccc26909e9976d33f3be2951b6ef8cd63353ff.zip |
Remove UI instance API from SLV2 (apps should implement UIs via Suil now).
Remove UI extension API and header from public APIs entirely.
Rework UI instance API to support multiple UIs and a more precise notion of embedding support.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3186 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 62 | ||||
-rw-r--r-- | src/pluginui.c | 26 | ||||
-rw-r--r-- | src/pluginuiinstance.c | 200 | ||||
-rw-r--r-- | src/slv2_internal.h | 13 |
4 files changed, 18 insertions, 283 deletions
diff --git a/src/plugin.c b/src/plugin.c index ea48507..ceac7c8 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -826,65 +826,3 @@ slv2_plugin_get_uis(SLV2Plugin p) return NULL; } } - -SLV2_API -SLV2UI -slv2_plugin_get_default_ui(SLV2Plugin p, - SLV2Value widget_type_uri) -{ -#ifdef HAVE_SUIL - SLV2Node ui_ui_node = sord_new_uri(p->world->world, NS_UI "ui"); - SLV2Node ui_binary_node = sord_new_uri(p->world->world, NS_UI "binary"); - - SLV2Matches uis = slv2_plugin_find_statements( - p, - p->plugin_uri->val.uri_val, - ui_ui_node, - NULL); - - SLV2UI native = NULL; - SLV2UI foreign = NULL; - FOREACH_MATCH(uis) { - SLV2Node ui = slv2_match_object(uis); - SLV2Value type = slv2_plugin_get_unique(p, ui, p->world->rdf_a_node); - SLV2Value binary = slv2_plugin_get_unique(p, ui, ui_binary_node); - - if (sord_node_get_type(ui) != SORD_URI - || !slv2_value_is_uri(type) - || !slv2_value_is_uri(binary)) { - slv2_value_free(binary); - slv2_value_free(type); - SLV2_ERROR("Corrupt UI\n"); - continue; - } - - if (!native && slv2_value_equals(type, widget_type_uri)) { - native = slv2_ui_new( - p->world, - slv2_value_new_from_node(p->world, ui), - type, - binary); - break; - } else if (!foreign && suil_ui_type_supported( - slv2_value_as_uri(widget_type_uri), - slv2_value_as_uri(type))) { - foreign = slv2_ui_new( - p->world, - slv2_value_new_from_node(p->world, ui), - type, - binary); - } else { - slv2_value_free(binary); - slv2_value_free(type); - } - } - slv2_match_end(uis); - - slv2_node_free(p->world, ui_binary_node); - slv2_node_free(p->world, ui_ui_node); - - return (native) ? native : foreign; -#else - return NULL; -#endif -} diff --git a/src/pluginui.c b/src/pluginui.c index c81a5dd..fdc32ea 100644 --- a/src/pluginui.c +++ b/src/pluginui.c @@ -90,17 +90,27 @@ slv2_ui_get_uri(SLV2UI ui) } SLV2_API -bool -slv2_ui_supported(SLV2UI ui, - SLV2Value widget_type_uri) +unsigned +slv2_ui_is_supported(SLV2UI ui, + SLV2UISupportedFunc supported_func, + SLV2Value container_type, + SLV2Value* ui_type) { #ifdef HAVE_SUIL - return suil_ui_type_supported( - slv2_value_as_uri(widget_type_uri), - slv2_value_as_uri(slv2_values_get_first(ui->classes))); -#else - return false; + SLV2Values classes = slv2_ui_get_classes(ui); + SLV2_FOREACH(c, classes) { + SLV2Value type = slv2_values_get(classes, c); + const unsigned q = supported_func(slv2_value_as_uri(container_type), + slv2_value_as_uri(type)); + if (q) { + if (ui_type) { + *ui_type = slv2_value_duplicate(type); + } + return q; + } + } #endif + return 0; } SLV2_API diff --git a/src/pluginuiinstance.c b/src/pluginuiinstance.c deleted file mode 100644 index 6231705..0000000 --- a/src/pluginuiinstance.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - Copyright 2011 David Robillard <http://drobilla.net> - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _XOPEN_SOURCE 500 - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifdef HAVE_SUIL -#include "suil/suil.h" -#endif - -#include "slv2_internal.h" - -SLV2_DEPRECATED -SLV2_API -SLV2UIInstance -slv2_ui_instantiate(SLV2Plugin plugin, - SLV2UI ui, - LV2UI_Write_Function write_function, - LV2UI_Controller controller, - const LV2_Feature* const* features) -{ - SLV2UIHost ui_host = slv2_ui_host_new(write_function, NULL, NULL, NULL); - - SLV2UIInstance ret = slv2_ui_instance_new( - plugin, ui, NULL, ui_host, controller, features); - - slv2_ui_host_free(ui_host); - return ret; -} - -SLV2_API -SLV2UIHost -slv2_ui_host_new(LV2UI_Write_Function write_function, - SLV2PortIndexFunction port_index_function, - SLV2PortSubscribeFunction port_subscribe_function, - SLV2PortUnsubscribeFunction port_unsubscribe_function) -{ - SLV2UIHost ret = malloc(sizeof(struct _SLV2UIHost)); - ret->write_function = write_function; - ret->port_index_function = port_index_function; - ret->port_subscribe_function = port_subscribe_function; - ret->port_unsubscribe_function = port_unsubscribe_function; - return ret; -} - -SLV2_API -void -slv2_ui_host_free(SLV2UIHost ui_host) -{ - free(ui_host); -} - -SLV2_API -SLV2UIInstance -slv2_ui_instance_new(SLV2Plugin plugin, - SLV2UI ui, - SLV2Value widget_type_uri, - SLV2UIHost ui_host, - LV2UI_Controller controller, - const LV2_Feature* const* features) -{ -#ifdef HAVE_SUIL - const char* const bundle_uri = slv2_value_as_uri(slv2_ui_get_bundle_uri(ui)); - const char* const bundle_path = slv2_uri_to_path(bundle_uri); - const char* const lib_uri = slv2_value_as_string(slv2_ui_get_binary_uri(ui)); - const char* const lib_path = slv2_uri_to_path(lib_uri); - if (!bundle_path || !lib_path) { - return NULL; - } - - SLV2Value ui_type = slv2_values_get_first(ui->classes); - if (!widget_type_uri) { - widget_type_uri = ui_type; - } - - SuilInstance suil_instance = suil_instance_new( - slv2_value_as_uri(slv2_plugin_get_uri(plugin)), - slv2_value_as_uri(slv2_ui_get_uri(ui)), - bundle_path, - lib_path, - slv2_value_as_uri(ui_type), - slv2_value_as_uri(widget_type_uri), - ui_host->write_function, - controller, - features); - - if (!suil_instance) { - return NULL; - } - - // Create SLV2UIInstance to return - struct _SLV2UIInstance* result = malloc(sizeof(struct _SLV2UIInstance)); - result->instance = suil_instance; - - return result; -#else - return NULL; -#endif -} - -SLV2_API -void -slv2_ui_instance_free(SLV2UIInstance instance) -{ -#ifdef HAVE_SUIL - if (instance) { - suil_instance_free(instance->instance); - free(instance); - } -#else - return NULL; -#endif -} - -SLV2_API -LV2UI_Widget -slv2_ui_instance_get_widget(SLV2UIInstance instance) -{ -#ifdef HAVE_SUIL - return suil_instance_get_widget(instance->instance); -#else - return NULL; -#endif -} - -SLV2_API -void -slv2_ui_instance_port_event(SLV2UIInstance instance, - uint32_t port_index, - uint32_t buffer_size, - uint32_t format, - const void* buffer) -{ - suil_instance_port_event(instance->instance, - port_index, - buffer_size, - format, - buffer); -} - -SLV2_API -const void* -slv2_ui_instance_extension_data(SLV2UIInstance instance, - const char* uri) -{ -#ifdef HAVE_SUIL - return suil_instance_extension_data(instance->instance, uri); -#else - return NULL; -#endif -} - -SLV2_API -const LV2UI_Descriptor* -slv2_ui_instance_get_descriptor(SLV2UIInstance instance) -{ -#ifdef HAVE_SUIL - return suil_instance_get_descriptor(instance->instance); -#else - return NULL; -#endif -} - -SLV2_API -LV2UI_Handle -slv2_ui_instance_get_handle(SLV2UIInstance instance) -{ -#ifdef HAVE_SUIL - return suil_instance_get_handle(instance->instance); -#else - return NULL; -#endif -} - diff --git a/src/slv2_internal.h b/src/slv2_internal.h index 5facad3..5a2d2c7 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -185,19 +185,6 @@ struct _SLV2InstanceImpl { void* lib_handle; }; -/* ********* UI Instance ********* */ - -struct _SLV2UIInstance { - SuilInstance instance; -}; - -struct _SLV2UIHost { - LV2UI_Write_Function write_function; - SLV2PortIndexFunction port_index_function; - SLV2PortSubscribeFunction port_subscribe_function; - SLV2PortUnsubscribeFunction port_unsubscribe_function; -}; - /* ********* Plugin Class ********* */ struct _SLV2PluginClass { |