From: Olaf Wintermann Date: Thu, 29 May 2025 07:27:07 +0000 (+0200) Subject: store FilesSection array in the filesview X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;ds=sidebyside;p=mizunara.git store FilesSection array in the filesview --- diff --git a/mizunara/Makefile b/mizunara/Makefile index ac23d64..1445ec8 100644 --- a/mizunara/Makefile +++ b/mizunara/Makefile @@ -38,6 +38,7 @@ SRC += window.c SRC += filebrowser.c SRC += gtk-filesview.c SRC += bookmarks.c +SRC += files.c SRC += $(MZUI) diff --git a/mizunara/application.h b/mizunara/application.h index 0780cd7..9a34101 100644 --- a/mizunara/application.h +++ b/mizunara/application.h @@ -135,7 +135,7 @@ struct FilesSection { }; struct FileInfo { - char *parent; + const char *parent; char *name; size_t size; time_t mtime; diff --git a/mizunara/filebrowser.c b/mizunara/filebrowser.c index 857fb02..f11a11a 100644 --- a/mizunara/filebrowser.c +++ b/mizunara/filebrowser.c @@ -143,8 +143,6 @@ void filebrowser_op_finished(UiEvent *event, void *data) { if(op->result) { int view = ui_get(op->browser->view); if(view == 0 && op->browser->update_grid) { - // TODO: group feature - // for now, just create a single section and move the result list FilesSection *section = malloc(sizeof(FilesSection)); memset(section, 0, sizeof(FilesSection)); section->files = op->result; diff --git a/mizunara/files.c b/mizunara/files.c new file mode 100644 index 0000000..a9aadfe --- /dev/null +++ b/mizunara/files.c @@ -0,0 +1,44 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "files.h" + +void files_section_free(FilesSection *s, size_t nsections) { + if(!s) { + return; + } + + for(size_t i=0;ifiles); + cx_foreach(FileInfo *, file, iter) { + free(file->name); + } + free(s->parent_url); + } + free(s); +} diff --git a/mizunara/files.h b/mizunara/files.h new file mode 100644 index 0000000..495c35f --- /dev/null +++ b/mizunara/files.h @@ -0,0 +1,46 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2025 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef MZ_FILES_H +#define MZ_FILES_H + +#include "application.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void files_section_free(FilesSection *s, size_t nsections); + + +#ifdef __cplusplus +} +#endif + +#endif /* MZ_FILES_H */ + diff --git a/mizunara/gtk-filesview.c b/mizunara/gtk-filesview.c index d35c3e3..01a81be 100644 --- a/mizunara/gtk-filesview.c +++ b/mizunara/gtk-filesview.c @@ -27,6 +27,7 @@ */ #include "gtk-filesview.h" +#include "files.h" #include #include @@ -664,6 +665,10 @@ void mz_update_files_view(MzFilesView *view, FilesSection *sections, size_t nums free(view->items); + files_section_free(view->filessections, view->num_filessections); + view->filessections = sections; + view->num_filessections = numsections; + view->sections = calloc(numsections, sizeof(MzFilesView)); size_t nchildren = 0; for(size_t i=0;i