diff options
| author | Victor Kareh <[email protected]> | 2025-09-21 19:09:14 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-21 19:09:14 +0000 |
| commit | f3998312f42dbd8b76eba71b976015b0813769f7 (patch) | |
| tree | 41b4fd62889a774b2d1e4d19e2a86c3acb14ab07 /src/file-manager/fm-icon-view.c | |
| parent | f093cfa7e4cbb27280576d39d63e5000df9f0d7c (diff) | |
| download | caja-f3998312f42dbd8b76eba71b976015b0813769f7.tar.bz2 caja-f3998312f42dbd8b76eba71b976015b0813769f7.tar.xz | |
File search improvements (#1851)
* search: Respect hidden files setting when searching
When starting a search, check the current window's hidden files mode and
apply the same setting to search results. This ensures search results
match the visibility of files in the current directory view.
* search: Add support for globs
Add globbing when searching for files. Caja will autodetect if the query
contains a glob and change its search to use that instead of substrings.
Example:
- "*.txt" finds all text files
- "photo-?.jpg" finds numbered photo files
- "data[0-9]*.csv" finds numbered data files
* search: Add location tooltips for search results
Display file location in tooltips when hovering over search results in
both icon and list views. This can help users tell where files are
located since search happens across subdirectories.
Diffstat (limited to 'src/file-manager/fm-icon-view.c')
| -rw-r--r-- | src/file-manager/fm-icon-view.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index 25708184..c17bedf6 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -38,6 +38,7 @@ #include <sys/wait.h> #include <eel/eel-background.h> +#include <eel/eel-canvas.h> #include <eel/eel-glib-extensions.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-gtk-macros.h> @@ -48,11 +49,14 @@ #include <libcaja-private/caja-clipboard-monitor.h> #include <libcaja-private/caja-directory-background.h> #include <libcaja-private/caja-directory.h> +#include <libcaja-private/caja-search-directory.h> #include <libcaja-private/caja-dnd.h> #include <libcaja-private/caja-file-utilities.h> #include <libcaja-private/caja-ui-utilities.h> #include <libcaja-private/caja-global-preferences.h> +#include <libcaja-private/caja-icon-canvas-item.h> #include <libcaja-private/caja-icon-container.h> +#include <libcaja-private/caja-icon-private.h> #include <libcaja-private/caja-icon-dnd.h> #include <libcaja-private/caja-link.h> #include <libcaja-private/caja-metadata.h> @@ -3114,6 +3118,58 @@ focus_in_event_callback (GtkWidget *widget, GdkEventFocus *event, gpointer user_ return FALSE; } +static gboolean +icon_container_query_tooltip_callback (GtkWidget *widget, + gint x, + gint y, + gboolean keyboard_tip, + GtkTooltip *tooltip, + FMIconView *icon_view) +{ + CajaIconContainer *icon_container; + EelCanvasItem *item; + CajaFile *file; + char *location_text; + + /* Only show tooltips in search directories */ + if (!CAJA_IS_SEARCH_DIRECTORY (fm_directory_view_get_model (FM_DIRECTORY_VIEW (icon_view)))) + { + return FALSE; + } + + icon_container = CAJA_ICON_CONTAINER (widget); + + /* Get the canvas item at the cursor position */ + item = eel_canvas_get_item_at (EEL_CANVAS (icon_container), x, y); + if (item == NULL || !CAJA_IS_ICON_CANVAS_ITEM (item)) + { + return FALSE; + } + + /* Get the file from the canvas item's user_data */ + CajaIcon *icon = CAJA_ICON_CANVAS_ITEM (item)->user_data; + file = CAJA_FILE (icon->data); + if (file == NULL) + { + return FALSE; + } + + /* Get the location attribute */ + location_text = caja_file_get_string_attribute_with_default (file, "location"); + if (location_text == NULL || location_text[0] == '\0') + { + g_free (location_text); + return FALSE; + } + + /* Set tooltip text with file location */ + gtk_tooltip_set_text (tooltip, location_text); + + g_free (location_text); + + return TRUE; +} + static CajaIconContainer * create_icon_container (FMIconView *icon_view) { @@ -3122,9 +3178,12 @@ create_icon_container (FMIconView *icon_view) icon_container = fm_icon_container_new (icon_view); gtk_widget_set_can_focus (GTK_WIDGET (icon_container), TRUE); + gtk_widget_set_has_tooltip (GTK_WIDGET (icon_container), TRUE); g_signal_connect_object (icon_container, "focus_in_event", G_CALLBACK (focus_in_event_callback), icon_view, 0); + g_signal_connect_object (icon_container, "query-tooltip", + G_CALLBACK (icon_container_query_tooltip_callback), icon_view, 0); g_signal_connect_object (icon_container, "activate", G_CALLBACK (icon_container_activate_callback), icon_view, 0); g_signal_connect_object (icon_container, "activate_alternate", |
