summaryrefslogtreecommitdiff
path: root/gtk/gtkpasswordentry.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-10-12 21:33:55 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-10-12 21:45:48 -0400
commit852c72fa28bb3802657aa3579207733342b355f6 (patch)
treea4c539b70d08cad043d7a9d461da0d663d12540c /gtk/gtkpasswordentry.c
parentf796d02fea3ac7ec9435555133eb751d8df5df8f (diff)
downloadgtk+-852c72fa28bb3802657aa3579207733342b355f6.tar.gz
passwordentry: Implement GtkAccessible
This copies what was done for GtkEntry: get the focused state from the GtkText within.
Diffstat (limited to 'gtk/gtkpasswordentry.c')
-rw-r--r--gtk/gtkpasswordentry.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index ec8d08b119..e6658ecf2e 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -22,6 +22,7 @@
#include "gtkpasswordentryprivate.h"
+#include "gtkaccessibleprivate.h"
#include "gtktextprivate.h"
#include "gtkeditable.h"
#include "gtkeventcontrollerkey.h"
@@ -105,8 +106,10 @@ enum {
static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
static void gtk_password_entry_editable_init (GtkEditableInterface *iface);
+static void gtk_password_entry_accessible_init (GtkAccessibleInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkPasswordEntry, gtk_password_entry, GTK_TYPE_WIDGET,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, gtk_password_entry_accessible_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, gtk_password_entry_editable_init))
static void
@@ -487,6 +490,31 @@ gtk_password_entry_editable_init (GtkEditableInterface *iface)
iface->get_delegate = gtk_password_entry_get_delegate;
}
+static gboolean
+gtk_password_entry_accessible_get_platform_state (GtkAccessible *self,
+ GtkAccessiblePlatformState state)
+{
+ GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (self);
+
+ switch (state)
+ {
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE:
+ return gtk_widget_get_focusable (GTK_WIDGET (entry->entry));
+ case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED:
+ return gtk_widget_has_focus (GTK_WIDGET (entry->entry));
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+gtk_password_entry_accessible_init (GtkAccessibleInterface *iface)
+{
+ GtkAccessibleInterface *parent_iface = g_type_interface_peek_parent (iface);
+ iface->get_at_context = parent_iface->get_at_context;
+ iface->get_platform_state = gtk_password_entry_accessible_get_platform_state;
+}
+
GtkText *
gtk_password_entry_get_text_widget (GtkPasswordEntry *entry)
{