From 6f4ed6c105f7e1f867d65fd5134b3e758d3a8ef6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 28 May 2020 15:46:42 +0100 Subject: [PATCH] a11y: Simplify GtkTextViewAccessible Drop the GtkWidgetAccessible.notify_gtk override. --- gtk/a11y/gtktextviewaccessible.c | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/gtk/a11y/gtktextviewaccessible.c b/gtk/a11y/gtktextviewaccessible.c index 109d56bc17..9962c23607 100644 --- a/gtk/a11y/gtktextviewaccessible.c +++ b/gtk/a11y/gtktextviewaccessible.c @@ -67,6 +67,18 @@ G_DEFINE_TYPE_WITH_CODE (GtkTextViewAccessible, gtk_text_view_accessible, GTK_TY G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init)) +static void +on_editable_changed (GObject *gobject, + GParamSpec *pspec, + AtkObject *accessible) +{ + GtkTextView *text_view = GTK_TEXT_VIEW (gobject); + + atk_object_notify_state_change (accessible, + ATK_STATE_EDITABLE, + gtk_text_view_get_editable (text_view)); +} + static void gtk_text_view_accessible_initialize (AtkObject *obj, gpointer data) @@ -74,25 +86,10 @@ gtk_text_view_accessible_initialize (AtkObject *obj, ATK_OBJECT_CLASS (gtk_text_view_accessible_parent_class)->initialize (obj, data); obj->role = ATK_ROLE_TEXT; -} -static void -gtk_text_view_accessible_notify_gtk (GObject *obj, - GParamSpec *pspec) -{ - AtkObject *atk_obj; - - atk_obj = gtk_widget_get_accessible (GTK_WIDGET (obj)); - - if (!strcmp (pspec->name, "editable")) - { - gboolean editable; - - editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (obj)); - atk_object_notify_state_change (atk_obj, ATK_STATE_EDITABLE, editable); - } - else - GTK_WIDGET_ACCESSIBLE_CLASS (gtk_text_view_accessible_parent_class)->notify_gtk (obj, pspec); + g_signal_connect (data, "notify::editable", + G_CALLBACK (on_editable_changed), + obj); } static AtkStateSet* @@ -167,15 +164,12 @@ gtk_text_view_accessible_class_init (GtkTextViewAccessibleClass *klass) { AtkObjectClass *class = ATK_OBJECT_CLASS (klass); GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass); - GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass; accessible_class->widget_set = gtk_text_view_accessible_widget_set; accessible_class->widget_unset = gtk_text_view_accessible_widget_unset; class->ref_state_set = gtk_text_view_accessible_ref_state_set; class->initialize = gtk_text_view_accessible_initialize; - - widget_class->notify_gtk = gtk_text_view_accessible_notify_gtk; } static void