fortrangoingonforty/sniffly / ec6da37

Browse files

implement plus button to create new tabs

Authored by espadonne
SHA
ec6da377f0d82c6b8c8545b367fe9d7ca05539b7
Parents
ce3f482
Tree
77fe031

1 changed file

StatusFile+-
M src/gui/tab_widget.f90 24 3
src/gui/tab_widget.f90modified
@@ -10,7 +10,7 @@ module tab_widget
10
                  gtk_label_new, gtk_box_set_spacing, gtk_widget_set_hexpand, &
10
                  gtk_label_new, gtk_box_set_spacing, gtk_widget_set_hexpand, &
11
                  gtk_widget_set_halign, GTK_ALIGN_END
11
                  gtk_widget_set_halign, GTK_ALIGN_END
12
   use tab_manager, only: tab_state, get_tab, num_tabs, active_tab_index, &
12
   use tab_manager, only: tab_state, get_tab, num_tabs, active_tab_index, &
13
-                         MAX_TABS, switch_to_tab
13
+                         MAX_TABS, switch_to_tab, create_tab, close_tab
14
   use gtk_app, only: update_ui_for_active_tab
14
   use gtk_app, only: update_ui_for_active_tab
15
   implicit none
15
   implicit none
16
   private
16
   private
@@ -147,9 +147,30 @@ contains
147
 
147
 
148
   ! Callback when plus button is clicked
148
   ! Callback when plus button is clicked
149
   subroutine on_plus_clicked(button, user_data) bind(c)
149
   subroutine on_plus_clicked(button, user_data) bind(c)
150
+    use gtk_app, only: get_home_directory
150
     type(c_ptr), value :: button, user_data
151
     type(c_ptr), value :: button, user_data
151
-    print *, "Plus button clicked - new tab"
152
+    integer :: new_tab_index
152
-    ! TODO: Call new_tab_cb when registered
153
+    type(tab_state), pointer :: new_tab
154
+
155
+    print *, "Plus button clicked - creating new tab"
156
+
157
+    ! Create a new tab for the home directory
158
+    ! TODO: Add directory picker to let user choose path
159
+    new_tab_index = create_tab(get_home_directory())
160
+
161
+    if (new_tab_index < 0) then
162
+      print *, "ERROR: Failed to create new tab (max tabs reached?)"
163
+      return
164
+    end if
165
+
166
+    print *, "Created new tab ", new_tab_index
167
+
168
+    ! Rebuild tab bar to show the new tab
169
+    ! TODO: Implement proper clear_tab_bar to avoid duplicates
170
+    ! For now, just refresh which will add the new tab
171
+    call refresh_tab_bar()
172
+
173
+    print *, "Tab bar refreshed with new tab"
153
   end subroutine on_plus_clicked
174
   end subroutine on_plus_clicked
154
 
175
 
155
   ! Callback when a tab button is clicked
176
   ! Callback when a tab button is clicked