From 0f11a46faa2b03856e1f1fb79187bb468874432d Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Fri, 7 Mar 2014 00:07:00 +0100
Subject: [PATCH] a11y: Make GtkWindowAccessible know about popovers

https://bugzilla.gnome.org/show_bug.cgi?id=725864
---
 gtk/a11y/gtkwindowaccessible.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index 4930ae6..2e8851e 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -23,6 +23,7 @@
 #include "gtkwidgetaccessibleprivate.h"
 #include "gtkwindowaccessible.h"
 #include "gtktoplevelaccessible.h"
+#include "gtkwindowprivate.h"
 
 /* atkcomponent.h */
 
@@ -279,6 +280,49 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible)
 }
 
 static void
+prepend_widget (GtkWidget  *widget,
+		GList     **list)
+{
+	*list = g_list_prepend (*list, widget);
+}
+
+static gint
+gtk_window_accessible_get_n_children (AtkObject *object)
+{
+  GList *children = NULL;
+  GtkWidget *window;
+  gint count;
+
+  window = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
+  gtk_container_forall (GTK_CONTAINER (window),
+			(GtkCallback) prepend_widget, &children);
+
+  count = g_list_length (children);
+  g_list_free (children);
+
+  return count;
+}
+
+static AtkObject *
+gtk_window_accessible_ref_child (AtkObject *object,
+                                 gint       i)
+{
+  GtkWidget *window, *ref_child;
+  GList *children = NULL;
+
+  window = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
+  gtk_container_forall (GTK_CONTAINER (window),
+			(GtkCallback) prepend_widget, &children);
+  ref_child = g_list_nth_data (children, i);
+  g_list_free (children);
+
+  if (!ref_child)
+    return NULL;
+
+  return g_object_ref (gtk_widget_get_accessible (ref_child));
+}
+
+static void
 gtk_window_accessible_class_init (GtkWindowAccessibleClass *klass)
 {
   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
@@ -292,6 +336,8 @@ gtk_window_accessible_class_init (GtkWindowAccessibleClass *klass)
   class->ref_state_set = gtk_window_accessible_ref_state_set;
   class->initialize = gtk_window_accessible_initialize;
   class->focus_event = gtk_window_accessible_focus_event;
+  class->get_n_children = gtk_window_accessible_get_n_children;
+  class->ref_child = gtk_window_accessible_ref_child;
 }
 
 static void
-- 
1.9.0