Commit 66fae033 authored by Benjamin Otte's avatar Benjamin Otte

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
parent 1ff21614
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
#include "config.h" #include "config.h"
#include <gtk/gtk.h>
#include "gtkcontaineraccessible.h" #include "gtkcontaineraccessible.h"
#include "gtkcontaineraccessibleprivate.h" #include "gtkcontaineraccessibleprivate.h"
#include <gtk/gtk.h>
#include "gtkwidgetprivate.h"
struct _GtkContainerAccessiblePrivate struct _GtkContainerAccessiblePrivate
{ {
GList *children; GList *children;
...@@ -76,36 +79,42 @@ gtk_container_accessible_ref_child (AtkObject *obj, ...@@ -76,36 +79,42 @@ gtk_container_accessible_ref_child (AtkObject *obj,
return accessible; return accessible;
} }
static gint void
gtk_container_accessible_add_gtk (GtkContainer *container, _gtk_container_accessible_add (GtkWidget *parent,
GtkWidget *widget, GtkWidget *child)
gpointer data)
{ {
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data); GtkContainerAccessible *accessible;
GtkContainerAccessibleClass *klass; 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); klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
if (klass->add_gtk) if (klass->add_gtk)
return klass->add_gtk (container, widget, data); klass->add_gtk (GTK_CONTAINER (parent), child, obj);
else
return 1;
} }
static gint void
gtk_container_accessible_remove_gtk (GtkContainer *container, _gtk_container_accessible_remove (GtkWidget *parent,
GtkWidget *widget, GtkWidget *child)
gpointer data)
{ {
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data); GtkContainerAccessible *accessible;
GtkContainerAccessibleClass *klass; 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); klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
if (klass->remove_gtk) if (klass->remove_gtk)
return klass->remove_gtk (container, widget, data); klass->remove_gtk (GTK_CONTAINER (parent), child, obj);
else
return 1;
} }
static gint static gint
...@@ -165,9 +174,6 @@ gtk_container_accessible_real_initialize (AtkObject *obj, ...@@ -165,9 +174,6 @@ gtk_container_accessible_real_initialize (AtkObject *obj,
accessible->priv->children = gtk_container_get_children (GTK_CONTAINER (data)); 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; obj->role = ATK_ROLE_PANEL;
} }
......
/* GTK+ - accessibility implementations /* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -22,12 +22,17 @@ ...@@ -22,12 +22,17 @@
G_BEGIN_DECLS G_BEGIN_DECLS
void _gtk_container_accessible_add_child (GtkContainerAccessible *accessible, void _gtk_container_accessible_add_child (GtkContainerAccessible *accessible,
AtkObject *child, AtkObject *child,
gint index); gint index);
void _gtk_container_accessible_remove_child (GtkContainerAccessible *accessible, void _gtk_container_accessible_remove_child (GtkContainerAccessible *accessible,
AtkObject *child, AtkObject *child,
gint index); gint index);
void _gtk_container_accessible_add (GtkWidget *parent,
GtkWidget *child);
void _gtk_container_accessible_remove (GtkWidget *parent,
GtkWidget *child);
G_END_DECLS G_END_DECLS
#endif /* __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__ */ #endif /* __GTK_CONTAINER_ACCESSIBLE_PRIVATE_H__ */
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "gtkstylecontextprivate.h" #include "gtkstylecontextprivate.h"
#include "gtkwidgetpath.h" #include "gtkwidgetpath.h"
#include "a11y/gtkcontaineraccessible.h" #include "a11y/gtkcontaineraccessible.h"
#include "a11y/gtkcontaineraccessibleprivate.h"
/** /**
* SECTION:gtkcontainer * SECTION:gtkcontainer
...@@ -1556,6 +1557,8 @@ gtk_container_add (GtkContainer *container, ...@@ -1556,6 +1557,8 @@ gtk_container_add (GtkContainer *container,
} }
g_signal_emit (container, container_signals[ADD], 0, widget); 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, ...@@ -1581,7 +1584,13 @@ gtk_container_remove (GtkContainer *container,
g_return_if_fail (GTK_IS_WIDGET (widget)); 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_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); g_signal_emit (container, container_signals[REMOVE], 0, widget);
_gtk_container_accessible_remove (GTK_WIDGET (container), widget);
g_object_unref (widget);
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment