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
This commit is contained in:
Benjamin Otte 2014-03-07 21:45:18 +01:00
parent 1ff2161431
commit 66fae0330c
3 changed files with 50 additions and 30 deletions

View File

@ -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)
{
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
GtkContainerAccessibleClass *klass;
void
_gtk_container_accessible_remove (GtkWidget *parent,
GtkWidget *child)
{
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;
}

View File

@ -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__ */

View File

@ -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