button: Fix accessible implementation

Now that GtkButton is no longer a container,
update the accessible implementation to match.
This commit is contained in:
Matthias Clasen 2020-05-08 01:11:22 -04:00
parent d7b1ecdf52
commit af19c7275b
2 changed files with 17 additions and 28 deletions

View File

@ -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))
if (GTK_IS_LABEL (child))
return child;
else
{
child = GTK_WIDGET (tmp_list->data);
break;
}
else if (GTK_IS_CONTAINER (tmp_list->data))
{
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

View File

@ -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