[gtk+] a11y: Don't use signals



commit 66fae0330c5cdb68f50699ff2645ff0cf112911e
Author: Benjamin Otte <otte redhat com>
Date:   Fri Mar 7 21:45:18 2014 +0100

    a11y: Don't use signals
    
    Instead, call functions directly. Fixes the fact that the signals
    weren't disconnected even when the accessible was destroyed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725733

 gtk/a11y/gtkcontaineraccessible.c        |   48 +++++++++++++++++-------------
 gtk/a11y/gtkcontaineraccessibleprivate.h |   19 +++++++----
 gtk/gtkcontainer.c                       |    9 +++++
 3 files changed, 48 insertions(+), 28 deletions(-)
---
diff --git a/gtk/a11y/gtkcontaineraccessible.c b/gtk/a11y/gtkcontaineraccessible.c
index 98e5554..0ea0d76 100644
--- a/gtk/a11y/gtkcontaineraccessible.c
+++ b/gtk/a11y/gtkcontaineraccessible.c
@@ -17,10 +17,13 @@
 
 #include "config.h"
 
-#include <gtk/gtk.h>
 #include "gtkcontaineraccessible.h"
 #include "gtkcontaineraccessibleprivate.h"
 
+#include <gtk/gtk.h>
+
+#include "gtkwidgetprivate.h"
+
 struct _GtkContainerAccessiblePrivate
 {
   GList *children;
@@ -76,36 +79,42 @@ gtk_container_accessible_ref_child (AtkObject *obj,
   return accessible;
 }
 
-static gint
-gtk_container_accessible_add_gtk (GtkContainer *container,
-                                  GtkWidget    *widget,
-                                  gpointer      data)
+void
+_gtk_container_accessible_add (GtkWidget *parent,
+                               GtkWidget *child)
 {
-  GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
+  GtkContainerAccessible *accessible;
   GtkContainerAccessibleClass *klass;
+  AtkObject *obj;
+
+  obj = _gtk_widget_peek_accessible (GTK_WIDGET (parent));
+  if (!GTK_IS_CONTAINER_ACCESSIBLE (obj))
+    return;
 
+  accessible = GTK_CONTAINER_ACCESSIBLE (obj);
   klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
 
   if (klass->add_gtk)
-    return klass->add_gtk (container, widget, data);
-  else
-    return 1;
+    klass->add_gtk (GTK_CONTAINER (parent), child, obj);
 }
- 
-static gint
-gtk_container_accessible_remove_gtk (GtkContainer *container,
-                                     GtkWidget    *widget,
-                                     gpointer     data)
+
+void
+_gtk_container_accessible_remove (GtkWidget *parent,
+                                  GtkWidget *child)
 {
-  GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
+  GtkContainerAccessible *accessible;
   GtkContainerAccessibleClass *klass;
+  AtkObject *obj;
+
+  obj = _gtk_widget_peek_accessible (GTK_WIDGET (parent));
+  if (!GTK_IS_CONTAINER_ACCESSIBLE (obj))
+    return;
 
+  accessible = GTK_CONTAINER_ACCESSIBLE (obj);
   klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
 
   if (klass->remove_gtk)
-    return klass->remove_gtk (container, widget, data);
-  else
-    return 1;
+    klass->remove_gtk (GTK_CONTAINER (parent), child, obj);
 }
 
 static gint
@@ -165,9 +174,6 @@ gtk_container_accessible_real_initialize (AtkObject *obj,
 
   accessible->priv->children = gtk_container_get_children (GTK_CONTAINER (data));
 
-  g_signal_connect (data, "add", G_CALLBACK (gtk_container_accessible_add_gtk), obj);
-  g_signal_connect (data, "remove", G_CALLBACK (gtk_container_accessible_remove_gtk), obj);
-
   obj->role = ATK_ROLE_PANEL;
 }
 
diff --git a/gtk/a11y/gtkcontaineraccessibleprivate.h b/gtk/a11y/gtkcontaineraccessibleprivate.h
index fa692ce..4d02a73 100644
--- a/gtk/a11y/gtkcontaineraccessibleprivate.h
+++ b/gtk/a11y/gtkcontaineraccessibleprivate.h
@@ -1,5 +1,5 @@
 /* GTK+ - accessibility implementations
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright (C) 2014  Benjamin Otte <otte gnome org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,12 +22,17 @@
 
 G_BEGIN_DECLS
 
-void _gtk_container_accessible_add_child    (GtkContainerAccessible *accessible,
-                                             AtkObject              *child,
-                                             gint                    index);
-void _gtk_container_accessible_remove_child (GtkContainerAccessible *accessible,
-                                             AtkObject              *child,
-                                             gint                    index);
+void            _gtk_container_accessible_add_child     (GtkContainerAccessible *accessible,
+                                                         AtkObject              *child,
+                                                         gint                    index);
+void            _gtk_container_accessible_remove_child  (GtkContainerAccessible *accessible,
+                                                         AtkObject              *child,
+                                                         gint                    index);
+void            _gtk_container_accessible_add           (GtkWidget              *parent,
+                                                         GtkWidget              *child);
+void            _gtk_container_accessible_remove        (GtkWidget              *parent,
+                                                         GtkWidget              *child);
+
 G_END_DECLS
 
 #endif /* __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__ */
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 1403139..1a99de3 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -50,6 +50,7 @@
 #include "gtkstylecontextprivate.h"
 #include "gtkwidgetpath.h"
 #include "a11y/gtkcontaineraccessible.h"
+#include "a11y/gtkcontaineraccessibleprivate.h"
 
 /**
  * SECTION:gtkcontainer
@@ -1556,6 +1557,8 @@ gtk_container_add (GtkContainer *container,
     }
 
   g_signal_emit (container, container_signals[ADD], 0, widget);
+
+  _gtk_container_accessible_add (GTK_WIDGET (container), widget);
 }
 
 /**
@@ -1581,7 +1584,13 @@ gtk_container_remove (GtkContainer *container,
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container) || GTK_IS_ASSISTANT (container) 
|| GTK_IS_ACTION_BAR (container));
 
+  g_object_ref (widget);
+
   g_signal_emit (container, container_signals[REMOVE], 0, widget);
+
+  _gtk_container_accessible_remove (GTK_WIDGET (container), widget);
+
+  g_object_unref (widget);
 }
 
 void


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