@@ -1239,146 +1239,9 @@ contains |
| 1239 | end if | 1239 | end if |
| 1240 | end function count_files_recursive | 1240 | end function count_files_recursive |
| 1241 | | 1241 | |
| 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 | - | | |
| 1379 | ! Callback wrapper for navigation events (no arguments) | 1242 | ! Callback wrapper for navigation events (no arguments) |
| 1380 | subroutine breadcrumb_callback() | 1243 | subroutine breadcrumb_callback() |
| 1381 | - use treemap_renderer, only: get_breadcrumb_path, get_current_view_node | 1244 | + use treemap_renderer, only: get_current_view_node |
| 1382 | use types, only: file_node | 1245 | use types, only: file_node |
| 1383 | type(file_node), pointer :: current_view | 1246 | type(file_node), pointer :: current_view |
| 1384 | | 1247 | |
@@ -1389,9 +1252,11 @@ contains |
| 1389 | if (associated(current_view) .and. allocated(current_view%path)) then | 1252 | if (associated(current_view) .and. allocated(current_view%path)) then |
| 1390 | global_scan_path = trim(current_view%path) | 1253 | global_scan_path = trim(current_view%path) |
| 1391 | print *, " Synced global_scan_path to: ", trim(global_scan_path) | 1254 | 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)) |
| 1392 | end if | 1258 | end if |
| 1393 | | 1259 | |
| 1394 | - call sniffly_update_breadcrumbs() | | |
| 1395 | call sniffly_update_status_bar_stats() | 1260 | call sniffly_update_status_bar_stats() |
| 1396 | | 1261 | |
| 1397 | ! Always add current path to navigation history | 1262 | ! Always add current path to navigation history |
@@ -1592,8 +1457,10 @@ contains |
| 1592 | ! Invalidate layout to force recalculation | 1457 | ! Invalidate layout to force recalculation |
| 1593 | call invalidate_layout() | 1458 | call invalidate_layout() |
| 1594 | | 1459 | |
| 1595 | - ! Update breadcrumbs after scan | 1460 | + ! Update breadcrumbs after scan (use global_scan_path) |
| 1596 | - call sniffly_update_breadcrumbs() | 1461 | + if (len_trim(global_scan_path) > 0) then |
| | 1462 | + call update_breadcrumb_cache(trim(global_scan_path)) |
| | 1463 | + end if |
| 1597 | | 1464 | |
| 1598 | ! Update status bar with file statistics | 1465 | ! Update status bar with file statistics |
| 1599 | call sniffly_update_status_bar_stats() | 1466 | call sniffly_update_status_bar_stats() |
@@ -1622,8 +1489,10 @@ contains |
| 1622 | ! Invalidate layout to force recalculation | 1489 | ! Invalidate layout to force recalculation |
| 1623 | call invalidate_layout() | 1490 | call invalidate_layout() |
| 1624 | | 1491 | |
| 1625 | - ! Update breadcrumbs after scan | 1492 | + ! Update breadcrumbs after scan (use pending_scan_path) |
| 1626 | - call sniffly_update_breadcrumbs() | 1493 | + if (len_trim(pending_scan_path) > 0) then |
| | 1494 | + call update_breadcrumb_cache(trim(pending_scan_path)) |
| | 1495 | + end if |
| 1627 | | 1496 | |
| 1628 | ! Update status bar with file statistics | 1497 | ! Update status bar with file statistics |
| 1629 | call sniffly_update_status_bar_stats() | 1498 | call sniffly_update_status_bar_stats() |