[gtk+] GtkToplevelAccessible: add a private struct



commit dad727d41c9f6677a26a683b52055d0e453f1cd6
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 15 05:52:04 2012 -0400

    GtkToplevelAccessible: add a private struct
    
    Move instance fields to a private struct, in preparation
    for installing a11y headers.
    This also required removing access to GtkToplevelAccessible innards
    from the GtkWindowAccessible implementation.

 gtk/a11y/gtktoplevelaccessible.c |   38 +++++++++++++++++++++++++++-----------
 gtk/a11y/gtktoplevelaccessible.h |   11 +++++++----
 gtk/a11y/gtkwindowaccessible.c   |    2 +-
 3 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/gtk/a11y/gtktoplevelaccessible.c b/gtk/a11y/gtktoplevelaccessible.c
index b8692a9..dd14980 100644
--- a/gtk/a11y/gtktoplevelaccessible.c
+++ b/gtk/a11y/gtktoplevelaccessible.c
@@ -30,6 +30,10 @@
 
 #include "gtktoplevelaccessible.h"
 
+struct _GtkToplevelAccessiblePrivate
+{
+  GList *window_list;
+};
 
 G_DEFINE_TYPE (GtkToplevelAccessible, _gtk_toplevel_accessible, ATK_TYPE_OBJECT)
 
@@ -49,8 +53,8 @@ gtk_toplevel_accessible_object_finalize (GObject *obj)
 {
   GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
 
-  if (toplevel->window_list)
-    g_list_free (toplevel->window_list);
+  if (toplevel->priv->window_list)
+    g_list_free (toplevel->priv->window_list);
 
   G_OBJECT_CLASS (_gtk_toplevel_accessible_parent_class)->finalize (obj);
 }
@@ -60,7 +64,7 @@ gtk_toplevel_accessible_get_n_children (AtkObject *obj)
 {
   GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
 
-  return g_list_length (toplevel->window_list);
+  return g_list_length (toplevel->priv->window_list);
 }
 
 static AtkObject *
@@ -72,7 +76,7 @@ gtk_toplevel_accessible_ref_child (AtkObject *obj,
   AtkObject *atk_obj;
 
   toplevel = GTK_TOPLEVEL_ACCESSIBLE (obj);
-  widget = g_list_nth_data (toplevel->window_list, i);
+  widget = g_list_nth_data (toplevel->priv->window_list, i);
   if (!widget)
     return NULL;
 
@@ -141,6 +145,8 @@ _gtk_toplevel_accessible_class_init (GtkToplevelAccessibleClass *klass)
   class->get_parent = NULL;
 
   g_object_class->finalize = gtk_toplevel_accessible_object_finalize;
+
+  g_type_class_add_private (klass, sizeof (GtkToplevelAccessiblePrivate));
 }
 
 static void
