From 4236c7fc3a7c7ef9f79b045cfd99c6575b16f7b1 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 9 Jul 2023 05:23:49 +0200 Subject: page.c: Allow add_element to hide checkboxes Since removing files or directories is currently not an option in searches, it is better to leave checkboxes out to avoid confusion. --- page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/page.c b/page.c index a172031..eb7ae99 100644 --- a/page.c +++ b/page.c @@ -333,7 +333,7 @@ end: } static int add_element(struct html_node *const n, const char *const dir, - const char *const res, const char *const name) + const char *const res, const char *const name, const bool chbx) { int ret = -1; enum {RM_CHECKBOX, NAME, SIZE, DATE, SHARE, PREVIEW, COLUMNS}; @@ -370,7 +370,7 @@ static int add_element(struct html_node *const n, const char *const dir, __func__, path.str, strerror(errno)); goto end; } - else if (strcmp(name, "..") + else if (chbx && strcmp(name, "..") && prepare_rm_checkbox(td[RM_CHECKBOX], &sb, name)) { fprintf(stderr, "%s: prepare_rm_checkbox failed\n", __func__); @@ -1138,7 +1138,7 @@ static int add_elements(const char *const root, const char *const res, if (!strcmp(name, ".") || (!strcmp(name, "..") && !strcmp(root, res))) continue; - else if (add_element(table, dir, res, name)) + else if (add_element(table, dir, res, name, true)) { fprintf(stderr, "%s: add_element failed\n", __func__); goto end; @@ -1784,7 +1784,7 @@ static int add_search_results(struct html_node *const n, { const struct page_search_result *const r = &s->results[i]; - if (add_element(table, "/user/", s->root, r->name)) + if (add_element(table, "/user/", s->root, r->name, false)) { fprintf(stderr, "%s: add_element failed\n", __func__); return -1; -- cgit v1.2.3