fortrangoingonforty/sniffly / d20fd3b

Browse files

I forget honestly oh yeah removal of search/filter widget grabber

Authored by espadonne
SHA
d20fd3bd47722758f6bf18b27d186931be199554
Parents
4425e28
Tree
68b9d0b

2 changed files

StatusFile+-
M src/gui/gtk_app.f90 2 44
M src/rendering/treemap_renderer.f90 3 112
src/gui/gtk_app.f90modified
@@ -44,7 +44,6 @@ module gtk_app
4444
   type(c_ptr), save :: breadcrumb_label_ptr = c_null_ptr
4545
   type(c_ptr), save :: progress_bar_ptr = c_null_ptr
4646
   type(c_ptr), save :: path_entry_ptr = c_null_ptr
47
-  type(c_ptr), save :: search_entry_ptr = c_null_ptr
4847
 
4948
   ! Global scan path (can be set via command line)
5049
   character(len=512), save :: global_scan_path = ""
@@ -177,20 +176,13 @@ contains
177176
     ! Add toolbar to main box
178177
     call gtk_box_append(main_box, toolbar)
179178
 
180
-    ! Create breadcrumb bar (horizontal box with path label and search entry)
179
+    ! Create breadcrumb bar (horizontal box with path label)
181180
     breadcrumb_bar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5_c_int)
