diff options
author | Samuel Thibault <[email protected]> | 2018-06-05 17:03:19 +0200 |
---|---|---|
committer | lukefromdc <[email protected]> | 2018-06-27 18:50:28 -0400 |
commit | ba087de8c7a9f1a4b93fdc74d917465dd2d89eb0 (patch) | |
tree | 9c78f9e03231217f2c444e17f2d6a758c009043b | |
parent | 3f19451892020b595a80eaa480c639625e3ee931 (diff) | |
download | caja-ba087de8c7a9f1a4b93fdc74d917465dd2d89eb0.tar.bz2 caja-ba087de8c7a9f1a4b93fdc74d917465dd2d89eb0.tar.xz |
desktop window: Add is-desktop AtkObject attribute
Screen readers need to distinguish between the desktop window and normal
windows, to be able to provide nicer speech synthesis.
This can be done by simply adding an "is-desktop" attribute to the
underlying AtkObject.
This is here done by introducing a thin caja_desktop_window_accessible_class
class which is based on GtkWindowAccessible and just appends the
attribute.
Closes: #999
-rw-r--r-- | src/caja-desktop-window.c | 37 | ||||
-rw-r--r-- | src/caja-desktop-window.h | 14 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c index 16242dcd..b3d24ffe 100644 --- a/src/caja-desktop-window.c +++ b/src/caja-desktop-window.c @@ -37,6 +37,41 @@ #include <gio/gio.h> #include <glib/gi18n.h> +/* Tell screen readers that this is a desktop window */ + +G_DEFINE_TYPE (CajaDesktopWindowAccessible, caja_desktop_window_accessible, + GTK_TYPE_WINDOW_ACCESSIBLE); + +static AtkAttributeSet * +desktop_get_attributes (AtkObject *accessible) +{ + AtkAttributeSet *attributes; + AtkAttribute *is_desktop; + + attributes = ATK_OBJECT_CLASS (caja_desktop_window_accessible_parent_class)->get_attributes (accessible); + + is_desktop = g_malloc (sizeof (AtkAttribute)); + is_desktop->name = g_strdup ("is-desktop"); + is_desktop->value = g_strdup ("true"); + + attributes = g_slist_append (attributes, is_desktop); + + return attributes; +} + +static void +caja_desktop_window_accessible_init (CajaDesktopWindowAccessible *window) +{ +} + +static void +caja_desktop_window_accessible_class_init (CajaDesktopWindowAccessibleClass *klass) +{ + AtkObjectClass *aclass = ATK_OBJECT_CLASS (klass); + + aclass->get_attributes = desktop_get_attributes; +} + struct CajaDesktopWindowDetails { gulong size_changed_id; @@ -289,6 +324,8 @@ caja_desktop_window_class_init (CajaDesktopWindowClass *klass) wclass->map = map; wclass->draw = draw; + gtk_widget_class_set_accessible_type (wclass, CAJA_TYPE_DESKTOP_WINDOW_ACCESSIBLE); + nclass->window_type = CAJA_WINDOW_DESKTOP; nclass->get_title = real_get_title; nclass->get_icon = real_get_icon; diff --git a/src/caja-desktop-window.h b/src/caja-desktop-window.h index 2bd3579c..5692177b 100644 --- a/src/caja-desktop-window.h +++ b/src/caja-desktop-window.h @@ -32,6 +32,8 @@ #include "caja-application.h" #include "caja-spatial-window.h" +#include <gtk/gtk-a11y.h> + #define CAJA_TYPE_DESKTOP_WINDOW caja_desktop_window_get_type() #define CAJA_DESKTOP_WINDOW(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_DESKTOP_WINDOW, CajaDesktopWindow)) @@ -64,4 +66,16 @@ CajaDesktopWindow *caja_desktop_window_new (CajaApplication *app void caja_desktop_window_update_directory (CajaDesktopWindow *window); gboolean caja_desktop_window_loaded (CajaDesktopWindow *window); +#define CAJA_TYPE_DESKTOP_WINDOW_ACCESSIBLE caja_desktop_window_accessible_get_type() + +typedef struct +{ + GtkWindowAccessible parent_spot; +} CajaDesktopWindowAccessible; + +typedef struct +{ + GtkWindowAccessibleClass parent_spot; +} CajaDesktopWindowAccessibleClass; + #endif /* CAJA_DESKTOP_WINDOW_H */ |