]> uap-core.de Git - mizunara.git/commitdiff
store FilesSection array in the filesview master
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 29 May 2025 07:27:07 +0000 (09:27 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 29 May 2025 07:27:07 +0000 (09:27 +0200)
mizunara/Makefile
mizunara/application.h
mizunara/filebrowser.c
mizunara/files.c [new file with mode: 0644]
mizunara/files.h [new file with mode: 0644]
mizunara/gtk-filesview.c
mizunara/gtk-filesview.h

index ac23d64c6e9cfe1fafad22c7e0b7e878f608fc3a..1445ec887abf0602db872e493879b04b90c8b7e3 100644 (file)
@@ -38,6 +38,7 @@ SRC += window.c
 SRC += filebrowser.c
 SRC += gtk-filesview.c
 SRC += bookmarks.c
 SRC += filebrowser.c
 SRC += gtk-filesview.c
 SRC += bookmarks.c
+SRC += files.c
 
 SRC += $(MZUI)
 
 
 SRC += $(MZUI)
 
index 0780cd791e94c64d5e0169819649a1f9047e5330..9a341012c62b4154b066105ea348e4def872b705 100644 (file)
@@ -135,7 +135,7 @@ struct FilesSection {
 };
 
 struct FileInfo {
 };
 
 struct FileInfo {
-    char *parent;
+    const char *parent;
     char *name;
     size_t size;
     time_t mtime;
     char *name;
     size_t size;
     time_t mtime;
index 857fb023aafd0c36bfe398cb95dd7419d0cc748d..f11a11a5235dacfc0a80925520533af7d5e1cf62 100644 (file)
@@ -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) {   
     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;
             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 (file)
index 0000000..a9aadfe
--- /dev/null
@@ -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;i<nsections;i++) {
+        CxIterator iter = cxListIterator(s->files);
+        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 (file)
index 0000000..495c35f
--- /dev/null
@@ -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 */
+
index d35c3e302c759f27b3d7b2e611eb7a543b941c7b..01a81befe62a87b89a3803dd47bfe57d03f5507c 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include "gtk-filesview.h"
  */
 
 #include "gtk-filesview.h"
+#include "files.h"
 
 #include <sys/stat.h>
 #include <sys/types.h>
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -664,6 +665,10 @@ void mz_update_files_view(MzFilesView *view, FilesSection *sections, size_t nums
     free(view->items);
     
     
     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<numsections;i++) {
     view->sections = calloc(numsections, sizeof(MzFilesView));
     size_t nchildren = 0;
     for(size_t i=0;i<numsections;i++) {
index 953eef002330de4d01c34746bb6646e7a653ffd7..58bd152ea350fbd78533041e300419353ca19a1b 100644 (file)
@@ -60,6 +60,9 @@ typedef struct MzFilesView {
     void (*open)(FileInfo **files, size_t numfiles, void *userdata);
     void *open_userdata;
     
     void (*open)(FileInfo **files, size_t numfiles, void *userdata);
     void *open_userdata;
     
+    FilesSection *filessections;
+    size_t num_filessections;
+    
     MzIconGadget *items;
     size_t numitems;
     
     MzIconGadget *items;
     size_t numitems;