summaryrefslogtreecommitdiffstats
path: root/src/uis.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-22 20:14:58 +0000
committerDavid Robillard <d@drobilla.net>2011-02-22 20:14:58 +0000
commitfcf7bfe09eb7d4b9a0445ae6f0ac2e933a260189 (patch)
tree48f52cf706ba8af4366e19cc33fbdff3d5338ba1 /src/uis.c
parentaff6b9aaac68a47edc8c644028891f7cc93c7714 (diff)
downloadsuil-fcf7bfe09eb7d4b9a0445ae6f0ac2e933a260189.tar.gz
suil-fcf7bfe09eb7d4b9a0445ae6f0ac2e933a260189.tar.bz2
suil-fcf7bfe09eb7d4b9a0445ae6f0ac2e933a260189.zip
Implement sane UI selection logic and separate it from instantiation.
Cleaner instantiation code. git-svn-id: http://svn.drobilla.net/lad/trunk/suil@3013 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/uis.c')
-rw-r--r--src/uis.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/uis.c b/src/uis.c
index 1880254..2ba234a 100644
--- a/src/uis.c
+++ b/src/uis.c
@@ -42,6 +42,48 @@ suil_uis_free(SuilUIs uis)
}
SUIL_API
+const char*
+suil_uis_get_plugin_uri(SuilUIs uis)
+{
+ return uis->plugin_uri;
+}
+
+SUIL_API
+SuilUI
+suil_uis_get(SuilUIs uis,
+ const char* ui_uri)
+{
+ for (unsigned i = 0; i < uis->n_uis; ++i) {
+ if (!strcmp(uis->uis[i]->uri, ui_uri)) {
+ return uis->uis[i];
+ }
+ }
+ return NULL;
+}
+
+SUIL_API
+SuilUI
+suil_uis_get_best(SuilUIs uis,
+ const char* type_uri)
+{
+ // Check for an exact type match
+ for (unsigned i = 0; i < uis->n_uis; ++i) {
+ if (!strcmp(uis->uis[i]->type_uri, type_uri)) {
+ return uis->uis[i];
+ }
+ }
+
+ // No exact match, use the first supported UI
+ for (unsigned i = 0; i < uis->n_uis; ++i) {
+ if (suil_ui_type_supported(type_uri, uis->uis[i]->type_uri)) {
+ return uis->uis[i];
+ }
+ }
+
+ return NULL;
+}
+
+SUIL_API
void
suil_uis_add(SuilUIs uis,
const char* uri,