[gtk+/wip/a11y: 3/10] range: Notify accessible of value changes



commit 8eb20f751e723372ae75e538aa1b6b963a01db42
Author: Mike Gorse <mgorse suse com>
Date:   Tue Jan 8 18:57:13 2013 +0100

    range: Notify accessible of value changes
    
    Instead of using a signal from the accessible, we call it directly.

 gtk/a11y/Makefile.am                 |    1 +
 gtk/a11y/gtkrangeaccessible.c        |   80 +++++-----------------------------
 gtk/a11y/gtkrangeaccessibleprivate.h |   29 ++++++++++++
 gtk/gtkrange.c                       |    5 ++-
 4 files changed, 45 insertions(+), 70 deletions(-)
---
diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am
index 62dd68f..6ef98d9 100644
--- a/gtk/a11y/Makefile.am
+++ b/gtk/a11y/Makefile.am
@@ -105,6 +105,7 @@ gtka11y_private_h_sources =		\
 	gtkcolorswatchaccessibleprivate.h \
 	gtkiconviewaccessibleprivate.h	\
 	gtklockbuttonaccessibleprivate.h \
+	gtkrangeaccessibleprivate.h     \
 	gtktextviewaccessibleprivate.h  \
 	gtktreeviewaccessibleprivate.h	\
 	gtkwidgetaccessibleprivate.h
diff --git a/gtk/a11y/gtkrangeaccessible.c b/gtk/a11y/gtkrangeaccessible.c
index be9c371..a85d7e0 100644
--- a/gtk/a11y/gtkrangeaccessible.c
+++ b/gtk/a11y/gtkrangeaccessible.c
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <gtk/gtk.h>
 #include "gtkrangeaccessible.h"
+#include "gtkwidgetprivate.h"
 
 
 static void atk_action_interface_init (AtkActionIface *iface);
@@ -30,89 +31,20 @@ G_DEFINE_TYPE_WITH_CODE (GtkRangeAccessible, gtk_range_accessible, GTK_TYPE_WIDG
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
 
 static void
-gtk_range_accessible_value_changed (GtkAdjustment *adjustment,
-                                    gpointer       data)
-{
-  g_object_notify (G_OBJECT (data), "accessible-value");
-}
-
-static void
 gtk_range_accessible_initialize (AtkObject *obj,
                                  gpointer   data)
 {
-  GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (obj);
-  GtkAdjustment *adj;
-  GtkRange *gtk_range;
-
   ATK_OBJECT_CLASS (gtk_range_accessible_parent_class)->initialize (obj, data);
 
-  gtk_range = GTK_RANGE (data);
-  /*
-   * If a GtkAdjustment already exists for the GtkRange,
-   * create the GailAdjustment
-   */
-  adj = gtk_range_get_adjustment (gtk_range);
-  if (adj)
-    g_signal_connect (adj, "value-changed",
-                      G_CALLBACK (gtk_range_accessible_value_changed),
-                      range);
-
   obj->role = ATK_ROLE_SLIDER;
 }
 
 static void
-gtk_range_accessible_finalize (GObject *object)
-{
-  GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (object);
-  GtkWidget *widget;
-  GtkAdjustment *adj;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
-  if (widget)
-    {
-      adj = gtk_range_get_adjustment (GTK_RANGE (widget));
-      if (adj)
-        g_signal_handlers_disconnect_by_func (adj,
-                                              gtk_range_accessible_value_changed,
-                                              range);
-    }
-
-  G_OBJECT_CLASS (gtk_range_accessible_parent_class)->finalize (object);
-}
-
-static void
-gtk_range_accessible_notify_gtk (GObject    *obj,
-                                 GParamSpec *pspec)
-{
-  GtkWidget *widget = GTK_WIDGET (obj);
-  GtkAdjustment *adj;
-  AtkObject *range;
-
-  if (strcmp (pspec->name, "adjustment") == 0)
-    {
-      range = gtk_widget_get_accessible (widget);
-      adj = gtk_range_get_adjustment (GTK_RANGE (widget));
-      g_signal_connect (adj, "value-changed",
-                        G_CALLBACK (gtk_range_accessible_value_changed),
-                        range);
-    }
-  else
-    GTK_WIDGET_ACCESSIBLE_CLASS (gtk_range_accessible_parent_class)->notify_gtk (obj, pspec);
-}
-
-
-static void
 gtk_range_accessible_class_init (GtkRangeAccessibleClass *klass)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-  GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
-
-  widget_class->notify_gtk = gtk_range_accessible_notify_gtk;
 
   class->initialize = gtk_range_accessible_initialize;
-
-  gobject_class->finalize = gtk_range_accessible_finalize;
 }
 
 static void
@@ -313,3 +245,13 @@ atk_action_interface_init (AtkActionIface *iface)
   iface->get_keybinding = gtk_range_accessible_get_keybinding;
   iface->get_name = gtk_range_accessible_action_get_name;
 }
+
+void
+_gtk_range_accessible_value_changed (GtkRange *range)
+{
+  AtkObject *accessible;
+
+  accessible = _gtk_widget_peek_accessible (GTK_WIDGET (range));
+  if (accessible)
+    g_object_notify (G_OBJECT (accessible), "accessible-value");
+}
diff --git a/gtk/a11y/gtkrangeaccessibleprivate.h b/gtk/a11y/gtkrangeaccessibleprivate.h
new file mode 100644
index 0000000..c8da48a
--- /dev/null
+++ b/gtk/a11y/gtkrangeaccessibleprivate.h
@@ -0,0 +1,29 @@
+/* GTK+ - accessibility implementations
+ * Copyright (C) 2002, 2004  Anders Carlsson <andersca gnu org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_RANGE_ACCESSIBLE_PRIVATE_H__
+#define __GTK_RANGE_ACCESSIBLE_PRIVATE_H__
+
+#include <gtk/a11y/gtkrangeaccessible.h>
+
+G_BEGIN_DECLS
+
+void  _gtk_range_accessible_value_changed (GtkRange *range);
+
+G_END_DECLS
+
+#endif /* __GTK_RANGE_ACCESSIBLE_PRIVATE_H__ */
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index d18cf2b..cff8b29 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -32,6 +32,7 @@
 
 #include "gtkadjustment.h"
 #include "gtkcolorscaleprivate.h"
+#include "gtkwidgetprivate.h"
 #include "gtkintl.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
@@ -41,7 +42,7 @@
 #include "gtkscrollbar.h"
 #include "gtktypebuiltins.h"
 #include "gtkwindow.h"
-#include "a11y/gtkrangeaccessible.h"
+#include "a11y/gtkrangeaccessibleprivate.h"
 
 /**
  * SECTION:gtkrange
@@ -3042,6 +3043,8 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment,
    */
 
   g_signal_emit (range, signals[VALUE_CHANGED], 0);
+
+  _gtk_range_accessible_value_changed (range);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]