fortrangoingonforty/sniffly / 923e235

Browse files

add UI updates when switching tabs (breadcrumb + treemap)

Authored by espadonne
SHA
923e23570776579a8f7a887ffbaec47010edb290
Parents
461006c
Tree
8a5962e

2 changed files

StatusFile+-
M src/gui/gtk_app.f90 57 1
M src/gui/tab_widget.f90 4 0
src/gui/gtk_app.f90modified
@@ -39,7 +39,7 @@ module gtk_app
3939
   public :: sniffly_app_run, sniffly_app_quit, sniffly_set_scan_path, &
4040
             sniffly_update_status, sniffly_show_error, breadcrumb_callback, &
4141
             sniffly_update_progress, sniffly_show_progress, sniffly_hide_progress, &
42
-            sniffly_update_status_bar_stats, get_forward_path
42
+            sniffly_update_status_bar_stats, get_forward_path, update_ui_for_active_tab
4343
 
4444
   ! Application constants
4545
   character(len=*), parameter :: APP_ID = "org.fortrangoingonforty.sniffly"
@@ -222,6 +222,10 @@ contains
222222
     end if
223223
     print *, "Created initial tab ", first_tab_index, " for: ", trim(scan_path)
224224
 
225
+    ! TEMPORARY: Create a second tab for testing tab switching
226
+    first_tab_index = create_tab(get_home_directory())
227
+    print *, "Created second tab for testing: ", trim(get_home_directory())
228
+
225229
     ! Create main vertical box (toolbar + treemap)
226230
     main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0_c_int)
227231
 
@@ -869,6 +873,58 @@ contains
869873
     call gtk_widget_set_sensitive(open_finder_btn_ptr, 1_c_int)
870874
   end subroutine update_selection_buttons
871875
 
876
+  ! Update UI to reflect the active tab's state (called when switching tabs)
877
+  subroutine update_ui_for_active_tab()
878
+    use gtk, only: gtk_widget_queue_draw
879
+    use types, only: file_node
880
+    type(tab_state), pointer :: tab
881
+    type(file_node), pointer :: current_view
882
+
883
+    print *, "=== UPDATE_UI_FOR_ACTIVE_TAB ==="
884
+
885
+    ! Get active tab
886
+    tab => get_active_tab()
887
+    if (.not. associated(tab)) then
888
+      print *, "ERROR: No active tab"
889
+      return
890
+    end if
891
+
892
+    print *, "  Active tab index: ", active_tab_index
893
+    print *, "  Tab has_data: ", tab%has_data
894
+
895
+    ! Only update if tab has data
896
+    if (.not. tab%has_data) then
897
+      print *, "  Tab has no data yet - skipping UI update"
898
+      return
899
+    end if
900
+
901
+    ! Get the current view node
902
+    current_view => tab%current_view_node
903
+    if (.not. associated(current_view)) then
904
+      print *, "ERROR: Tab has_data=true but current_view_node not associated"
905
+      return
906
+    end if
907
+
908
+    print *, "  Updating breadcrumb for: ", trim(current_view%path)
909
+
910
+    ! Update breadcrumb cache
911
+    call update_breadcrumb_cache(trim(current_view%path))
912
+
913
+    ! Trigger treemap redraw
914
+    if (c_associated(drawing_area_ptr)) then
915
+      call gtk_widget_queue_draw(drawing_area_ptr)
916
+      print *, "  Triggered treemap redraw"
917
+    end if
918
+
919
+    ! Update navigation buttons
920
+    call update_history_buttons()
921
+
922
+    ! Update path entry
923
+    call update_path_entry(trim(current_view%path))
924
+
925
+    print *, "=== UI UPDATE COMPLETE ==="
926
+  end subroutine update_ui_for_active_tab
927
+
872928
   ! Helper: Add path to navigation history
873929
   subroutine add_to_history(path)
874930
     character(len=*), intent(in) :: path
src/gui/tab_widget.f90modified
@@ -11,6 +11,7 @@ module tab_widget
1111
                  gtk_widget_set_halign, GTK_ALIGN_END
1212
   use tab_manager, only: tab_state, get_tab, num_tabs, active_tab_index, &
1313
                          MAX_TABS, switch_to_tab
14
+  use gtk_app, only: update_ui_for_active_tab
1415
   implicit none
1516
   private
1617
 
@@ -184,6 +185,9 @@ contains
184185
     ! Update tab visual states (yellow border)
185186
     call update_tab_visual_states()
186187
 
188
+    ! Update UI to reflect the new tab's state
189
+    call update_ui_for_active_tab()
190
+
187191
     print *, "Switched to tab ", clicked_tab_index
188192
   end subroutine on_tab_clicked
189193