fix tooltip things, tab overrun, poor icon choice
- SHA
7c4215dffbe9da368ac9bd9ffc78b68b602b43c6- Parents
-
7ac35c5 - Tree
9738804
7c4215d
7c4215dffbe9da368ac9bd9ffc78b68b602b43c67ac35c5
9738804| Status | File | + | - |
|---|---|---|---|
| M |
src/gui/cairo_tab_bar.f90
|
14 | 1 |
| M |
src/gui/gtk_app.f90
|
1 | 1 |
| M |
src/gui/treemap_widget.f90
|
16 | 2 |
src/gui/cairo_tab_bar.f90modified@@ -283,14 +283,20 @@ contains | |||
| 283 | 283 | ||
| 284 | ! Draw tab label text | 284 | ! Draw tab label text |
| 285 | subroutine draw_tab_label(cr, x, y, width, height, text, is_dimmed) | 285 | subroutine draw_tab_label(cr, x, y, width, height, text, is_dimmed) |
| 286 | + use pango, only: pango_layout_set_width, pango_layout_set_ellipsize | ||
| 286 | type(c_ptr), intent(in) :: cr | 287 | type(c_ptr), intent(in) :: cr |
| 287 | integer, intent(in) :: x, y, width, height | 288 | integer, intent(in) :: x, y, width, height |
| 288 | character(len=*), intent(in) :: text | 289 | character(len=*), intent(in) :: text |
| 289 | logical, intent(in) :: is_dimmed | 290 | logical, intent(in) :: is_dimmed |
| 290 | type(c_ptr) :: layout, font_desc | 291 | type(c_ptr) :: layout, font_desc |
| 291 | integer(c_int), target :: text_width, text_height | 292 | integer(c_int), target :: text_width, text_height |
| 293 | + integer(c_int) :: max_text_width | ||
| 292 | real(c_double) :: text_x, text_y | 294 | real(c_double) :: text_x, text_y |
| 293 | 295 | ||
| 296 | + ! Pango constants (not available in gtk-fortran bindings) | ||
| 297 | + integer(c_int), parameter :: PANGO_SCALE = 1024 | ||
| 298 | + integer(c_int), parameter :: PANGO_ELLIPSIZE_END = 3 | ||
| 299 | + | ||
| 294 | ! Create pango layout | 300 | ! Create pango layout |
| 295 | layout = pango_cairo_create_layout(cr) | 301 | layout = pango_cairo_create_layout(cr) |
| 296 | call pango_layout_set_text(layout, trim(text)//c_null_char, -1_c_int) | 302 | call pango_layout_set_text(layout, trim(text)//c_null_char, -1_c_int) |
@@ -299,7 +305,14 @@ contains | |||
| 299 | font_desc = pango_font_description_from_string("Sans 10"//c_null_char) | 305 | font_desc = pango_font_description_from_string("Sans 10"//c_null_char) |
| 300 | call pango_layout_set_font_description(layout, font_desc) | 306 | call pango_layout_set_font_description(layout, font_desc) |
| 301 | 307 | ||
| 302 | - ! Get text size | 308 | + ! Calculate maximum width for text (leave room for close button and some padding) |
| 309 | + max_text_width = width - CLOSE_BUTTON_SIZE - CLOSE_BUTTON_MARGIN - 10 | ||
| 310 | + | ||
| 311 | + ! Enable ellipsization to truncate long text | ||
| 312 | + call pango_layout_set_width(layout, max_text_width * PANGO_SCALE) | ||
| 313 | + call pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END) | ||
| 314 | + | ||
| 315 | + ! Get text size (after ellipsization) | ||
| 303 | call pango_layout_get_pixel_size(layout, c_loc(text_width), c_loc(text_height)) | 316 | call pango_layout_get_pixel_size(layout, c_loc(text_width), c_loc(text_height)) |
| 304 | 317 | ||
| 305 | ! Center text in tab (leaving room for close button) | 318 | ! Center text in tab (leaving room for close button) |
src/gui/gtk_app.f90modified@@ -256,7 +256,7 @@ contains | |||
| 256 | ! Create Open Directory button with folder icon | 256 | ! Create Open Directory button with folder icon |
| 257 | open_dir_btn = gtk_button_new() | 257 | open_dir_btn = gtk_button_new() |
| 258 | open_dir_btn_ptr = open_dir_btn ! Store for later access (pulsing on empty tabs) | 258 | open_dir_btn_ptr = open_dir_btn ! Store for later access (pulsing on empty tabs) |
| 259 | - call gtk_button_set_icon_name(open_dir_btn, "folder-open"//c_null_char) | 259 | + call gtk_button_set_icon_name(open_dir_btn, "folder"//c_null_char) |
| 260 | call gtk_widget_set_tooltip_text(open_dir_btn, "Open Directory (Ctrl+O)"//c_null_char) | 260 | call gtk_widget_set_tooltip_text(open_dir_btn, "Open Directory (Ctrl+O)"//c_null_char) |
| 261 | call g_signal_connect(open_dir_btn, "clicked"//c_null_char, & | 261 | call g_signal_connect(open_dir_btn, "clicked"//c_null_char, & |
| 262 | c_funloc(on_open_dir_clicked), c_null_ptr) | 262 | c_funloc(on_open_dir_clicked), c_null_ptr) |
src/gui/treemap_widget.f90modified@@ -629,14 +629,16 @@ contains | |||
| 629 | function on_query_tooltip(widget, x, y, keyboard_mode, tooltip, user_data) bind(c) result(show_tooltip) | 629 | function on_query_tooltip(widget, x, y, keyboard_mode, tooltip, user_data) bind(c) result(show_tooltip) |
| 630 | use types, only: file_node | 630 | use types, only: file_node |
| 631 | use treemap_renderer, only: find_node_at_position | 631 | use treemap_renderer, only: find_node_at_position |
| 632 | + use file_system, only: list_directory | ||
| 632 | use iso_fortran_env, only: int64 | 633 | use iso_fortran_env, only: int64 |
| 633 | type(c_ptr), value :: widget, tooltip, user_data | 634 | type(c_ptr), value :: widget, tooltip, user_data |
| 634 | integer(c_int), value :: x, y, keyboard_mode | 635 | integer(c_int), value :: x, y, keyboard_mode |
| 635 | integer(c_int) :: show_tooltip | 636 | integer(c_int) :: show_tooltip |
| 636 | type(file_node), pointer :: current_view | 637 | type(file_node), pointer :: current_view |
| 637 | - integer :: hovered_index | 638 | + integer :: hovered_index, item_count |
| 638 | character(len=512) :: tooltip_text | 639 | character(len=512) :: tooltip_text |
| 639 | character(len=64) :: size_str | 640 | character(len=64) :: size_str |
| 641 | + character(len=256), dimension(10000) :: dir_entries | ||
| 640 | real(c_double) :: dx, dy | 642 | real(c_double) :: dx, dy |
| 641 | real :: size_mb, size_gb | 643 | real :: size_mb, size_gb |
| 642 | 644 | ||
@@ -685,10 +687,22 @@ contains | |||
| 685 | 687 | ||
| 686 | ! Build tooltip text | 688 | ! Build tooltip text |
| 687 | if (current_view%children(hovered_index)%is_directory) then | 689 | if (current_view%children(hovered_index)%is_directory) then |
| 690 | + ! Determine item count for directory | ||
| 691 | + if (allocated(current_view%children(hovered_index)%children)) then | ||
| 692 | + ! Directory has been scanned - use cached count | ||
| 693 | + item_count = current_view%children(hovered_index)%num_children | ||
| 694 | + else if (allocated(current_view%children(hovered_index)%path)) then | ||
| 695 | + ! Directory not yet scanned - count entries on demand | ||
| 696 | + item_count = list_directory(trim(current_view%children(hovered_index)%path), dir_entries, 10000) | ||
| 697 | + if (item_count < 0) item_count = 0 ! Handle errors | ||
| 698 | + else | ||
| 699 | + item_count = 0 | ||
| 700 | + end if | ||
| 701 | + | ||
| 688 | write(tooltip_text, '(A,A,A,A,A,I0,A)') & | 702 | write(tooltip_text, '(A,A,A,A,A,I0,A)') & |
| 689 | trim(current_view%children(hovered_index)%name), & | 703 | trim(current_view%children(hovered_index)%name), & |
| 690 | char(10), 'Size: ', trim(size_str), & | 704 | char(10), 'Size: ', trim(size_str), & |
| 691 | - char(10), current_view%children(hovered_index)%num_children, ' items' | 705 | + char(10), item_count, ' items' |
| 692 | else | 706 | else |
| 693 | write(tooltip_text, '(A,A,A,A)') & | 707 | write(tooltip_text, '(A,A,A,A)') & |
| 694 | trim(current_view%children(hovered_index)%name), & | 708 | trim(current_view%children(hovered_index)%name), & |