mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 06:51:10 +00:00
GtkContainerAccessible: add a private struct
Move instance fields to a private struct, in preparation for installing a11y headers. This also required removing access to GtkContainerAccessible innards from the GtkMenuItemAccessible implementation.
This commit is contained in:
parent
95f3fadcbd
commit
978f336aa4
@ -20,6 +20,10 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtkcontaineraccessible.h"
|
||||
|
||||
struct _GtkContainerAccessiblePrivate
|
||||
{
|
||||
GList *children;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkContainerAccessible, _gtk_container_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
|
||||
|
||||
@ -34,7 +38,7 @@ gtk_container_accessible_get_n_children (AtkObject* obj)
|
||||
if (widget == NULL)
|
||||
return 0;
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER(widget));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (widget));
|
||||
count = g_list_length (children);
|
||||
g_list_free (children);
|
||||
|
||||
@ -115,9 +119,9 @@ gtk_container_accessible_real_add_gtk (GtkContainer *container,
|
||||
accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
|
||||
|
||||
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||
g_list_free (accessible->children);
|
||||
accessible->children = gtk_container_get_children (container);
|
||||
index = g_list_index (accessible->children, widget);
|
||||
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;
|
||||
@ -140,10 +144,10 @@ gtk_container_accessible_real_remove_gtk (GtkContainer *container,
|
||||
accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
|
||||
|
||||
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||
index = g_list_index (accessible->children, widget);
|
||||
g_list_free (accessible->children);
|
||||
accessible->children = gtk_container_get_children (container);
|
||||
if (index >= 0 && index <= g_list_length (accessible->children))
|
||||
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;
|
||||
@ -157,7 +161,7 @@ gtk_container_accessible_real_initialize (AtkObject *obj,
|
||||
|
||||
ATK_OBJECT_CLASS (_gtk_container_accessible_parent_class)->initialize (obj, data);
|
||||
|
||||
accessible->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, "remove", G_CALLBACK (gtk_container_accessible_remove_gtk), obj);
|
||||
@ -170,7 +174,7 @@ gtk_container_accessible_finalize (GObject *object)
|
||||
{
|
||||
GtkContainerAccessible *accessible = GTK_CONTAINER_ACCESSIBLE (object);
|
||||
|
||||
g_list_free (accessible->children);
|
||||
g_list_free (accessible->priv->children);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_container_accessible_parent_class)->finalize (object);
|
||||
}
|
||||
@ -189,10 +193,14 @@ _gtk_container_accessible_class_init (GtkContainerAccessibleClass *klass)
|
||||
|
||||
klass->add_gtk = gtk_container_accessible_real_add_gtk;
|
||||
klass->remove_gtk = gtk_container_accessible_real_remove_gtk;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GtkContainerAccessiblePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_container_accessible_init (GtkContainerAccessible *container)
|
||||
{
|
||||
container->priv = G_TYPE_INSTANCE_GET_PRIVATE (container,
|
||||
GTK_TYPE_CONTAINER_ACCESSIBLE,
|
||||
GtkContainerAccessiblePrivate);
|
||||
}
|
||||
|
||||
|
@ -30,14 +30,15 @@ G_BEGIN_DECLS
|
||||
#define GTK_IS_CONTAINER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER_ACCESSIBLE))
|
||||
#define GTK_CONTAINER_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER_ACCESSIBLE, GtkContainerAccessibleClass))
|
||||
|
||||
typedef struct _GtkContainerAccessible GtkContainerAccessible;
|
||||
typedef struct _GtkContainerAccessibleClass GtkContainerAccessibleClass;
|
||||
typedef struct _GtkContainerAccessible GtkContainerAccessible;
|
||||
typedef struct _GtkContainerAccessibleClass GtkContainerAccessibleClass;
|
||||
typedef struct _GtkContainerAccessiblePrivate GtkContainerAccessiblePrivate;
|
||||
|
||||
struct _GtkContainerAccessible
|
||||
{
|
||||
GtkWidgetAccessible parent;
|
||||
|
||||
GList *children;
|
||||
GtkContainerAccessiblePrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkContainerAccessibleClass
|
||||
|
@ -811,26 +811,14 @@ menu_item_add_gtk (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *parent_widget;
|
||||
AtkObject *atk_parent;
|
||||
AtkObject *atk_child;
|
||||
GtkContainerAccessible *container_accessible;
|
||||
gint index;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU (container), 1);
|
||||
|
||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
||||
if (GTK_IS_MENU_ITEM (parent_widget))
|
||||
{
|
||||
atk_parent = gtk_widget_get_accessible (parent_widget);
|
||||
atk_child = gtk_widget_get_accessible (widget);
|
||||
GTK_CONTAINER_ACCESSIBLE_CLASS (_gtk_menu_item_accessible_parent_class)->add_gtk (container, widget, gtk_widget_get_accessible (parent_widget));
|
||||
|
||||
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||
container_accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
|
||||
g_list_free (container_accessible->children);
|
||||
container_accessible->children = gtk_container_get_children (container);
|
||||
index = g_list_index (container_accessible->children, widget);
|
||||
g_signal_emit_by_name (atk_parent, "children-changed::add",
|
||||
index, atk_child, NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -840,30 +828,13 @@ menu_item_remove_gtk (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *parent_widget;
|
||||
AtkObject *atk_parent;
|
||||
AtkObject *atk_child;
|
||||
GtkContainerAccessible *container_accessible;
|
||||
gint index;
|
||||
gint list_length;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_MENU (container), 1);
|
||||
|
||||
parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
|
||||
if (GTK_IS_MENU_ITEM (parent_widget))
|
||||
{
|
||||
atk_parent = gtk_widget_get_accessible (parent_widget);
|
||||
atk_child = gtk_widget_get_accessible (widget);
|
||||
|
||||
g_object_notify (G_OBJECT (atk_child), "accessible-parent");
|
||||
|
||||
container_accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
|
||||
index = g_list_index (container_accessible->children, widget);
|
||||
list_length = g_list_length (container_accessible->children);
|
||||
g_list_free (container_accessible->children);
|
||||
container_accessible->children = gtk_container_get_children (container);
|
||||
if (index >= 0 && index <= list_length)
|
||||
g_signal_emit_by_name (atk_parent, "children-changed::remove",
|
||||
index, atk_child, NULL);
|
||||
GTK_CONTAINER_ACCESSIBLE_CLASS (_gtk_menu_item_accessible_parent_class)->remove_gtk (container, widget, gtk_widget_get_accessible (parent_widget));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user