[gtk/headerbar-buttons-a11y] a11y: Include window management buttons in headerbar
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/headerbar-buttons-a11y] a11y: Include window management buttons in headerbar
- Date: Thu, 15 Aug 2019 11:23:20 +0000 (UTC)
commit bc1c0584b76e19d5d65bfa2ae809f95113e53c83
Author: Benjamin Otte <otte redhat com>
Date: Sun Jul 21 23:15:00 2019 +0200
a11y: Include window management buttons in headerbar
gtk/a11y/Makefile.inc | 2 +
gtk/a11y/gtkheaderbaraccessible.c | 87 +++++++++++++++++++++++++++++++++++++++
gtk/a11y/gtkheaderbaraccessible.h | 55 +++++++++++++++++++++++++
gtk/a11y/meson.build | 2 +
gtk/gtkcontainerprivate.h | 1 +
gtk/gtkheaderbar.c | 3 +-
6 files changed, 149 insertions(+), 1 deletion(-)
---
diff --git a/gtk/a11y/Makefile.inc b/gtk/a11y/Makefile.inc
index 8529c7ae57..3ed6c5decd 100644
--- a/gtk/a11y/Makefile.inc
+++ b/gtk/a11y/Makefile.inc
@@ -14,6 +14,7 @@ a11y_h_sources = \
a11y/gtkflowboxaccessible.h \
a11y/gtkflowboxchildaccessible.h \
a11y/gtkframeaccessible.h \
+ a11y/gtkheaderbaraccessible.h \
a11y/gtkiconviewaccessible.h \
a11y/gtkimageaccessible.h \
a11y/gtkimagecellaccessible.h \
@@ -88,6 +89,7 @@ a11y_c_sources = \
a11y/gtkflowboxaccessible.c \
a11y/gtkflowboxchildaccessible.c \
a11y/gtkframeaccessible.c \
+ a11y/gtkheaderbaraccessible.c \
a11y/gtkiconviewaccessible.c \
a11y/gtkimageaccessible.c \
a11y/gtkimagecellaccessible.c \
diff --git a/gtk/a11y/gtkheaderbaraccessible.c b/gtk/a11y/gtkheaderbaraccessible.c
new file mode 100644
index 0000000000..3610ac0d1f
--- /dev/null
+++ b/gtk/a11y/gtkheaderbaraccessible.c
@@ -0,0 +1,87 @@
+/* GTK+ - accessibility implementations
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkheaderbaraccessible.h"
+
+#include "gtkcontainerprivate.h"
+
+G_DEFINE_TYPE (GtkHeaderBarAccessible, gtk_header_bar_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
+
+static void
+count_widget (GtkWidget *widget,
+ gint *count)
+{
+ (*count)++;
+}
+
+static gint
+gtk_header_bar_accessible_get_n_children (AtkObject* obj)
+{
+ GtkWidget *widget;
+ gint count = 0;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ if (widget == NULL)
+ return 0;
+
+ gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) count_widget, &count);
+ return count;
+}
+
+static AtkObject *
+gtk_header_bar_accessible_ref_child (AtkObject *obj,
+ gint i)
+{
+ GList *children, *tmp_list;
+ AtkObject *accessible;
+ GtkWidget *widget;
+
+ widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+ if (widget == NULL)
+ return NULL;
+
+ children = gtk_container_get_all_children (GTK_CONTAINER (widget));
+ 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));
+
+ g_list_free (children);
+ g_object_ref (accessible);
+
+ return accessible;
+}
+
+static void
+gtk_header_bar_accessible_class_init (GtkHeaderBarAccessibleClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+ class->get_n_children = gtk_header_bar_accessible_get_n_children;
+ class->ref_child = gtk_header_bar_accessible_ref_child;
+}
+
+static void
+gtk_header_bar_accessible_init (GtkHeaderBarAccessible *header_bar)
+{
+}
+
diff --git a/gtk/a11y/gtkheaderbaraccessible.h b/gtk/a11y/gtkheaderbaraccessible.h
new file mode 100644
index 0000000000..fca9428a94
--- /dev/null
+++ b/gtk/a11y/gtkheaderbaraccessible.h
@@ -0,0 +1,55 @@
+/* GTK+ - accessibility implementations
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_HEADER_BAR_ACCESSIBLE_H__
+#define __GTK_HEADER_BAR_ACCESSIBLE_H__
+
+#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk-a11y.h> can be included directly."
+#endif
+
+#include <gtk/a11y/gtkcontaineraccessible.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_HEADER_BAR_ACCESSIBLE (gtk_header_bar_accessible_get_type ())
+#define GTK_HEADER_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessible))
+#define GTK_HEADER_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessibleClass))
+#define GTK_IS_HEADER_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GTK_TYPE_HEADER_BAR_ACCESSIBLE))
+#define GTK_IS_HEADER_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_TYPE_HEADER_BAR_ACCESSIBLE))
+#define GTK_HEADER_BAR_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessibleClass))
+
+typedef struct _GtkHeaderBarAccessible GtkHeaderBarAccessible;
+typedef struct _GtkHeaderBarAccessibleClass GtkHeaderBarAccessibleClass;
+typedef struct _GtkHeaderBarAccessiblePrivate GtkHeaderBarAccessiblePrivate;
+
+struct _GtkHeaderBarAccessible
+{
+ GtkContainerAccessible parent;
+};
+
+struct _GtkHeaderBarAccessibleClass
+{
+ GtkContainerAccessibleClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gtk_header_bar_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_HEADER_BAR_ACCESSIBLE_H__ */
diff --git a/gtk/a11y/meson.build b/gtk/a11y/meson.build
index d0359158d0..566b3a7412 100644
--- a/gtk/a11y/meson.build
+++ b/gtk/a11y/meson.build
@@ -17,6 +17,7 @@ a11y_sources = files(
'gtkflowboxaccessible.c',
'gtkflowboxchildaccessible.c',
'gtkframeaccessible.c',
+ 'gtkheaderbaraccessible.c',
'gtkiconviewaccessible.c',
'gtkimageaccessible.c',
'gtkimagecellaccessible.c',
@@ -72,6 +73,7 @@ a11y_headers = files(
'gtkflowboxaccessible.h',
'gtkflowboxchildaccessible.h',
'gtkframeaccessible.h',
+ 'gtkheaderbaraccessible.h',
'gtkiconviewaccessible.h',
'gtkimageaccessible.h',
'gtkimagecellaccessible.h',
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 7402a6676b..547e0295c3 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -42,6 +42,7 @@ void _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
gboolean _gtk_container_get_border_width_set (GtkContainer *container);
void _gtk_container_set_border_width_set (GtkContainer *container,
gboolean border_width_set);
+GList * gtk_container_get_all_children (GtkContainer *container);
void gtk_container_get_children_clip (GtkContainer *container,
GtkAllocation *out_clip);
void gtk_container_set_default_resize_mode (GtkContainer *container,
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index dd7d2093c9..0ef94e3c84 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -30,7 +30,7 @@
#include "gtkwindowprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcontainerprivate.h"
-#include "a11y/gtkcontaineraccessible.h"
+#include "a11y/gtkheaderbaraccessible.h"
#include <string.h>
@@ -2118,6 +2118,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
g_object_class_install_properties (object_class, LAST_PROP, header_bar_props);
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_HEADER_BAR_ACCESSIBLE);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
gtk_widget_class_set_css_name (widget_class, "headerbar");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]