[gtk/wip/ebassi/a11y-2: 429/442] a11y: Simplify GtkLevelBarAccessible
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/a11y-2: 429/442] a11y: Simplify GtkLevelBarAccessible
- Date: Fri, 5 Jun 2020 19:37:22 +0000 (UTC)
commit 0dcffe7c33e8cee663809a3afab7b3fe38686fbc
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed May 27 19:19:55 2020 +0100
a11y: Simplify GtkLevelBarAccessible
Drop the GtkWidgetAccessible.notify_gtk and AtkObject.initialize
overrides, and have GtkLevelBar notify the accessible object of value
changes.
gtk/a11y/gtklevelbaraccessible.c | 42 ++++++++++++++++------------------------
gtk/gtklevelbar.c | 6 ++++--
2 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/gtk/a11y/gtklevelbaraccessible.c b/gtk/a11y/gtklevelbaraccessible.c
index f4fd19d620..071845a167 100644
--- a/gtk/a11y/gtklevelbaraccessible.c
+++ b/gtk/a11y/gtklevelbaraccessible.c
@@ -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));
-
- 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);
-}
-
+ GtkLevelBar *level_bar = data;
+ 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;
-
- widget_class->notify_gtk = gtk_level_bar_accessible_notify_gtk;
+ AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
- 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
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index d95dba0782..b879494f65 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -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));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]