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 @@
#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;
}
......
/* 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
......@@ -28,6 +28,11 @@ void _gtk_container_accessible_add_child (GtkContainerAccessible *accessible,
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__ */
......@@ -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
......
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