@@ -147,16 +147,26 @@ 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 | + use iso_fortran_env, only: output_unit |
| 151 | type(c_ptr), value :: button, user_data | 151 | type(c_ptr), value :: button, user_data |
| 152 | integer :: new_tab_index | 152 | integer :: new_tab_index |
| 153 | - type(tab_state), pointer :: new_tab | 153 | + type(tab_state), pointer :: new_tab, current_tab |
| | 154 | + character(len=512) :: new_tab_path |
| 154 | | 155 | |
| 155 | print *, "Plus button clicked - creating new tab" | 156 | print *, "Plus button clicked - creating new tab" |
| 156 | | 157 | |
| 157 | - ! Create a new tab for the home directory | 158 | + ! Get the current tab's path and use that for the new tab |
| 158 | ! TODO: Add directory picker to let user choose path | 159 | ! TODO: Add directory picker to let user choose path |
| 159 | - new_tab_index = create_tab(get_home_directory()) | 160 | + current_tab => get_tab(active_tab_index) |
| | 161 | + if (associated(current_tab)) then |
| | 162 | + new_tab_path = current_tab%scan_path |
| | 163 | + else |
| | 164 | + ! Fallback to home directory using environment variable |
| | 165 | + call get_environment_variable("HOME", new_tab_path) |
| | 166 | + end if |
| | 167 | + |
| | 168 | + ! Create a new tab with the same path as current tab |
| | 169 | + new_tab_index = create_tab(trim(new_tab_path)) |
| 160 | | 170 | |
| 161 | if (new_tab_index < 0) then | 171 | if (new_tab_index < 0) then |
| 162 | print *, "ERROR: Failed to create new tab (max tabs reached?)" | 172 | print *, "ERROR: Failed to create new tab (max tabs reached?)" |