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:
committed by
Benjamin Otte
parent
6c68b25008
commit
a1bb39a42b
@@ -234,8 +234,8 @@ gtk_button_accessible_class_init (GtkButtonAccessibleClass *klass)
|
|||||||
|
|
||||||
widget_class->notify_gtk = gtk_button_accessible_notify_gtk;
|
widget_class->notify_gtk = gtk_button_accessible_notify_gtk;
|
||||||
|
|
||||||
container_class->add_gtk = NULL;
|
container_class->add = NULL;
|
||||||
container_class->remove_gtk = NULL;
|
container_class->remove = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gtkcontaineraccessible.h"
|
#include "gtkcontaineraccessible.h"
|
||||||
|
#include "gtkwidgetprivate.h"
|
||||||
|
|
||||||
struct _GtkContainerAccessiblePrivate
|
struct _GtkContainerAccessiblePrivate
|
||||||
{
|
{
|
||||||
@@ -72,85 +73,81 @@ gtk_container_accessible_ref_child (AtkObject *obj,
|
|||||||
return accessible;
|
return accessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static void
|
||||||
gtk_container_accessible_add_gtk (GtkContainer *container,
|
gtk_container_accessible_add (GtkContainer *container,
|
||||||
GtkWidget *widget,
|
GtkWidget *child,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
|
GtkContainerAccessible *accessible;
|
||||||
GtkContainerAccessibleClass *klass;
|
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)
|
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
|
||||||
return klass->add_gtk (container, widget, data);
|
if (klass->add == NULL)
|
||||||
else
|
return;
|
||||||
return 1;
|
|
||||||
|
klass->add (accessible, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static void
|
||||||
gtk_container_accessible_remove_gtk (GtkContainer *container,
|
gtk_container_accessible_remove (GtkContainer *container,
|
||||||
GtkWidget *widget,
|
GtkWidget *child,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (data);
|
GtkContainerAccessible *accessible;
|
||||||
GtkContainerAccessibleClass *klass;
|
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)
|
klass = GTK_CONTAINER_ACCESSIBLE_GET_CLASS (accessible);
|
||||||
return klass->remove_gtk (container, widget, data);
|
if (klass->remove == NULL)
|
||||||
else
|
return;
|
||||||
return 1;
|
|
||||||
|
klass->remove (accessible, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static void
|
||||||
gtk_container_accessible_real_add_gtk (GtkContainer *container,
|
gtk_container_accessible_real_add (GtkContainerAccessible *accessible,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget)
|
||||||
gpointer data)
|
|
||||||
{
|
{
|
||||||
AtkObject *atk_parent;
|
GtkContainer *container;
|
||||||
AtkObject *atk_child;
|
AtkObject *atk_child;
|
||||||
GtkContainerAccessible *accessible;
|
|
||||||
gint index;
|
gint index;
|
||||||
|
|
||||||
atk_parent = ATK_OBJECT (data);
|
|
||||||
atk_child = gtk_widget_get_accessible (widget);
|
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_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||||
g_list_free (accessible->priv->children);
|
g_list_free (accessible->priv->children);
|
||||||
accessible->priv->children = gtk_container_get_children (container);
|
accessible->priv->children = gtk_container_get_children (container);
|
||||||
index = g_list_index (accessible->priv->children, widget);
|
index = g_list_index (accessible->priv->children, widget);
|
||||||
g_signal_emit_by_name (atk_parent, "children-changed::add", index, atk_child, NULL);
|
g_signal_emit_by_name (accessible, "children-changed::add", index, atk_child, NULL);
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static void
|
||||||
gtk_container_accessible_real_remove_gtk (GtkContainer *container,
|
gtk_container_accessible_real_remove (GtkContainerAccessible *accessible,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget)
|
||||||
gpointer data)
|
|
||||||
{
|
{
|
||||||
AtkObject* atk_parent;
|
GtkContainer *container;
|
||||||
AtkObject *atk_child;
|
AtkObject *atk_child;
|
||||||
GtkContainerAccessible *accessible;
|
|
||||||
gint index;
|
gint index;
|
||||||
|
|
||||||
atk_parent = ATK_OBJECT (data);
|
container = GTK_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)));
|
||||||
atk_child = gtk_widget_get_accessible (widget);
|
atk_child = gtk_widget_get_accessible (widget);
|
||||||
if (atk_child == NULL)
|
if (atk_child == NULL)
|
||||||
return 1;
|
return;
|
||||||
accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||||
index = g_list_index (accessible->priv->children, widget);
|
index = g_list_index (accessible->priv->children, widget);
|
||||||
g_list_free (accessible->priv->children);
|
g_list_free (accessible->priv->children);
|
||||||
accessible->priv->children = gtk_container_get_children (container);
|
accessible->priv->children = gtk_container_get_children (container);
|
||||||
if (index >= 0 && index <= g_list_length (accessible->priv->children))
|
if (index >= 0 && index <= g_list_length (accessible->priv->children))
|
||||||
g_signal_emit_by_name (atk_parent, "children-changed::remove", index, atk_child, NULL);
|
g_signal_emit_by_name (accessible, "children-changed::remove", index, atk_child, NULL);
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -163,8 +160,8 @@ 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, "add", G_CALLBACK (gtk_container_accessible_add), obj);
|
||||||
g_signal_connect (data, "remove", G_CALLBACK (gtk_container_accessible_remove_gtk), obj);
|
g_signal_connect (data, "remove", G_CALLBACK (gtk_container_accessible_remove), obj);
|
||||||
|
|
||||||
obj->role = ATK_ROLE_PANEL;
|
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->ref_child = gtk_container_accessible_ref_child;
|
||||||
class->initialize = gtk_container_accessible_real_initialize;
|
class->initialize = gtk_container_accessible_real_initialize;
|
||||||
|
|
||||||
klass->add_gtk = gtk_container_accessible_real_add_gtk;
|
klass->add = gtk_container_accessible_real_add;
|
||||||
klass->remove_gtk = gtk_container_accessible_real_remove_gtk;
|
klass->remove = gtk_container_accessible_real_remove;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GtkContainerAccessiblePrivate));
|
g_type_class_add_private (klass, sizeof (GtkContainerAccessiblePrivate));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,10 @@ struct _GtkContainerAccessibleClass
|
|||||||
{
|
{
|
||||||
GtkWidgetAccessibleClass parent_class;
|
GtkWidgetAccessibleClass parent_class;
|
||||||
|
|
||||||
gint (*add_gtk) (GtkContainer *container,
|
void (*add) (GtkContainerAccessible *container,
|
||||||
GtkWidget *widget,
|
GtkWidget *child);
|
||||||
gpointer data);
|
void (*remove) (GtkContainerAccessible *container,
|
||||||
gint (*remove_gtk) (GtkContainer *container,
|
GtkWidget *child);
|
||||||
GtkWidget *widget,
|
|
||||||
gpointer data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gtk_container_accessible_get_type (void);
|
GType gtk_container_accessible_get_type (void);
|
||||||
|
|||||||
@@ -834,8 +834,7 @@ menu_item_add_gtk (GtkContainer *container,
|
|||||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
||||||
if (GTK_IS_MENU_ITEM (parent_widget))
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -851,7 +850,7 @@ menu_item_remove_gtk (GtkContainer *container,
|
|||||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
||||||
if (GTK_IS_MENU_ITEM (parent_widget))
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,8 +333,8 @@ gtk_notebook_accessible_class_init (GtkNotebookAccessibleClass *klass)
|
|||||||
widget_class->notify_gtk = gtk_notebook_accessible_notify_gtk;
|
widget_class->notify_gtk = gtk_notebook_accessible_notify_gtk;
|
||||||
|
|
||||||
/* we listen to page-added/-removed, so we don't care about these */
|
/* we listen to page-added/-removed, so we don't care about these */
|
||||||
container_class->add_gtk = NULL;
|
container_class->add = NULL;
|
||||||
container_class->remove_gtk = NULL;
|
container_class->remove = NULL;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GtkNotebookAccessiblePrivate));
|
g_type_class_add_private (klass, sizeof (GtkNotebookAccessiblePrivate));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ gtk_statusbar_accessible_class_init (GtkStatusbarAccessibleClass *klass)
|
|||||||
* As we report the statusbar as having no children
|
* As we report the statusbar as having no children
|
||||||
* we are not interested in add and remove signals
|
* we are not interested in add and remove signals
|
||||||
*/
|
*/
|
||||||
container_class->add_gtk = NULL;
|
container_class->add = NULL;
|
||||||
container_class->remove_gtk = NULL;
|
container_class->remove = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -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
|
* we do not represent these as children so we do not want to report
|
||||||
* children added or deleted when these changed.
|
* children added or deleted when these changed.
|
||||||
*/
|
*/
|
||||||
container_class->add_gtk = NULL;
|
container_class->add = NULL;
|
||||||
container_class->remove_gtk = NULL;
|
container_class->remove = NULL;
|
||||||
|
|
||||||
gobject_class->finalize = gtk_tree_view_accessible_finalize;
|
gobject_class->finalize = gtk_tree_view_accessible_finalize;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user