fortrangoingonforty/sniffly / fab1682

Browse files

auto-start scan after dir selection and reduce event loop lag

Co-Authored-By: mfwolffe <wolffemf@dukes.jmu.edu>
Authored by espadonne
SHA
fab168227e4995f91be897f045d3f6e67a81ea83
Parents
21a5c7b
Tree
fd43e33

1 changed file

StatusFile+-
M src/gui/gtk_app.f90 8 10
src/gui/gtk_app.f90modified
@@ -583,7 +583,7 @@ contains
583583
         selected_path = c_path(1:path_len)
584584
         print *, "Selected directory: ", trim(selected_path)
585585
 
586
-        ! Update tab scan path (but don't scan yet)
586
+        ! Update tab scan path
587587
         ! Remove trailing slash if present (C code doesn't like it)
588588
         if (len_trim(selected_path) > 1 .and. &
589589
             selected_path(len_trim(selected_path):len_trim(selected_path)) == '/') then
@@ -595,7 +595,9 @@ contains
595595
         call set_scan_path(trim(tab%scan_path))
596596
         call update_path_entry(trim(tab%scan_path))
597597
 
598
-        print *, "Path updated. Click Scan button to scan: ", trim(tab%scan_path)
598
+        ! Auto-start scan immediately after directory selection
599
+        call sniffly_update_status("Scanning...")
600
+        call trigger_rescan(tab%scan_path)
599601
       end if
600602
     else
601603
       print *, "Directory selection cancelled"
@@ -2161,11 +2163,9 @@ contains
21612163
       normalized_path = trim(path)
21622164
     end if
21632165
 
2164
-    ! Process pending GTK events before starting scan
2166
+    ! Process pending GTK events once before starting scan (minimal delay)
21652167
     context = g_main_context_default()
2166
-    do i = 1, 10
2167
-      do while (g_main_context_iteration(context, 0_c_int) /= 0_c_int)
2168
-      end do
2168
+    do while (g_main_context_iteration(context, 0_c_int) /= 0_c_int)
21692169
     end do
21702170
 
21712171
     print *, "=== ABOUT TO CALL scan_directory ==="
@@ -2177,10 +2177,8 @@ contains
21772177
     call update_cancel_scan_button_state()
21782178
     call update_history_buttons()
21792179
 
2180
-    ! Process events after scan to update UI
2181
-    do i = 1, 10
2182
-      do while (g_main_context_iteration(context, 0_c_int) /= 0_c_int)
2183
-      end do
2180
+    ! Process events once after scan to update UI
2181
+    do while (g_main_context_iteration(context, 0_c_int) /= 0_c_int)
21842182
     end do
21852183
 
21862184
     ! Invalidate layout to force recalculation