fortrangoingonforty/sniffly / 6a5d00a

Browse files

remove old breadcrumb functions, wire up new widget

Authored by espadonne
SHA
6a5d00a263e112cc89d49d56a4c50806695d5c0d
Parents
85a8d6a
Tree
4b65717

1 changed file

StatusFile+-
M src/gui/gtk_app.f90 12 143
src/gui/gtk_app.f90modified
@@ -1239,146 +1239,9 @@ contains
12391239
     end if
12401240
   end function count_files_recursive
12411241
 
1242
-  ! Update breadcrumb bar with clickable path segments
1243
-  subroutine sniffly_update_breadcrumbs()
1244
-    use treemap_renderer, only: get_breadcrumb_path, get_path_depth
1245
-    use gtk, only: gtk_button_new_with_label, gtk_box_remove
1246
-    character(len=256), dimension(100) :: names
1247
-    character(len=512) :: home_dir, segment_label
1248
-    character(len=256) :: display_name
1249
-    integer :: count, i, home_len, name_len, depth_to_navigate
1250
-    logical :: is_home_path
1251
-    type(c_ptr) :: button, separator, child
1252
-    type(c_ptr) :: user_data_ptr
1253
-
1254
-    ! Guard against accessing widgets during shutdown
1255
-    if (app_is_shutting_down) return
1256
-
1257
-    if (.not. c_associated(breadcrumb_box_ptr)) then
1258
-      print *, "WARNING: breadcrumb_box_ptr not associated!"
1259
-      return
1260
-    end if
1261
-
1262
-    ! Get breadcrumb path from renderer
1263
-    call get_breadcrumb_path(names, count)
1264
-    print *, "Updating breadcrumbs: count=", count
1265
-
1266
-    ! Remove all existing breadcrumb widgets
1267
-    do i = 1, breadcrumb_count
1268
-      if (c_associated(breadcrumb_buttons(i))) then
1269
-        child = gtk_widget_get_first_child(breadcrumb_box_ptr)
1270
-        do while (c_associated(child))
1271
-          call gtk_box_remove(breadcrumb_box_ptr, child)
1272
-          child = gtk_widget_get_first_child(breadcrumb_box_ptr)
1273
-        end do
1274
-        exit
1275
-      end if
1276
-    end do
1277
-    breadcrumb_count = 0
1278
-
1279
-    ! Get home directory for abbreviation
1280
-    call get_environment_variable("HOME", home_dir)
1281
-    home_len = len_trim(home_dir)
1282
-
1283
-    ! Create button for each path segment
1284
-    do i = 1, min(count, MAX_BREADCRUMB_SEGMENTS)
1285
-      display_name = names(i)
1286
-
1287
-      ! Replace home directory with ~ for first segment
1288
-      if (i == 1 .and. home_len > 0) then
1289
-        name_len = len_trim(names(i))
1290
-        is_home_path = .false.
1291
-
1292
-        if (name_len >= home_len) then
1293
-          if (names(i)(1:home_len) == home_dir(1:home_len)) then
1294
-            is_home_path = .true.
1295
-          end if
1296
-        end if
1297
-
1298
-        if (is_home_path) then
1299
-          if (name_len == home_len) then
1300
-            display_name = "~"
1301
-          else if (names(i)(home_len+1:home_len+1) == "/") then
1302
-            display_name = "~" // trim(names(i)(home_len+1:name_len))
1303
-          end if
1304
-        end if
1305
-      end if
1306
-
1307
-      ! Extract just the last component for nested paths
1308
-      if (i > 1) then
1309
-        ! Find last slash and take component after it
1310
-        name_len = len_trim(names(i))
1311
-        do depth_to_navigate = name_len, 1, -1
1312
-          if (names(i)(depth_to_navigate:depth_to_navigate) == '/') then
1313
-            display_name = names(i)(depth_to_navigate+1:name_len)
1314
-            exit
1315
-          end if
1316
-        end do
1317
-      end if
1318
-
1319
-      ! Add separator before button (except first)
1320
-      if (i > 1) then
1321
-        separator = gtk_label_new(" > "//c_null_char)
1322
-        call gtk_box_append(breadcrumb_box_ptr, separator)
1323
-      end if
1324
-
1325
-      ! Create clickable button for this segment
1326
-      segment_label = trim(display_name)
1327
-      button = gtk_button_new_with_label(trim(segment_label)//c_null_char)
1328
-
1329
-      ! Store depth information as user data (count - i = levels to go up)
1330
-      depth_to_navigate = count - i
1331
-      user_data_ptr = transfer(depth_to_navigate, user_data_ptr)
1332
-
1333
-      ! Connect click handler
1334
-      call g_signal_connect(button, "clicked"//c_null_char, &
1335
-                           c_funloc(on_breadcrumb_clicked), user_data_ptr)
1336
-
1337
-      ! Add to box
1338
-      call gtk_box_append(breadcrumb_box_ptr, button)
1339
-
1340
-      ! Store button reference
1341
-      breadcrumb_count = breadcrumb_count + 1
1342
-      breadcrumb_buttons(breadcrumb_count) = button
1343
-    end do
1344
-
1345
-    print *, "Created ", breadcrumb_count, " clickable breadcrumb segments"
1346
-  end subroutine sniffly_update_breadcrumbs
1347
-
1348
-  ! Breadcrumb button click handler
1349
-  subroutine on_breadcrumb_clicked(button, user_data) bind(c)
1350
-    use treemap_renderer, only: navigate_up
1351
-    use gtk, only: gtk_widget_queue_draw
1352
-    use treemap_widget, only: get_widget_ptr
1353
-    type(c_ptr), value :: button, user_data
1354
-    integer :: levels_to_go_up
1355
-    type(c_ptr) :: widget
1356
-
1357
-    ! Extract depth from user data
1358
-    levels_to_go_up = transfer(user_data, levels_to_go_up)
1359
-
1360
-    print *, "Breadcrumb clicked: navigating up ", levels_to_go_up, " levels"
1361
-
1362
-    if (levels_to_go_up > 0) then
1363
-      ! Navigate up by the specified number of levels
1364
-      call navigate_up(levels_to_go_up)
1365
-
1366
-      ! Update breadcrumbs and history
1367
-      call breadcrumb_callback()
1368
-
1369
-      ! Redraw treemap
1370
-      widget = get_widget_ptr()
1371
-      if (c_associated(widget)) then
1372
-        call gtk_widget_queue_draw(widget)
1373
-      end if
1374
-    else
1375
-      print *, "Already at this level (depth = 0)"
1376
-    end if
1377
-  end subroutine on_breadcrumb_clicked
1378
-
13791242
   ! Callback wrapper for navigation events (no arguments)
13801243
   subroutine breadcrumb_callback()
1381
-    use treemap_renderer, only: get_breadcrumb_path, get_current_view_node
1244
+    use treemap_renderer, only: get_current_view_node
13821245
     use types, only: file_node
13831246
     type(file_node), pointer :: current_view
13841247
 
@@ -1389,9 +1252,11 @@ contains
13891252
     if (associated(current_view) .and. allocated(current_view%path)) then
13901253
       global_scan_path = trim(current_view%path)
13911254
       print *, "  Synced global_scan_path to: ", trim(global_scan_path)
1255
+
1256
+      ! Update breadcrumb widget with new path
1257
+      call update_breadcrumb_cache(trim(current_view%path))
13921258
     end if
13931259
 
1394
-    call sniffly_update_breadcrumbs()
13951260
     call sniffly_update_status_bar_stats()
13961261
 
13971262
     ! Always add current path to navigation history
@@ -1592,8 +1457,10 @@ contains
15921457
     ! Invalidate layout to force recalculation
15931458
     call invalidate_layout()
15941459
 
1595
-    ! Update breadcrumbs after scan
1596
-    call sniffly_update_breadcrumbs()
1460
+    ! Update breadcrumbs after scan (use global_scan_path)
1461
+    if (len_trim(global_scan_path) > 0) then
1462
+      call update_breadcrumb_cache(trim(global_scan_path))
1463
+    end if
15971464
 
15981465
     ! Update status bar with file statistics
15991466
     call sniffly_update_status_bar_stats()
@@ -1622,8 +1489,10 @@ contains
16221489
     ! Invalidate layout to force recalculation
16231490
     call invalidate_layout()
16241491
 
1625
-    ! Update breadcrumbs after scan
1626
-    call sniffly_update_breadcrumbs()
1492
+    ! Update breadcrumbs after scan (use pending_scan_path)
1493
+    if (len_trim(pending_scan_path) > 0) then
1494
+      call update_breadcrumb_cache(trim(pending_scan_path))
1495
+    end if
16271496
 
16281497
     ! Update status bar with file statistics
16291498
     call sniffly_update_status_bar_stats()