@@ -152,18 +158,18 @@ remove_child (GtkToplevelAccessible *toplevel,
   guint window_count = 0;
   AtkObject *child;
 
-  if (toplevel->window_list)
+  if (toplevel->priv->window_list)
     {
       GtkWindow *tmp_window;
 
-      for (l = toplevel->window_list; l; l = l->next)
+      for (l = toplevel->priv->window_list; l; l = l->next)
         {
           tmp_window = GTK_WINDOW (l->data);
 
           if (window == tmp_window)
             {
               /* Remove the window from the window_list & emit the signal */
-              toplevel->window_list = g_list_delete_link (toplevel->window_list, l);
+              toplevel->priv->window_list = g_list_delete_link (toplevel->priv->window_list, l);
               child = gtk_widget_get_accessible (GTK_WIDGET (window));
               g_signal_emit_by_name (atk_obj, "children-changed::remove",
                                      window_count, child, NULL);
@@ -209,8 +215,8 @@ show_event_watcher (GSignalInvocationHint *ihint,
     return TRUE;
 
   /* Add the window to the list & emit the signal */
-  toplevel->window_list = g_list_append (toplevel->window_list, widget);
-  n_children = g_list_length (toplevel->window_list);
+  toplevel->priv->window_list = g_list_append (toplevel->priv->window_list, widget);
+  n_children = g_list_length (toplevel->priv->window_list);
 
   atk_object_set_parent (child, atk_obj);
   g_signal_emit_by_name (atk_obj, "children-changed::add",
@@ -248,7 +254,11 @@ _gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel)
   GList *l;
   guint signal_id;
 
-  l = toplevel->window_list = gtk_window_list_toplevels ();
+  toplevel->priv = G_TYPE_INSTANCE_GET_PRIVATE (toplevel,
+                                                GTK_TYPE_TOPLEVEL_ACCESSIBLE,
+                                                GtkToplevelAccessiblePrivate);
+
+  l = toplevel->priv->window_list = gtk_window_list_toplevels ();
 
   while (l)
     {
@@ -264,7 +274,7 @@ _gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel)
         {
           GList *temp_l  = l->next;
 
-          toplevel->window_list = g_list_delete_link (toplevel->window_list, l);
+          toplevel->priv->window_list = g_list_delete_link (toplevel->priv->window_list, l);
           l = temp_l;
         }
       else
@@ -285,3 +295,9 @@ _gtk_toplevel_accessible_init (GtkToplevelAccessible *toplevel)
   g_signal_add_emission_hook (signal_id, 0,
                               hide_event_watcher, toplevel, (GDestroyNotify) NULL);
 }
+
+GList *
+_gtk_toplevel_accessible_get_children (GtkToplevelAccessible *accessible)
+{
+  return accessible->priv->window_list;
+}
diff --git a/gtk/a11y/gtktoplevelaccessible.h b/gtk/a11y/gtktoplevelaccessible.h
index a56cf82..3d4df84 100644
--- a/gtk/a11y/gtktoplevelaccessible.h
+++ b/gtk/a11y/gtktoplevelaccessible.h
@@ -29,13 +29,15 @@ G_BEGIN_DECLS
 #define GTK_IS_TOPLEVEL_ACCESSIBLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOPLEVEL_ACCESSIBLE))
 #define GTK_TOPLEVEL_ACCESSIBLE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOPLEVEL_ACCESSIBLE, GtkToplevelAccessibleClass))
 
-typedef struct _GtkToplevelAccessible      GtkToplevelAccessible;
-typedef struct _GtkToplevelAccessibleClass GtkToplevelAccessibleClass;
+typedef struct _GtkToplevelAccessible        GtkToplevelAccessible;
+typedef struct _GtkToplevelAccessibleClass   GtkToplevelAccessibleClass;
+typedef struct _GtkToplevelAccessiblePrivate GtkToplevelAccessiblePrivate;
 
 struct _GtkToplevelAccessible
 {
   AtkObject parent;
-  GList *window_list;
+
+  GtkToplevelAccessiblePrivate *priv;
 };
 
 struct _GtkToplevelAccessibleClass
@@ -43,7 +45,8 @@ struct _GtkToplevelAccessibleClass
   AtkObjectClass parent_class;
 };
 
-GType _gtk_toplevel_accessible_get_type (void);
+GType  _gtk_toplevel_accessible_get_type     (void);
+GList *_gtk_toplevel_accessible_get_children (GtkToplevelAccessible *accessible);
 
 G_END_DECLS
 
diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index db857b9..475d142 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -190,7 +190,7 @@ gtk_window_accessible_get_index_in_parent (AtkObject *accessible)
       if (GTK_IS_TOPLEVEL_ACCESSIBLE (atk_obj))
         {
           GtkToplevelAccessible *toplevel = GTK_TOPLEVEL_ACCESSIBLE (atk_obj);
-          index = g_list_index (toplevel->window_list, window);
+          index = g_list_index (_gtk_toplevel_accessible_get_children (toplevel), window);
         }
       else
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]