diff options
author | Colomban Wendling <[email protected]> | 2025-04-01 19:13:05 +0200 |
---|---|---|
committer | Colomban Wendling <[email protected]> | 2025-04-03 00:05:48 +0200 |
commit | 4abe18dbd3aeb1f609fde72a1f534bc5a829f6f2 (patch) | |
tree | 006880038e31175a3e8ba5b69a1f2040bd8a0d61 | |
parent | 0e95d2dd680b153bb38d1403bf379dc7be63ad8d (diff) | |
download | caja-4abe18dbd3aeb1f609fde72a1f534bc5a829f6f2.tar.bz2 caja-4abe18dbd3aeb1f609fde72a1f534bc5a829f6f2.tar.xz |
File properties: improve accessibility of the icon button
Neither the button nor the icon shown in the properties dialog had nay
name, which is a problem for accessibility as an assistive technology
thus doesn't have anything to present to the user apart from an unnamed
button or image -- which isn't particularly helpful.
Improve this in two ways:
* Add a description to the icon, either matching the file type display
name of the icon, the fact it's a custom icon or conveying multiple
files are selected and the icon is hence not very specific.
* Add a tooltip to the button hinting that it can be used to change
the associated icon.
-rw-r--r-- | src/file-manager/fm-properties-window.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 3be02ed9..88a97e55 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -364,11 +364,13 @@ add_prompt_and_separator (GtkWidget *vbox, const char *prompt_text) static void get_image_for_properties_window (FMPropertiesWindow *window, char **icon_name, + char **display_name_, GdkPixbuf **icon_pixbuf) { CajaIconInfo *icon, *new_icon; GList *l; gint icon_scale; + gchar *display_name = NULL; icon = NULL; icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (window->details->notebook)); @@ -382,6 +384,7 @@ get_image_for_properties_window (FMPropertiesWindow *window, icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | CAJA_FILE_ICON_FLAGS_IGNORE_VISITING); + display_name = caja_file_get_string_attribute (file, "type"); } else { new_icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | @@ -390,6 +393,8 @@ get_image_for_properties_window (FMPropertiesWindow *window, g_object_unref (icon); g_object_unref (new_icon); icon = NULL; + g_free (display_name); + display_name = g_strdup (_("Multiple files")); break; } g_object_unref (new_icon); @@ -406,11 +411,23 @@ get_image_for_properties_window (FMPropertiesWindow *window, *icon_name = g_strdup (caja_icon_info_get_used_name (icon)); } + if (display_name_ != NULL) { + if (! display_name) { + display_name = g_strdup (_("No files")); + } else if (! caja_icon_info_get_used_name (icon)) { + g_free (display_name); + display_name = g_strdup (_("User-defined icon")); + } + *display_name_ = display_name; + display_name = NULL; + } + if (icon_pixbuf != NULL) { *icon_pixbuf = caja_icon_info_get_pixbuf_at_size (icon, CAJA_ICON_SIZE_STANDARD); } g_object_unref (icon); + g_free (display_name); } static void @@ -419,8 +436,9 @@ update_properties_window_icon (FMPropertiesWindow *window) GdkPixbuf *pixbuf; cairo_surface_t *surface; char *name; + char *display_name; - get_image_for_properties_window (window, &name, &pixbuf); + get_image_for_properties_window (window, &name, &display_name, &pixbuf); if (name != NULL) { gtk_window_set_icon_name (GTK_WINDOW (window), name); @@ -432,7 +450,10 @@ update_properties_window_icon (FMPropertiesWindow *window) gtk_widget_get_window (GTK_WIDGET (window))); gtk_image_set_from_surface (GTK_IMAGE (window->details->icon_image), surface); + atk_object_set_name (gtk_widget_get_accessible (window->details->icon_image), display_name); + g_free (name); + g_free (display_name); g_object_unref (pixbuf); cairo_surface_destroy (surface); } @@ -547,7 +568,8 @@ create_image_widget (FMPropertiesWindow *window, button = NULL; if (is_customizable) { button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), image); + gtk_widget_set_tooltip_text (button, _("Change associated icon")); + gtk_button_set_image (GTK_BUTTON (button), image); /* prepare the image to receive dropped objects to assign custom images */ gtk_drag_dest_set (GTK_WIDGET (image), |