[gtk/kill-containers: 28/99] button: Fix accessible implementation



commit 2fe25ba70906bb0d82b47caa03759650d96699b1
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 8 01:11:22 2020 -0400

    button: Fix accessible implementation
    
    Now that GtkButton is no longer a container,
    update the accessible implementation to match.

 gtk/a11y/gtkbuttonaccessible.c | 39 ++++++++++++++-------------------------
 gtk/a11y/gtkbuttonaccessible.h |  6 +++---
 2 files changed, 17 insertions(+), 28 deletions(-)
---
diff --git a/gtk/a11y/gtkbuttonaccessible.c b/gtk/a11y/gtkbuttonaccessible.c
index 6522f44c83..b8f30658e9 100644
--- a/gtk/a11y/gtkbuttonaccessible.c
+++ b/gtk/a11y/gtkbuttonaccessible.c
@@ -68,30 +68,25 @@ get_image_from_button (GtkWidget *button)
 }
 
 static GtkWidget *
-find_label_child (GtkContainer *container)
+find_label_child (GtkWidget *widget)
 {
-  GList *children, *tmp_list;
   GtkWidget *child;
 
-  children = gtk_container_get_children (container);
-
-  child = NULL;
-  for (tmp_list = children; tmp_list != NULL; tmp_list = tmp_list->next)
+  for (child = gtk_widget_get_first_child (widget);
+       child != NULL;
+       child = gtk_widget_get_next_sibling (widget))
     {
-      if (GTK_IS_LABEL (tmp_list->data))
-        {
-          child = GTK_WIDGET (tmp_list->data);
-          break;
-        }
-      else if (GTK_IS_CONTAINER (tmp_list->data))
+      if (GTK_IS_LABEL (child))
+        return child;
+      else
         {
-          child = find_label_child (GTK_CONTAINER (tmp_list->data));
-          if (child)
-            break;
+          GtkWidget *w = find_label_child (child);
+          if (w)
+            return w;
         }
     }
-  g_list_free (children);
-  return child;
+
+  return NULL;
 }
 
 static GtkWidget *
@@ -101,10 +96,8 @@ get_label_from_button (GtkWidget *button)
 
   child = gtk_button_get_child (GTK_BUTTON (button));
 
-  if (GTK_IS_CONTAINER (child))
-    child = find_label_child (GTK_CONTAINER (child));
-  else if (!GTK_IS_LABEL (child))
-    child = NULL;
+  if (!GTK_IS_LABEL (child))
+    child = find_label_child (child);
 
   return child;
 }
@@ -200,7 +193,6 @@ static void
 gtk_button_accessible_class_init (GtkButtonAccessibleClass *klass)
 {
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-  GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
 
   class->get_name = gtk_button_accessible_get_name;
@@ -210,9 +202,6 @@ gtk_button_accessible_class_init (GtkButtonAccessibleClass *klass)
   class->initialize = gtk_button_accessible_initialize;
 
   widget_class->notify_gtk = gtk_button_accessible_notify_gtk;
-
-  container_class->add_gtk = NULL;
-  container_class->remove_gtk = NULL;
 }
 
 static void
diff --git a/gtk/a11y/gtkbuttonaccessible.h b/gtk/a11y/gtkbuttonaccessible.h
index 671c6c2e7b..077344007d 100644
--- a/gtk/a11y/gtkbuttonaccessible.h
+++ b/gtk/a11y/gtkbuttonaccessible.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 _GtkButtonAccessiblePrivate GtkButtonAccessiblePrivate;
 
 struct _GtkButtonAccessible
 {
-  GtkContainerAccessible parent;
+  GtkWidgetAccessible parent;
 
   GtkButtonAccessiblePrivate *priv;
 };
 
 struct _GtkButtonAccessibleClass
 {
-  GtkContainerAccessibleClass parent_class;
+  GtkWidgetAccessibleClass parent_class;
 };
 
 GDK_AVAILABLE_IN_ALL


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