]> uap-core.de Git - mizunara.git/commitdiff
add mz_files_view_remove_items() for cleaning up child widgets
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 20 Jan 2025 21:01:53 +0000 (22:01 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 20 Jan 2025 21:01:53 +0000 (22:01 +0100)
mizunara/gtk-filesview.c
mizunara/gtk-filesview.h

index 5299b5ab44639f3c82b440f0a0943b85c7e6c07b..0ac84dc066ec682bd5cd362cc059e77fe149a081 100644 (file)
@@ -116,8 +116,6 @@ void mz_files_view_snapshot(GtkWidget *widget, GtkSnapshot *snapshot) {
             y++;
         }
     }
-
-    //gtk_widget_size_allocate(view->items[0].image, &child_allocation, -1);
     
     // draw children
     GtkWidgetClass *cls = mz_files_view_parent_class;
@@ -161,6 +159,7 @@ void mz_update_files_view(MzFilesView *view, FilesSection *sections, size_t nums
     printf("mz_update_files_view\n");
     
     // TODO: free previous files
+    mz_files_view_remove_items(view);
     free(view->items);
     
     
@@ -198,3 +197,10 @@ void mz_update_files_view(MzFilesView *view, FilesSection *sections, size_t nums
     
     gtk_widget_queue_draw(GTK_WIDGET(view));
 }
+
+void mz_files_view_remove_items(MzFilesView *view) {
+    for(size_t i=0;i<view->numitems;i++) {
+        gtk_widget_unparent(view->items[i].image);
+        gtk_widget_unparent(view->items[i].label);
+    }
+}
index f315b22022794fa7bb3950d8f01b154f2577022f..54b691b16c86e512c59200e3facdcdd037ad20cc 100644 (file)
@@ -71,6 +71,8 @@ void mz_files_view_snapshot(GtkWidget *widget, GtkSnapshot *snapshot);
 
 void mz_update_files_view(MzFilesView *view, FilesSection *sections, size_t numsections);
 
+void mz_files_view_remove_items(MzFilesView *view);
+
 #ifdef __cplusplus
 }
 #endif