]> Pileus Git - ~andy/gtk/commitdiff
GtkContainerAccessible: add a private struct
authorMatthias Clasen <mclasen@redhat.com>
Sun, 14 Oct 2012 19:11:17 +0000 (15:11 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 14 Oct 2012 19:56:46 +0000 (15:56 -0400)
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.

gtk/a11y/gtkcontaineraccessible.c
gtk/a11y/gtkcontaineraccessible.h
gtk/a11y/gtkmenuitemaccessible.c

index 423cdf43edb341ce8b96fba19b54364cc7b70db4..6f32898c6a1be9b8429d78d10dfe34eed503e902 100644 (file)
 #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);
 }
-
index c401437fbe1155dae24046994b1db69563071f7f..394c9cc72c26b519b725dc6b222da432c321035b 100644 (file)
@@ -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
index 0fb4cfa303fdb742925b00a14c3a4cfb36fa82eb..cd53e8af83d9c7f761a8e510a46f458fd0ca674e 100644 (file)
@@ -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);
-
-      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);
+      GTK_CONTAINER_ACCESSIBLE_CLASS (_gtk_menu_item_accessible_parent_class)->add_gtk (container, widget, gtk_widget_get_accessible (parent_widget));
+
     }
   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;
 }