182181
     breadcrumb_label_ptr = gtk_label_new(""//c_null_char)  ! Will be set by first render
183182
     call gtk_widget_set_halign(breadcrumb_label_ptr, GTK_ALIGN_START)
184
-    call gtk_widget_set_hexpand(breadcrumb_label_ptr, 1_c_int)  ! Expand to push search to right
183
+    call gtk_widget_set_hexpand(breadcrumb_label_ptr, 1_c_int)
185184
     call gtk_box_append(breadcrumb_bar, breadcrumb_label_ptr)
186185
 
187
-    ! Create search/filter entry
188
-    search_entry_ptr = gtk_entry_new()
189
-    call gtk_entry_set_placeholder_text(search_entry_ptr, "Filter by filename..."//c_null_char)
190
-    call g_signal_connect(search_entry_ptr, "changed"//c_null_char, &
191
-                          c_funloc(on_search_changed), c_null_ptr)
192
-    call gtk_box_append(breadcrumb_bar, search_entry_ptr)
193
-
194186
     ! Add breadcrumb bar to main box
195187
     call gtk_box_append(main_box, breadcrumb_bar)
196188
 
@@ -369,40 +361,6 @@ contains
369361
     end if
370362
   end subroutine on_delete_clicked
371363
 
372
-  ! Callback when search/filter entry text changes
373
-  subroutine on_search_changed(editable, user_data) bind(c)
374
-    use gtk, only: gtk_widget_queue_draw
375
-    use treemap_renderer, only: set_filter_pattern, invalidate_layout
376
-    type(c_ptr), value :: editable, user_data
377
-    type(c_ptr) :: text_ptr
378
-    character(len=256) :: search_text
379
-    integer :: i
380
-
381
-    if (.not. c_associated(search_entry_ptr)) return
382
-
383
-    ! Get the text from the search entry
384
-    text_ptr = gtk_editable_get_text(search_entry_ptr)
385
-
386
-    ! Convert C string to Fortran string
387
-    search_text = ""
388
-    if (c_associated(text_ptr)) then
389
-      call c_f_string(text_ptr, search_text)
390
-    end if
391
-
392
-    print *, "Search filter changed: '", trim(search_text), "'"
393
-
394
-    ! Update filter in renderer
395
-    call set_filter_pattern(trim(search_text))
396
-
397
-    ! Invalidate layout to force recalculation (filtering happens during layout)
398
-    call invalidate_layout()
399
-
400
-    ! Trigger redraw
401
-    if (c_associated(main_window_ptr)) then
402
-      call gtk_widget_queue_draw(main_window_ptr)
403
-    end if
404
-  end subroutine on_search_changed
405
-
406364
   ! Helper to convert C string to Fortran string
407365
   subroutine c_f_string(c_str_ptr, f_str)
408366
     type(c_ptr), intent(in) :: c_str_ptr
src/rendering/treemap_renderer.f90modified
@@ -18,8 +18,7 @@ module treemap_renderer
1818
             scan_and_render_with_interaction, find_node_at_position, navigate_into_node, &
1919
             navigate_up, get_breadcrumb_path, get_path_depth, get_node_count, &
2020
             get_node_center_by_index, find_node_in_direction, register_progress_callback, &
21
-            scan_directory, invalidate_layout, get_current_view_node, remove_selected_node_from_view, &
22
-            set_filter_pattern
21
+            scan_directory, invalidate_layout, get_current_view_node, remove_selected_node_from_view
2322
 
2423
   ! Callback interfaces for progress updates
2524
   abstract interface
@@ -69,9 +68,6 @@ module treemap_renderer
6968
   procedure(hide_progress_callback), pointer, save :: hide_progress_cb => null()
7069
   procedure(update_progress_callback), pointer, save :: update_progress_cb => null()
7170
 
72
-  ! Filter pattern for search/filtering
73
-  character(len=256), save :: filter_pattern = ""
74
-
7571
 contains
7672
 
7773
   ! Initialize renderer
@@ -266,9 +262,6 @@ contains
266262
       bounds%height = int(height)
267263
 
268264
       if (associated(current_view_node) .and. current_view_node%size > 0) then
269
-        ! Apply filter by temporarily setting filtered nodes' sizes to 0
270
-        call apply_filter_to_view(current_view_node)
271
-
272265
         call calculate_treemap(current_view_node, bounds)
273266
       end if
274267
 
@@ -323,9 +316,6 @@ contains
323316
       bounds%height = int(height)
324317
 
325318
       if (associated(current_view_node) .and. current_view_node%size > 0) then
326
-        ! Apply filter by temporarily setting filtered nodes' sizes to 0
327
-        call apply_filter_to_view(current_view_node)
328
-
329319
         call calculate_treemap(current_view_node, bounds)
330320
       end if
331321
 
@@ -1020,7 +1010,6 @@ contains
10201010
     ! Render only the direct children of the current view
10211011
     if (allocated(view_node%children) .and. view_node%num_children > 0) then
10221012
       print *, "DEBUG: Rendering", view_node%num_children, "children"
1023
-      print *, "DEBUG: Current filter pattern: '", trim(filter_pattern), "'"
10241013
 
10251014
       ! Count visible nodes
10261015
       visible_count = 0
@@ -1028,7 +1017,7 @@ contains
10281017
         ! Skip nodes without names (shouldn't happen but be defensive)
10291018
         if (.not. allocated(view_node%children(i)%name)) cycle
10301019
 
1031
-        if (view_node%children(i)%size > 0 .and. matches_filter(view_node%children(i)%name)) then
1020
+        if (view_node%children(i)%size > 0) then
10321021
           visible_count = visible_count + 1
10331022
           if (visible_count <= 5) then
10341023
             print *, "DEBUG: Visible child", i, ":", trim(view_node%children(i)%name), &
@@ -1042,12 +1031,7 @@ contains
10421031
         ! Skip nodes without names (shouldn't happen but be defensive)
10431032
         if (.not. allocated(view_node%children(i)%name)) cycle
10441033
 
1045
-        ! Skip nodes that don't match the filter
1046
-        if (.not. matches_filter(view_node%children(i)%name)) then
1047
-          cycle
1048
-        end if
1049
-
1050
-        ! Skip nodes with size 0 (filtered out or deleted)
1034
+        ! Skip nodes with size 0 (deleted)
10511035
         if (view_node%children(i)%size == 0) then
10521036
           cycle
10531037
         end if
@@ -1277,68 +1261,6 @@ contains
12771261
     end if
12781262
   end subroutine render_label
12791263
 
1280
-  ! Set the filter pattern for filename filtering
1281
-  subroutine set_filter_pattern(pattern)
1282
-    character(len=*), intent(in) :: pattern
1283
-
1284
-    filter_pattern = trim(pattern)
1285
-    print *, "Filter pattern set to: '", trim(filter_pattern), "'"
1286
-
1287
-    ! If filter is being cleared, restore all sizes
1288
-    if (len_trim(filter_pattern) == 0 .and. associated(current_view_node)) then
1289
-      print *, "Filter cleared - restoring all sizes"
1290
-      call recalculate_sizes(root_node)
1291
-    end if
1292
-
1293
-    ! Invalidate layout when filter changes
1294
-    layout_calculated = .false.
1295
-  end subroutine set_filter_pattern
1296
-
1297
-  ! Check if a filename matches the current filter pattern (case-insensitive substring match)
1298
-  function matches_filter(filename) result(matches)
1299
-    character(len=*), intent(in) :: filename
1300
-    logical :: matches
1301
-    character(len=256) :: lower_name, lower_pattern
1302
-    integer :: i, ascii_val
1303
-
1304
-    ! If no filter is set, everything matches
1305
-    if (len_trim(filter_pattern) == 0) then
1306
-      matches = .true.
1307
-      return
1308
-    end if
1309
-
1310
-    ! If filename is empty, don't match (defensive check)
1311
-    if (len_trim(filename) == 0) then
1312
-      matches = .false.
1313
-      return
1314
-    end if
1315
-
1316
-    ! Convert both to lowercase for case-insensitive comparison
1317
-    lower_name = ""
1318
-    lower_pattern = ""
1319
-
1320
-    do i = 1, min(len_trim(filename), 256)
1321
-      ascii_val = iachar(filename(i:i))
1322
-      if (ascii_val >= 65 .and. ascii_val <= 90) then  ! A-Z
1323
-        lower_name(i:i) = achar(ascii_val + 32)
1324
-      else
1325
-        lower_name(i:i) = filename(i:i)
1326
-      end if
1327
-    end do
1328
-
1329
-    do i = 1, min(len_trim(filter_pattern), 256)
1330
-      ascii_val = iachar(filter_pattern(i:i))
1331
-      if (ascii_val >= 65 .and. ascii_val <= 90) then  ! A-Z
1332
-        lower_pattern(i:i) = achar(ascii_val + 32)
1333
-      else
1334
-        lower_pattern(i:i) = filter_pattern(i:i)
1335
-      end if
1336
-    end do
1337
-
1338
-    ! Check if pattern is a substring of filename
1339
-    matches = index(trim(lower_name), trim(lower_pattern)) > 0
1340
-  end function matches_filter
1341
-
13421264
   ! Recursively recalculate directory sizes from their children
13431265
   ! This restores sizes that may have been set to 0 by filtering
13441266
   recursive subroutine recalculate_sizes(node)
@@ -1370,35 +1292,4 @@ contains
13701292
     end if
13711293
   end subroutine recalculate_sizes
13721294
 
1373
-  ! Apply filter to view by setting non-matching nodes' sizes to 0
1374
-  subroutine apply_filter_to_view(node)
1375
-    type(file_node), intent(inout) :: node
1376
-    integer :: i
1377
-    integer :: match_count
1378
-
1379
-    ! If no filter is set, nothing to do
1380
-    if (len_trim(filter_pattern) == 0) return
1381
-
1382
-    ! If node has no children, nothing to do
1383
-    if (.not. allocated(node%children)) return
1384
-    if (node%num_children == 0) return
1385
-
1386
-    ! First, recalculate all sizes from scratch (restores any previously filtered sizes)
1387
-    call recalculate_sizes(node)
1388
-
1389
-    ! Now apply filter by setting non-matching children to size 0
1390
-    ! Note: original_size is already backed up during scanning, so no need to back up here
1391
-    match_count = 0
1392
-    do i = 1, node%num_children
1393
-      if (matches_filter(node%children(i)%name)) then
1394
-        match_count = match_count + 1
1395
-      else
1396
-        ! Set size to 0 for filtered nodes so layout skips them
1397
-        node%children(i)%size = 0_int64
1398
-      end if
1399
-    end do
1400
-
1401
-    print *, "Filter applied:", match_count, "of", node%num_children, "items match"
1402
-  end subroutine apply_filter_to_view
1403
-
14041295
 end module treemap_renderer