[gtk/a11y/atspi-action: 4/4] a11y: Add atspi.Action for GtkPasswordEntry
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/atspi-action: 4/4] a11y: Add atspi.Action for GtkPasswordEntry
- Date: Thu, 15 Oct 2020 20:22:11 +0000 (UTC)
commit 529c866fdd3924ad2b0bc9994fdd8228d08ca300
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Oct 15 19:21:27 2020 +0100
a11y: Add atspi.Action for GtkPasswordEntry
gtk/a11y/gtkatspiaction.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
---
diff --git a/gtk/a11y/gtkatspiaction.c b/gtk/a11y/gtkatspiaction.c
index 3da07c7948..2edba26585 100644
--- a/gtk/a11y/gtkatspiaction.c
+++ b/gtk/a11y/gtkatspiaction.c
@@ -32,6 +32,7 @@
#include "gtkbutton.h"
#include "gtkentryprivate.h"
#include "gtkexpander.h"
+#include "gtkpasswordentryprivate.h"
#include "gtkswitch.h"
#include "gtkwidgetprivate.h"
@@ -498,6 +499,94 @@ static const GDBusInterfaceVTable entry_action_vtable = {
/* }}} */
+/* {{{ GtkPasswordEntry */
+
+static gboolean is_peek_enabled (GtkAtSpiContext *self);
+static gboolean activate_peek (GtkAtSpiContext *self);
+
+static const Action password_entry_actions[] = {
+ {
+ .name = "activate",
+ .localized_name = NC_("accessibility", "Activate"),
+ .description = NC_("accessibility", "Activates the entry"),
+ .keybinding = "<Return>",
+ .is_enabled = NULL,
+ .activate = NULL,
+ },
+ {
+ .name = "peek",
+ .localized_name = NC_("accessibility", "Peek"),
+ .description = NC_("accessibility", "Shows the contents of the password entry"),
+ .keybinding = "<VoidSymbol>",
+ .is_enabled = is_peek_enabled,
+ .activate = activate_peek,
+ },
+};
+
+static gboolean
+is_peek_enabled (GtkAtSpiContext *self)
+{
+ GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
+ GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (accessible);
+
+ if (!gtk_password_entry_get_show_peek_icon (entry))
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+activate_peek (GtkAtSpiContext *self)
+{
+ GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
+ GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (accessible);
+
+ gtk_password_entry_toggle_peek (entry);
+
+ return TRUE;
+}
+
+static void
+password_entry_handle_method (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ GtkAtSpiContext *self = user_data;
+
+ action_handle_method (self, method_name, parameters, invocation,
+ password_entry_actions,
+ G_N_ELEMENTS (password_entry_actions));
+}
+
+static GVariant *
+password_entry_handle_get_property (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+ GtkAtSpiContext *self = user_data;
+
+ return action_handle_get_property (self, property_name, error,
+ password_entry_actions,
+ G_N_ELEMENTS (password_entry_actions));
+}
+
+static const GDBusInterfaceVTable password_entry_action_vtable = {
+ password_entry_handle_method,
+ password_entry_handle_get_property,
+ NULL,
+};
+
+/* }}} */
+
static gboolean
is_valid_action (GtkActionMuxer *muxer,
const char *action_name)
@@ -715,6 +804,8 @@ gtk_atspi_get_action_vtable (GtkAccessible *accessible)
return &entry_action_vtable;
else if (GTK_IS_EXPANDER (accessible))
return &expander_action_vtable;
+ else if (GTK_IS_PASSWORD_ENTRY (accessible))
+ return &password_entry_action_vtable;
else if (GTK_IS_SWITCH (accessible))
return &switch_action_vtable;
else if (GTK_IS_WIDGET (accessible))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]