aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-04-28 12:42:33 -0400
committerSam Anthony <sam@samanthony.xyz>2025-04-28 12:42:33 -0400
commit8dbf0d70b04b7dbb995a74e1f5ee183228ab80ac (patch)
tree0b1684bf8c9c66b614dd52a1b6b2f7461fc8726c
parentba1170ac0504fbe7cf96a9d6515477ed8de1b29d (diff)
downloadvolute-8dbf0d70b04b7dbb995a74e1f5ee183228ab80ac.zip
add filter string buffers to compressor-select widget
-rw-r--r--widget.c24
-rw-r--r--widget.h8
2 files changed, 20 insertions, 12 deletions
diff --git a/widget.c b/widget.c
index 7460d41..940a433 100644
--- a/widget.c
+++ b/widget.c
@@ -119,16 +119,6 @@ w_init_select_compressor(w_Select_Compressor *select, int n, const Compressor *c
select->comps = comps;
select->n = n;
- select->filtered = malloc(n * sizeof(*select->filtered));
- if (select->filtered == NULL) {
- return 1;
- }
- /* TODO: parallelize. */
- for (i = 0; i < n; i++) {
- select->filtered[i] = i;
- }
- select->nfiltered = n;
-
namesize = sizeof((*comps).brand) + sizeof((*comps).series) + sizeof((*comps).model) + 3;
select->names = malloc(n * sizeof(*select->names));
if (select->names == NULL) {
@@ -147,6 +137,20 @@ w_init_select_compressor(w_Select_Compressor *select, int n, const Compressor *c
comps[i].brand, comps[i].series, comps[i].model);
}
+ memset(select->brand_filter, 0, sizeof(select->brand_filter));
+ memset(select->series_filter, 0, sizeof(select->series_filter));
+ memset(select->model_filter, 0, sizeof(select->model_filter));
+
+ select->filtered = malloc(n * sizeof(*select->filtered));
+ if (select->filtered == NULL) {
+ return 1;
+ }
+ /* TODO: parallelize. */
+ for (i = 0; i < n; i++) {
+ select->filtered[i] = i;
+ }
+ select->nfiltered = n;
+
select->idx = 0;
select -> oldidx = 0;
diff --git a/widget.h b/widget.h
index 34e6edf..e1bbf2c 100644
--- a/widget.h
+++ b/widget.h
@@ -33,11 +33,15 @@ typedef struct {
const Compressor *comps;
int n; /* len(comps) */
+ char **names; /* buffer to hold names of compressors. */
+
+ char brand_filter[NAME_SIZE];
+ char series_filter[NAME_SIZE];
+ char model_filter[NAME_SIZE];
+
int *filtered; /* indices of compressors accepted by the filter. */
int nfiltered; /* len(filtered) */
- char **names; /* buffer to hold names of compressors. */
-
int idx; /* index of selected in filtered. */
int oldidx; /* index of previously selected. */