a11y: Simplify GtkLevelBarAccessible

Drop the GtkWidgetAccessible.notify_gtk and AtkObject.initialize
overrides, and have GtkLevelBar notify the accessible object of value
changes.
This commit is contained in:
Emmanuele Bassi 2020-05-27 19:19:55 +01:00
parent 9f09cfcfbd
commit 0dcffe7c33
2 changed files with 20 additions and 26 deletions

View File

@ -18,10 +18,11 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtklevelbaraccessible.h"
#include "gtklevelbar.h"
#include <string.h>
static void atk_value_interface_init (AtkValueIface *iface);
@ -29,45 +30,36 @@ G_DEFINE_TYPE_WITH_CODE (GtkLevelBarAccessible, gtk_level_bar_accessible, GTK_TY
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
static void
gtk_level_bar_accessible_initialize (AtkObject *obj,
gpointer data)
on_value_changed (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
ATK_OBJECT_CLASS (gtk_level_bar_accessible_parent_class)->initialize (obj, data);
GtkLevelBarAccessible *self = user_data;
obj->role = ATK_ROLE_LEVEL_BAR;
g_object_notify (G_OBJECT (self), "accessible-value");
}
static void
gtk_level_bar_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
gtk_level_bar_accessible_initialize (AtkObject *object,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (obj);
GtkLevelBarAccessible *level_bar = GTK_LEVEL_BAR_ACCESSIBLE (gtk_widget_get_accessible (widget));
GtkLevelBar *level_bar = data;
if (strcmp (pspec->name, "value") == 0)
{
g_object_notify (G_OBJECT (level_bar), "accessible-value");
}
else
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_level_bar_accessible_parent_class)->notify_gtk (obj, pspec);
g_signal_connect (level_bar, "notify::value", G_CALLBACK (on_value_changed), object);
}
static void
gtk_level_bar_accessible_class_init (GtkLevelBarAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
widget_class->notify_gtk = gtk_level_bar_accessible_notify_gtk;
class->initialize = gtk_level_bar_accessible_initialize;
object_class->initialize = gtk_level_bar_accessible_initialize;
}
static void
gtk_level_bar_accessible_init (GtkLevelBarAccessible *button)
gtk_level_bar_accessible_init (GtkLevelBarAccessible *self)
{
ATK_OBJECT (self)->role = ATK_ROLE_LEVEL_BAR;
}
static void

View File

@ -133,11 +133,11 @@
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtklevelbaraccessible.h"
#include <math.h>
#include <stdlib.h>
#include "a11y/gtklevelbaraccessible.h"
enum {
PROP_VALUE = 1,
PROP_MIN_VALUE,
@ -1122,7 +1122,9 @@ gtk_level_bar_set_value_internal (GtkLevelBar *self,
gdouble value)
{
self->cur_value = value;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VALUE]);
gtk_widget_queue_allocate (GTK_WIDGET (self->trough_widget));
}