a11y: Redo vfuncs of GtkContainerAccessible

Rename from add_gtk and remove_gtk to simply add and remove and make
them take accessible and widget as parameters.
We do pass in the child widget and not its accessible to give the vfunc
the chance to actually figure out if it needs to create the accessible
for a given widget or not.
This commit is contained in:
Mike Gorse
2013-01-13 15:13:41 +01:00
committed by Benjamin Otte
parent 6c68b25008
commit a1bb39a42b
7 changed files with 58 additions and 64 deletions

View File

@@ -234,8 +234,8 @@ gtk_button_accessible_class_init (GtkButtonAccessibleClass *klass)
widget_class->notify_gtk = gtk_button_accessible_notify_gtk;
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
container_class->add = NULL;
container_class->remove = NULL;
}
static void

View File

@@ -19,6 +19,7 @@
#include <gtk/gtk.h>
#include "gtkcontaineraccessible.h"
#include "gtkwidgetprivate.h"
struct _GtkContainerAccessiblePrivate
{
@@ -72,85 +73,81 @@ gtk_container_accessible_ref_child (AtkObject *obj,
return accessible;
}
static gint
gtk_container_accessible_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
static void
gtk_container_accessible_add (GtkContainer *container,
GtkWidget *child,
gpointer data)
{
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
GtkContainerAccessible *accessible;
GtkContainerAccessibleClass *klass;
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
accessible = GTK_CONTAINER_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (container)));
if (accessible == NULL)
return;
if (klass->add_gtk)
return klass->add_gtk (container, widget, data);
else
return 1;
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
if (klass->add == NULL)
return;
klass->add (accessible, child);
}
static gint
gtk_container_accessible_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
static void
gtk_container_accessible_remove (GtkContainer *container,
GtkWidget *child,
gpointer data)
{
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
GtkContainerAccessible *accessible;
GtkContainerAccessibleClass *klass;
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
accessible = GTK_CONTAINER_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (container)));
if (accessible == NULL)
return;
if (klass->remove_gtk)
return klass->remove_gtk (container, widget, data);
else
return 1;
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
if (klass->remove == NULL)
return;
klass->remove (accessible, child);
}
static gint
gtk_container_accessible_real_add_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
static void
gtk_container_accessible_real_add (GtkContainerAccessible *accessible,
GtkWidget *widget)
{
AtkObject *atk_parent;
GtkContainer *container;
AtkObject *atk_child;
GtkContainerAccessible *accessible;
gint index;
atk_parent = ATK_OBJECT (data);
atk_child = gtk_widget_get_accessible (widget);
accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
container = GTK_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
g_list_free (accessible->priv->children);
accessible->priv->children = gtk_container_get_children (container);
index = g_list_index (accessible->priv->children, widget);
g_signal_emit_by_name (atk_parent, "children-changed::add", index, atk_child, NULL);
return 1;
g_signal_emit_by_name (accessible, "children-changed::add", index, atk_child, NULL);
}
static gint
gtk_container_accessible_real_remove_gtk (GtkContainer *container,
GtkWidget *widget,
gpointer data)
static void
gtk_container_accessible_real_remove (GtkContainerAccessible *accessible,
GtkWidget *widget)
{
AtkObject* atk_parent;
GtkContainer *container;
AtkObject *atk_child;
GtkContainerAccessible *accessible;
gint index;
atk_parent = ATK_OBJECT (data);
container = GTK_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
atk_child = gtk_widget_get_accessible (widget);
if (atk_child == NULL)
return 1;
accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
return;
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
index = g_list_index (accessible->priv->children, widget);
g_list_free (accessible->priv->children);
accessible->priv->children = gtk_container_get_children (container);
if (index >= 0 && index <= g_list_length (accessible->priv->children))
g_signal_emit_by_name (atk_parent, "children-changed::remove", index, atk_child, NULL);
return 1;
g_signal_emit_by_name (accessible, "children-changed::remove", index, atk_child, NULL);
}
static void
@@ -163,8 +160,8 @@ 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);
g_signal_connect (data, "add", G_CALLBACK (gtk_container_accessible_add), obj);
g_signal_connect (data, "remove", G_CALLBACK (gtk_container_accessible_remove), obj);
obj->role = ATK_ROLE_PANEL;
}
@@ -191,8 +188,8 @@ gtk_container_accessible_class_init (GtkContainerAccessibleClass *klass)
class->ref_child = gtk_container_accessible_ref_child;
class->initialize = gtk_container_accessible_real_initialize;
klass->add_gtk = gtk_container_accessible_real_add_gtk;
klass->remove_gtk = gtk_container_accessible_real_remove_gtk;
klass->add = gtk_container_accessible_real_add;
klass->remove = gtk_container_accessible_real_remove;
g_type_class_add_private (klass, sizeof (GtkContainerAccessiblePrivate));
}

View File

@@ -49,12 +49,10 @@ struct _GtkContainerAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
gint (*add_gtk) (GtkContainer *container,
GtkWidget *widget,
gpointer data);
gint (*remove_gtk) (GtkContainer *container,
GtkWidget *widget,
gpointer data);
void (*add) (GtkContainerAccessible *container,
GtkWidget *child);
void (*remove) (GtkContainerAccessible *container,
GtkWidget *child);
};
GType gtk_container_accessible_get_type (void);

View File

@@ -834,8 +834,7 @@ menu_item_add_gtk (GtkContainer *container,
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
if (GTK_IS_MENU_ITEM (parent_widget))
{
GTK_CONTAINER_ACCESSIBLE_CLASS (gtk_menu_item_accessible_parent_class)->add_gtk (container, widget, gtk_widget_get_accessible (parent_widget));
GTK_CONTAINER_ACCESSIBLE_CLASS (gtk_menu_item_accessible_parent_class)->add (GTK_CONTAINER_ACCESSIBLE (gtk_widget_get_accessible (parent_widget)), widget);
}
return 1;
}
@@ -851,7 +850,7 @@ menu_item_remove_gtk (GtkContainer *container,
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
if (GTK_IS_MENU_ITEM (parent_widget))
{
GTK_CONTAINER_ACCESSIBLE_CLASS (gtk_menu_item_accessible_parent_class)->remove_gtk (container, widget, gtk_widget_get_accessible (parent_widget));
GTK_CONTAINER_ACCESSIBLE_CLASS (gtk_menu_item_accessible_parent_class)->remove (GTK_CONTAINER_ACCESSIBLE (gtk_widget_get_accessible (parent_widget)), widget);
}
return 1;
}

View File

@@ -333,8 +333,8 @@ gtk_notebook_accessible_class_init (GtkNotebookAccessibleClass *klass)
widget_class->notify_gtk = gtk_notebook_accessible_notify_gtk;
/* we listen to page-added/-removed, so we don't care about these */
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
container_class->add = NULL;
container_class->remove = NULL;
g_type_class_add_private (klass, sizeof (GtkNotebookAccessiblePrivate));
}

View File

@@ -121,8 +121,8 @@ gtk_statusbar_accessible_class_init (GtkStatusbarAccessibleClass *klass)
* As we report the statusbar as having no children
* we are not interested in add and remove signals
*/
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
container_class->add = NULL;
container_class->remove = NULL;
}
static void

View File

@@ -525,8 +525,8 @@ gtk_tree_view_accessible_class_init (GtkTreeViewAccessibleClass *klass)
* we do not represent these as children so we do not want to report
* children added or deleted when these changed.
*/
container_class->add_gtk = NULL;
container_class->remove_gtk = NULL;
container_class->add = NULL;
container_class->remove = NULL;
gobject_class->finalize = gtk_tree_view_accessible_finalize;