summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-24 09:00:54 +0000
committerDavid Robillard <d@drobilla.net>2011-02-24 09:00:54 +0000
commit25bd8988fb82e6132ae6c1b87e6d0b8087d61f1b (patch)
tree63d8b4a0a69c07d012af30b711a0a9cb80a160e6 /src/plugin.c
parent5a7ed3f46fa2e0151a0f403824ae3a7df10a6c34 (diff)
downloadlilv-25bd8988fb82e6132ae6c1b87e6d0b8087d61f1b.tar.gz
lilv-25bd8988fb82e6132ae6c1b87e6d0b8087d61f1b.tar.bz2
lilv-25bd8988fb82e6132ae6c1b87e6d0b8087d61f1b.zip
Make Suil exclusively deal with instantiating (not choosing) UIs.
Add slv2_ui_instance_new as a replacement for slv2_ui_instantiate (now deprecated), which supports cross-toolkit embedding by taking an additional widget type pointer. Remove direct Suil dependency from Ingen. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3022 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c82
1 files changed, 74 insertions, 8 deletions
diff --git a/src/plugin.c b/src/plugin.c
index f06cfd7..14a4266 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -27,8 +27,17 @@
#include <dlfcn.h>
#endif
+#include "slv2-config.h"
#include "slv2_internal.h"
+#ifdef HAVE_SUIL
+#include "suil/suil.h"
+#endif
+
+#define NS_UI (const uint8_t*)"http://lv2plug.in/ns/extensions/ui#"
+#define NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
+#define NS_FOAF (const uint8_t*)"http://xmlns.com/foaf/0.1/"
+
/** Ownership of @a uri is taken */
SLV2Plugin
slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri)
@@ -694,9 +703,6 @@ slv2_plugin_get_port_by_symbol(SLV2Plugin p,
return NULL;
}
-#define NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
-#define NS_FOAF (const uint8_t*)"http://xmlns.com/foaf/0.1/"
-
static SLV2Node
slv2_plugin_get_author(SLV2Plugin p)
{
@@ -764,16 +770,14 @@ SLV2_API
SLV2UIs
slv2_plugin_get_uis(SLV2Plugin p)
{
-#define NS_UI (const uint8_t*)"http://lv2plug.in/ns/extensions/ui#"
-
- SLV2Node ui_ui = sord_new_uri(p->world->world, NS_UI "ui");
+ 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");
SLV2UIs result = slv2_uis_new();
SLV2Matches uis = slv2_plugin_find_statements(
p,
p->plugin_uri->val.uri_val,
- ui_ui,
+ ui_ui_node,
NULL);
FOREACH_MATCH(uis) {
@@ -801,7 +805,7 @@ slv2_plugin_get_uis(SLV2Plugin p)
slv2_match_end(uis);
slv2_node_free(ui_binary_node);
- slv2_node_free(ui_ui);
+ slv2_node_free(ui_ui_node);
if (slv2_uis_size(result) > 0) {
return result;
@@ -810,3 +814,65 @@ 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(ui_binary_node);
+ slv2_node_free(ui_ui_node);
+
+ return (native) ? native : foreign;
+#else
+ return NULL;
+#endif
+}