From a1bb39a42b356f34b03911c7ae2e83a42e15f582 Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Sun, 13 Jan 2013 15:13:41 +0100 Subject: [PATCH] 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. --- gtk/a11y/gtkbuttonaccessible.c | 4 +- gtk/a11y/gtkcontaineraccessible.c | 91 +++++++++++++++---------------- gtk/a11y/gtkcontaineraccessible.h | 10 ++-- gtk/a11y/gtkmenuitemaccessible.c | 5 +- gtk/a11y/gtknotebookaccessible.c | 4 +- gtk/a11y/gtkstatusbaraccessible.c | 4 +- gtk/a11y/gtktreeviewaccessible.c | 4 +- 7 files changed, 58 insertions(+), 64 deletions(-) diff --git a/gtk/a11y/gtkbuttonaccessible.c b/gtk/a11y/gtkbuttonaccessible.c index f7dece930b..f4cbc28888 100644 --- a/gtk/a11y/gtkbuttonaccessible.c +++ b/gtk/a11y/gtkbuttonaccessible.c @@ -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 diff --git a/gtk/a11y/gtkcontaineraccessible.c b/gtk/a11y/gtkcontaineraccessible.c index ccf075c17b..d43f2f4874 100644 --- a/gtk/a11y/gtkcontaineraccessible.c +++ b/gtk/a11y/gtkcontaineraccessible.c @@ -19,6 +19,7 @@ #include #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)); } diff --git a/gtk/a11y/gtkcontaineraccessible.h b/gtk/a11y/gtkcontaineraccessible.h index 1761d21dc3..4139e69788 100644 --- a/gtk/a11y/gtkcontaineraccessible.h +++ b/gtk/a11y/gtkcontaineraccessible.h @@ -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); diff --git a/gtk/a11y/gtkmenuitemaccessible.c b/gtk/a11y/gtkmenuitemaccessible.c index 4e14a7158c..4f72bcfce2 100644 --- a/gtk/a11y/gtkmenuitemaccessible.c +++ b/gtk/a11y/gtkmenuitemaccessible.c @@ -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; } diff --git a/gtk/a11y/gtknotebookaccessible.c b/gtk/a11y/gtknotebookaccessible.c index 67d5acbe49..73f422e114 100644 --- a/gtk/a11y/gtknotebookaccessible.c +++ b/gtk/a11y/gtknotebookaccessible.c @@ -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)); } diff --git a/gtk/a11y/gtkstatusbaraccessible.c b/gtk/a11y/gtkstatusbaraccessible.c index 7c3c250c9b..233096a0b1 100644 --- a/gtk/a11y/gtkstatusbaraccessible.c +++ b/gtk/a11y/gtkstatusbaraccessible.c @@ -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 diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c index a25fba5d04..707325853b 100644 --- a/gtk/a11y/gtktreeviewaccessible.c +++ b/gtk/a11y/gtktreeviewaccessible.c @@ -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;