[gtk/ebassi/for-master: 12/15] a11y: Add accessible actions to GtkSearchEntry
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ebassi/for-master: 12/15] a11y: Add accessible actions to GtkSearchEntry
- Date: Thu, 12 Nov 2020 16:23:01 +0000 (UTC)
commit 53f3efb7a77cb832f20524d30d95aaef61b89b5a
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Nov 12 16:05:31 2020 +0000
a11y: Add accessible actions to GtkSearchEntry
Just like GtkPasswordEntry, GtkSearchEntry should have its set of
accessible actions.
gtk/a11y/gtkatspiaction.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
---
diff --git a/gtk/a11y/gtkatspiaction.c b/gtk/a11y/gtkatspiaction.c
index 1de9362070..cdb5c2b36e 100644
--- a/gtk/a11y/gtkatspiaction.c
+++ b/gtk/a11y/gtkatspiaction.c
@@ -35,6 +35,7 @@
#include "gtkexpander.h"
#include "gtkmodelbuttonprivate.h"
#include "gtkpasswordentryprivate.h"
+#include "gtksearchentry.h"
#include "gtkswitch.h"
#include "gtkwidgetprivate.h"
@@ -681,6 +682,93 @@ static const GDBusInterfaceVTable password_entry_action_vtable = {
NULL,
};
+/* }}} */
+/* {{{ GtkSearchEntry */
+
+static gboolean is_clear_enabled (GtkAtSpiContext *self);
+static gboolean activate_clear (GtkAtSpiContext *self);
+
+static const Action search_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", "Clear"),
+ .description = NC_("accessibility", "Clears the contents of the entry"),
+ .keybinding = "<VoidSymbol>",
+ .is_enabled = is_clear_enabled,
+ .activate = activate_clear,
+ },
+};
+
+static gboolean
+is_clear_enabled (GtkAtSpiContext *self)
+{
+ GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
+ GtkSearchEntry *entry = GTK_SEARCH_ENTRY (accessible);
+
+ const char *str = gtk_editable_get_text (GTK_EDITABLE (entry));
+
+ if (str == NULL || *str == '\0')
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+activate_clear (GtkAtSpiContext *self)
+{
+ GtkAccessible *accessible = gtk_at_context_get_accessible (GTK_AT_CONTEXT (self));
+
+ gtk_editable_set_text (GTK_EDITABLE (accessible), "");
+
+ return TRUE;
+}
+
+static void
+search_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,
+ search_entry_actions,
+ G_N_ELEMENTS (search_entry_actions));
+}
+
+static GVariant *
+search_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,
+ search_entry_actions,
+ G_N_ELEMENTS (search_entry_actions));
+}
+
+static const GDBusInterfaceVTable search_entry_action_vtable = {
+ search_entry_handle_method,
+ search_entry_handle_get_property,
+ NULL,
+};
/* }}} */
static gboolean
@@ -915,6 +1003,8 @@ gtk_atspi_get_action_vtable (GtkAccessible *accessible)
return &expander_action_vtable;
else if (GTK_IS_PASSWORD_ENTRY (accessible))
return &password_entry_action_vtable;
+ else if (GTK_IS_SEARCH_ENTRY (accessible))
+ return &search_entry_action_vtable;
else if (GTK_IS_SWITCH (accessible))
return &switch_action_vtable;
else if (GTK_IS_COLOR_SWATCH (accessible))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]