summaryrefslogtreecommitdiff
path: root/gtk/gtkpasswordentry.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-07-28 18:23:57 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-07-28 18:23:57 -0400
commit1755e07af73690cb4d9033798b1ee6b70a041978 (patch)
tree4b9a807decab6260eba4da2ea6d4187c4f00abb4 /gtk/gtkpasswordentry.c
parenta610bb89a0fecf0b27001b4444b2e47e1c5e0af3 (diff)
downloadgtk+-1755e07af73690cb4d9033798b1ee6b70a041978.tar.gz
a11y: Set an accessible role for GtkPasswordEntry
Use the text-box accessible role for GtkPasswordEntry. And set properties as appropriate. Update the documentation and add a test.
Diffstat (limited to 'gtk/gtkpasswordentry.c')
-rw-r--r--gtk/gtkpasswordentry.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index 93d560e49e..252b8be0f2 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -61,6 +61,10 @@
* a .passwordstyle class. The text Css node below it has a child with
* name image and style class .caps-lock-indicator for the Caps Lock
* icon, and possibly other children.
+ *
+ * # Accessibility
+ *
+ * GtkPasswordEntry uses the #GTK_ACCESSIBLE_ROLE_TEXT_BOX role.
*/
typedef struct {
@@ -222,14 +226,27 @@ gtk_password_entry_set_property (GObject *object,
{
GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (object);
GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
+ const char *text;
if (gtk_editable_delegate_set_property (object, prop_id, value, pspec))
- return;
+ {
+ if (prop_id == NUM_PROPERTIES + GTK_EDITABLE_PROP_EDITABLE)
+ {
+ gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
+ GTK_ACCESSIBLE_PROPERTY_READ_ONLY, !g_value_get_boolean (value),
+ -1);
+ }
+ return;
+ }
switch (prop_id)
{
case PROP_PLACEHOLDER_TEXT:
- gtk_text_set_placeholder_text (GTK_TEXT (priv->entry), g_value_get_string (value));
+ text = g_value_get_string (value);
+ gtk_text_set_placeholder_text (GTK_TEXT (priv->entry), text);
+ gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
+ GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER, text,
+ -1);
break;
case PROP_ACTIVATES_DEFAULT:
@@ -424,6 +441,7 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
gtk_editable_install_properties (object_class, NUM_PROPERTIES);
gtk_widget_class_set_css_name (widget_class, I_("entry"));
+ gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
}
static GtkEditable *