aboutsummaryrefslogtreecommitdiffstats
path: root/src/query.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-17 17:59:48 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 19:07:21 -0500
commit30ec5250ca9963ecbab37a6103fdbd2ea0fcdc90 (patch)
tree960648ac973fd6f96ab1d53518c0934eae112c4a /src/query.c
parente00df6c4764e2eb0fcef8bbe2b052680cd8fb02a (diff)
downloadjalv-30ec5250ca9963ecbab37a6103fdbd2ea0fcdc90.tar.gz
jalv-30ec5250ca9963ecbab37a6103fdbd2ea0fcdc90.tar.bz2
jalv-30ec5250ca9963ecbab37a6103fdbd2ea0fcdc90.zip
Move general model query functions to a separate file
Diffstat (limited to 'src/query.c')
-rw-r--r--src/query.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/query.c b/src/query.c
new file mode 100644
index 0000000..f3b9724
--- /dev/null
+++ b/src/query.c
@@ -0,0 +1,53 @@
+// Copyright 2012-2024 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#include "query.h"
+
+#include "lv2/core/lv2.h"
+#include "lv2/ui/ui.h"
+
+bool
+jalv_port_has_designation(const JalvNodes* const nodes,
+ const LilvPlugin* const plugin,
+ const LilvPort* const port,
+ const LilvNode* const designation)
+{
+ LilvNodes* const designations =
+ lilv_port_get_value(plugin, port, nodes->lv2_designation);
+
+ bool found = false;
+ LILV_FOREACH (nodes, n, designations) {
+ const LilvNode* const node = lilv_nodes_get(designations, n);
+ if (lilv_node_equals(node, designation)) {
+ found = true;
+ break;
+ }
+ }
+
+ lilv_nodes_free(designations);
+ return found;
+}
+
+bool
+jalv_ui_is_resizable(LilvWorld* const world, const LilvUI* const ui)
+{
+ if (!ui) {
+ return false;
+ }
+
+ const LilvNode* s = lilv_ui_get_uri(ui);
+ LilvNode* p = lilv_new_uri(world, LV2_CORE__optionalFeature);
+ LilvNode* fs = lilv_new_uri(world, LV2_UI__fixedSize);
+ LilvNode* nrs = lilv_new_uri(world, LV2_UI__noUserResize);
+
+ LilvNodes* fs_matches = lilv_world_find_nodes(world, s, p, fs);
+ LilvNodes* nrs_matches = lilv_world_find_nodes(world, s, p, nrs);
+
+ lilv_nodes_free(nrs_matches);
+ lilv_nodes_free(fs_matches);
+ lilv_node_free(nrs);
+ lilv_node_free(fs);
+ lilv_node_free(p);
+
+ return !fs_matches && !nrs_matches;
+}