[gtk/a11y/atspi] atspi: Fix up the role for password entries
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/atspi] atspi: Fix up the role for password entries
- Date: Tue, 13 Oct 2020 14:54:04 +0000 (UTC)
commit b909455154083383b588cadb604dafec535abcd7
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 13 10:52:43 2020 -0400
atspi: Fix up the role for password entries
We use to set the the 'password text' role for entries with
visibility = FALSE. Nowadays, we have a separate class for
password entries, so fix up the role mapping based on that.
gtk/a11y/gtkatspicontext.c | 4 ++--
gtk/a11y/gtkatspiutils.c | 26 +++++++++++++++++++++++++-
gtk/a11y/gtkatspiutilsprivate.h | 4 ++--
3 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 9a5f58fd47..aa9b3ccf05 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -370,8 +370,8 @@ handle_accessible_method (GDBusConnection *connection,
if (g_strcmp0 (method_name, "GetRole") == 0)
{
- GtkAccessibleRole role = gtk_at_context_get_accessible_role (GTK_AT_CONTEXT (self));
- guint atspi_role = gtk_accessible_role_to_atspi_role (role);
+ guint atspi_role = gtk_atspi_role_for_context (GTK_AT_CONTEXT (self));
+
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", atspi_role));
}
else if (g_strcmp0 (method_name, "GetRoleName") == 0)
diff --git a/gtk/a11y/gtkatspiutils.c b/gtk/a11y/gtkatspiutils.c
index cea75297e5..f4c854693d 100644
--- a/gtk/a11y/gtkatspiutils.c
+++ b/gtk/a11y/gtkatspiutils.c
@@ -21,6 +21,8 @@
#include "config.h"
#include "gtkatspiutilsprivate.h"
+#include "gtkenums.h"
+#include "gtkpasswordentry.h"
/*< private >
* gtk_accessible_role_to_atspi_role:
@@ -30,7 +32,7 @@
*
* Returns: an #AtspiRole
*/
-AtspiRole
+static AtspiRole
gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
{
switch (role)
@@ -276,6 +278,28 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
return ATSPI_ROLE_FILLER;
}
+/*<private>
+ * gtk_atspi_role_for_context:
+ * @context: a #GtkATContext
+ *
+ * Returns a suitable ATSPI role for a context, taking into account
+ * both the #GtkAccessibleRole set on the context and the type
+ * of accessible.
+ *
+ * Returns: an #AtspiRole
+ */
+AtspiRole
+gtk_atspi_role_for_context (GtkATContext *context)
+{
+ GtkAccessible *accessible = gtk_at_context_get_accessible (context);
+ GtkAccessibleRole role = gtk_at_context_get_accessible_role (context);
+
+ if (GTK_IS_PASSWORD_ENTRY (accessible))
+ return ATSPI_ROLE_PASSWORD_TEXT;
+
+ return gtk_accessible_role_to_atspi_role (role);
+}
+
GVariant *
gtk_at_spi_null_ref (void)
{
diff --git a/gtk/a11y/gtkatspiutilsprivate.h b/gtk/a11y/gtkatspiutilsprivate.h
index dc8be1cca8..20b0b09305 100644
--- a/gtk/a11y/gtkatspiutilsprivate.h
+++ b/gtk/a11y/gtkatspiutilsprivate.h
@@ -21,12 +21,12 @@
#pragma once
#include "gtkatspiprivate.h"
-#include "gtkenums.h"
+#include "gtkatcontextprivate.h"
G_BEGIN_DECLS
AtspiRole
-gtk_accessible_role_to_atspi_role (GtkAccessibleRole role);
+gtk_atspi_role_for_context (GtkATContext *context);
GVariant *
gtk_at_spi_null_ref (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]