[gtk/kill-containers: 3/51] expander: Fix accessible implementation



commit 0fb98c7a4481623bd92e32c1810b8879b080256c
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 8 01:16:07 2020 -0400

    expander: Fix accessible implementation
    
    GtkExpander is no longer a container,
    update the accessible implementation to match.

 gtk/a11y/gtkexpanderaccessible.c | 51 +++++++---------------------------------
 gtk/a11y/gtkexpanderaccessible.h |  6 ++---
 2 files changed, 11 insertions(+), 46 deletions(-)
---
diff --git a/gtk/a11y/gtkexpanderaccessible.c b/gtk/a11y/gtkexpanderaccessible.c
index d2bd0d9bce..be54d83e53 100644
--- a/gtk/a11y/gtkexpanderaccessible.c
+++ b/gtk/a11y/gtkexpanderaccessible.c
@@ -23,7 +23,7 @@
 
 static void atk_action_interface_init (AtkActionIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (GtkExpanderAccessible, gtk_expander_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
+G_DEFINE_TYPE_WITH_CODE (GtkExpanderAccessible, gtk_expander_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
 
 static const gchar *
@@ -60,68 +60,33 @@ static gint
 gtk_expander_accessible_get_n_children (AtkObject *obj)
 {
   GtkWidget *widget;
-  GList *children;
-  gint count = 0;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
   if (widget == NULL)
     return 0;
 
-  children = gtk_container_get_children (GTK_CONTAINER(widget));
-  count = g_list_length (children);
-  g_list_free (children);
+  if (gtk_expander_get_child (GTK_EXPANDER (widget)))
+    return 1;
 
-  /* See if there is a label - if there is, reduce our count by 1
-   * since we don't want the label included with the children.
-   */
-  if (gtk_expander_get_label_widget (GTK_EXPANDER (widget)))
-    count -= 1;
-
-  return count;
+  return 0;
 }
 
 static AtkObject *
 gtk_expander_accessible_ref_child (AtkObject *obj,
                                    gint       i)
 {
-  GList *children, *tmp_list;
   AtkObject *accessible;
   GtkWidget *widget;
-  GtkWidget *label;
-  gint index;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
   if (widget == NULL)
     return NULL;
 
-  children = gtk_container_get_children (GTK_CONTAINER (widget));
-
-  /* See if there is a label - if there is, we need to skip it
-   * since we don't want the label included with the children.
-   */
-  label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
-  if (label)
-    {
-      for (index = 0; index <= i; index++)
-        {
-          tmp_list = g_list_nth (children, index);
-          if (label == GTK_WIDGET (tmp_list->data))
-            {
-              i += 1;
-              break;
-            }
-        }
-    }
-
-  tmp_list = g_list_nth (children, i);
-  if (!tmp_list)
-    {
-      g_list_free (children);
-      return NULL;
-    }
-  accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
+  widget = gtk_expander_get_child (GTK_EXPANDER (widget));
+  if (widget == NULL)
+    return NULL;
 
-  g_list_free (children);
+  accessible = gtk_widget_get_accessible (widget);
   g_object_ref (accessible);
   return accessible;
 }
diff --git a/gtk/a11y/gtkexpanderaccessible.h b/gtk/a11y/gtkexpanderaccessible.h
index d39a93e83d..ecad612efe 100644
--- a/gtk/a11y/gtkexpanderaccessible.h
+++ b/gtk/a11y/gtkexpanderaccessible.h
@@ -22,7 +22,7 @@
 #error "Only <gtk/gtk-a11y.h> can be included directly."
 #endif
 
-#include <gtk/a11y/gtkcontaineraccessible.h>
+#include <gtk/a11y/gtkwidgetaccessible.h>
 
 G_BEGIN_DECLS
 
@@ -39,14 +39,14 @@ typedef struct _GtkExpanderAccessiblePrivate GtkExpanderAccessiblePrivate;
 
 struct _GtkExpanderAccessible
 {
-  GtkContainerAccessible parent;
+  GtkWidgetAccessible parent;
 
   GtkExpanderAccessiblePrivate *priv;
 };
 
 struct _GtkExpanderAccessibleClass
 {
-  GtkContainerAccessibleClass parent_class;
+  GtkWidgetAccessibleClass parent_class;
 };
 
 GDK_AVAILABLE_IN_ALL


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