fepitre / rpms / gtk3

Forked from rpms/gtk3 4 years ago
Clone

Blame SOURCES/0001-a11y-Include-window-management-buttons-in-headerbar.patch

9c78e9
From bc1c0584b76e19d5d65bfa2ae809f95113e53c83 Mon Sep 17 00:00:00 2001
9c78e9
From: Benjamin Otte <otte@redhat.com>
9c78e9
Date: Sun, 21 Jul 2019 23:15:00 +0200
9c78e9
Subject: [PATCH] a11y: Include window management buttons in headerbar
9c78e9
9c78e9
---
9c78e9
 gtk/a11y/Makefile.inc             |  2 +
9c78e9
 gtk/a11y/gtkheaderbaraccessible.c | 87 +++++++++++++++++++++++++++++++
9c78e9
 gtk/a11y/gtkheaderbaraccessible.h | 55 +++++++++++++++++++
9c78e9
 gtk/gtkcontainerprivate.h         |  1 +
9c78e9
 gtk/gtkheaderbar.c                |  3 +-
9c78e9
 6 files changed, 149 insertions(+), 1 deletion(-)
9c78e9
 create mode 100644 gtk/a11y/gtkheaderbaraccessible.c
9c78e9
 create mode 100644 gtk/a11y/gtkheaderbaraccessible.h
9c78e9
9c78e9
diff --git a/gtk/a11y/Makefile.inc b/gtk/a11y/Makefile.inc
9c78e9
index 8529c7ae57..3ed6c5decd 100644
9c78e9
--- a/gtk/a11y/Makefile.inc
9c78e9
+++ b/gtk/a11y/Makefile.inc
9c78e9
@@ -14,6 +14,7 @@ a11y_h_sources =				\
9c78e9
 	a11y/gtkflowboxaccessible.h		\
9c78e9
 	a11y/gtkflowboxchildaccessible.h	\
9c78e9
 	a11y/gtkframeaccessible.h		\
9c78e9
+	a11y/gtkheaderbaraccessible.h	        \
9c78e9
 	a11y/gtkiconviewaccessible.h		\
9c78e9
 	a11y/gtkimageaccessible.h		\
9c78e9
 	a11y/gtkimagecellaccessible.h		\
9c78e9
@@ -88,6 +89,7 @@ a11y_c_sources =				\
9c78e9
 	a11y/gtkflowboxaccessible.c		\
9c78e9
 	a11y/gtkflowboxchildaccessible.c	\
9c78e9
 	a11y/gtkframeaccessible.c		\
9c78e9
+	a11y/gtkheaderbaraccessible.c	        \
9c78e9
 	a11y/gtkiconviewaccessible.c		\
9c78e9
 	a11y/gtkimageaccessible.c		\
9c78e9
 	a11y/gtkimagecellaccessible.c		\
9c78e9
--- a/gtk/Makefile.in
9c78e9
+++ b/gtk/Makefile.in
9c78e9
@@ -281,6 +281,7 @@
9c78e9
 	a11y/gtkcontainercellaccessible.c a11y/gtkentryaccessible.c \
9c78e9
 	a11y/gtkexpanderaccessible.c a11y/gtkflowboxaccessible.c \
9c78e9
 	a11y/gtkflowboxchildaccessible.c a11y/gtkframeaccessible.c \
9c78e9
+	a11y/gtkheaderbaraccessible.c \
9c78e9
 	a11y/gtkiconviewaccessible.c a11y/gtkimageaccessible.c \
9c78e9
 	a11y/gtkimagecellaccessible.c a11y/gtklabelaccessible.c \
9c78e9
 	a11y/gtklevelbaraccessible.c a11y/gtklinkbuttonaccessible.c \
9c78e9
@@ -487,6 +488,7 @@
9c78e9
 	a11y/libgtk_3_la-gtkflowboxaccessible.lo \
9c78e9
 	a11y/libgtk_3_la-gtkflowboxchildaccessible.lo \
9c78e9
 	a11y/libgtk_3_la-gtkframeaccessible.lo \
9c78e9
+	a11y/libgtk_3_la-gtkheaderbaraccessible.lo \
9c78e9
 	a11y/libgtk_3_la-gtkiconviewaccessible.lo \
9c78e9
 	a11y/libgtk_3_la-gtkimageaccessible.lo \
9c78e9
 	a11y/libgtk_3_la-gtkimagecellaccessible.lo \
9c78e9
@@ -1389,6 +1391,7 @@
9c78e9
 	a11y/gtkflowboxaccessible.h		\
9c78e9
 	a11y/gtkflowboxchildaccessible.h	\
9c78e9
 	a11y/gtkframeaccessible.h		\
9c78e9
+	a11y/gtkheaderbaraccessible.h		\
9c78e9
 	a11y/gtkiconviewaccessible.h		\
9c78e9
 	a11y/gtkimageaccessible.h		\
9c78e9
 	a11y/gtkimagecellaccessible.h		\
9c78e9
@@ -1463,6 +1466,7 @@
9c78e9
 	a11y/gtkflowboxaccessible.c		\
9c78e9
 	a11y/gtkflowboxchildaccessible.c	\
9c78e9
 	a11y/gtkframeaccessible.c		\
9c78e9
+	a11y/gtkheaderbaraccessible.c		\
9c78e9
 	a11y/gtkiconviewaccessible.c		\
9c78e9
 	a11y/gtkimageaccessible.c		\
9c78e9
 	a11y/gtkimagecellaccessible.c		\
9c78e9
@@ -2702,6 +2706,8 @@
9c78e9
 	a11y/$(DEPDIR)/$(am__dirstamp)
9c78e9
 a11y/libgtk_3_la-gtkframeaccessible.lo: a11y/$(am__dirstamp) \
9c78e9
 	a11y/$(DEPDIR)/$(am__dirstamp)
9c78e9
+a11y/libgtk_3_la-gtkheaderbaraccessible.lo: a11y/$(am__dirstamp) \
9c78e9
+	a11y/$(DEPDIR)/$(am__dirstamp)
9c78e9
 a11y/libgtk_3_la-gtkiconviewaccessible.lo: a11y/$(am__dirstamp) \
9c78e9
 	a11y/$(DEPDIR)/$(am__dirstamp)
9c78e9
 a11y/libgtk_3_la-gtkimageaccessible.lo: a11y/$(am__dirstamp) \
9c78e9
@@ -3447,6 +3453,7 @@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkflowboxaccessible.Plo@am__quote@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkflowboxchildaccessible.Plo@am__quote@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkframeaccessible.Plo@am__quote@
9c78e9
+@AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkheaderbaraccessible.Plo@am__quote@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkiconviewaccessible.Plo@am__quote@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkimageaccessible.Plo@am__quote@
9c78e9
 @AMDEP_TRUE@@am__include@ @am__quote@a11y/$(DEPDIR)/libgtk_3_la-gtkimagecellaccessible.Plo@am__quote@
9c78e9
@@ -3705,6 +3712,13 @@
9c78e9
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
9c78e9
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgtk_3_la_CFLAGS) $(CFLAGS) -c -o a11y/libgtk_3_la-gtkframeaccessible.lo `test -f 'a11y/gtkframeaccessible.c' || echo '$(srcdir)/'`a11y/gtkframeaccessible.c
9c78e9
 
9c78e9
+a11y/libgtk_3_la-gtkheaderbaraccessible.lo: a11y/gtkheaderbaraccessible.c
9c78e9
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgtk_3_la_CFLAGS) $(CFLAGS) -MT a11y/libgtk_3_la-gtkheaderbaraccessible.lo -MD -MP -MF a11y/$(DEPDIR)/libgtk_3_la-gtkheaderbaraccessible.Tpo -c -o a11y/libgtk_3_la-gtkheaderbaraccessible.lo `test -f 'a11y/gtkheaderbaraccessible.c' || echo '$(srcdir)/'`a11y/gtkheaderbaraccessible.c
9c78e9
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) a11y/$(DEPDIR)/libgtk_3_la-gtkheaderbaraccessible.Tpo a11y/$(DEPDIR)/libgtk_3_la-gtkheaderbaraccessible.Plo
9c78e9
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='a11y/gtkheaderbaraccessible.c' object='a11y/libgtk_3_la-gtkheaderbaraccessible.lo' libtool=yes @AMDEPBACKSLASH@
9c78e9
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
9c78e9
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgtk_3_la_CFLAGS) $(CFLAGS) -c -o a11y/libgtk_3_la-gtkheaderbaraccessible.lo `test -f 'a11y/gtkheaderbaraccessible.c' || echo '$(srcdir)/'`a11y/gtkheaderbaraccessible.c
9c78e9
+
9c78e9
 a11y/libgtk_3_la-gtkiconviewaccessible.lo: a11y/gtkiconviewaccessible.c
9c78e9
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgtk_3_la_CFLAGS) $(CFLAGS) -MT a11y/libgtk_3_la-gtkiconviewaccessible.lo -MD -MP -MF a11y/$(DEPDIR)/libgtk_3_la-gtkiconviewaccessible.Tpo -c -o a11y/libgtk_3_la-gtkiconviewaccessible.lo `test -f 'a11y/gtkiconviewaccessible.c' || echo '$(srcdir)/'`a11y/gtkiconviewaccessible.c
9c78e9
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) a11y/$(DEPDIR)/libgtk_3_la-gtkiconviewaccessible.Tpo a11y/$(DEPDIR)/libgtk_3_la-gtkiconviewaccessible.Plo
9c78e9
diff --git a/gtk/a11y/gtkheaderbaraccessible.c b/gtk/a11y/gtkheaderbaraccessible.c
9c78e9
new file mode 100644
9c78e9
index 0000000000..3610ac0d1f
9c78e9
--- /dev/null
9c78e9
+++ b/gtk/a11y/gtkheaderbaraccessible.c
9c78e9
@@ -0,0 +1,87 @@
9c78e9
+/* GTK+ - accessibility implementations
9c78e9
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
9c78e9
+ *
9c78e9
+ * This library is free software; you can redistribute it and/or
9c78e9
+ * modify it under the terms of the GNU Lesser General Public
9c78e9
+ * License as published by the Free Software Foundation; either
9c78e9
+ * version 2 of the License, or (at your option) any later version.
9c78e9
+ *
9c78e9
+ * This library is distributed in the hope that it will be useful,
9c78e9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9c78e9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9c78e9
+ * Lesser General Public License for more details.
9c78e9
+ *
9c78e9
+ * You should have received a copy of the GNU Lesser General Public
9c78e9
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
9c78e9
+ */
9c78e9
+
9c78e9
+#include "config.h"
9c78e9
+
9c78e9
+#include "gtkheaderbaraccessible.h"
9c78e9
+
9c78e9
+#include "gtkcontainerprivate.h"
9c78e9
+
9c78e9
+G_DEFINE_TYPE (GtkHeaderBarAccessible, gtk_header_bar_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE)
9c78e9
+
9c78e9
+static void
9c78e9
+count_widget (GtkWidget *widget,
9c78e9
+              gint      *count)
9c78e9
+{
9c78e9
+  (*count)++;
9c78e9
+}
9c78e9
+
9c78e9
+static gint
9c78e9
+gtk_header_bar_accessible_get_n_children (AtkObject* obj)
9c78e9
+{
9c78e9
+  GtkWidget *widget;
9c78e9
+  gint count = 0;
9c78e9
+
9c78e9
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
9c78e9
+  if (widget == NULL)
9c78e9
+    return 0;
9c78e9
+
9c78e9
+  gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) count_widget, &count);
9c78e9
+  return count;
9c78e9
+}
9c78e9
+
9c78e9
+static AtkObject *
9c78e9
+gtk_header_bar_accessible_ref_child (AtkObject *obj,
9c78e9
+                                     gint       i)
9c78e9
+{
9c78e9
+  GList *children, *tmp_list;
9c78e9
+  AtkObject  *accessible;
9c78e9
+  GtkWidget *widget;
9c78e9
+
9c78e9
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
9c78e9
+  if (widget == NULL)
9c78e9
+    return NULL;
9c78e9
+
9c78e9
+  children = gtk_container_get_all_children (GTK_CONTAINER (widget));
9c78e9
+  tmp_list = g_list_nth (children, i);
9c78e9
+  if (!tmp_list)
9c78e9
+    {
9c78e9
+      g_list_free (children);
9c78e9
+      return NULL;
9c78e9
+    }
9c78e9
+  accessible = gtk_widget_get_accessible (GTK_WIDGET (tmp_list->data));
9c78e9
+
9c78e9
+  g_list_free (children);
9c78e9
+  g_object_ref (accessible);
9c78e9
+
9c78e9
+  return accessible;
9c78e9
+}
9c78e9
+
9c78e9
+static void
9c78e9
+gtk_header_bar_accessible_class_init (GtkHeaderBarAccessibleClass *klass)
9c78e9
+{
9c78e9
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
9c78e9
+
9c78e9
+  class->get_n_children = gtk_header_bar_accessible_get_n_children;
9c78e9
+  class->ref_child = gtk_header_bar_accessible_ref_child;
9c78e9
+}
9c78e9
+
9c78e9
+static void
9c78e9
+gtk_header_bar_accessible_init (GtkHeaderBarAccessible *header_bar)
9c78e9
+{
9c78e9
+}
9c78e9
+
9c78e9
diff --git a/gtk/a11y/gtkheaderbaraccessible.h b/gtk/a11y/gtkheaderbaraccessible.h
9c78e9
new file mode 100644
9c78e9
index 0000000000..fca9428a94
9c78e9
--- /dev/null
9c78e9
+++ b/gtk/a11y/gtkheaderbaraccessible.h
9c78e9
@@ -0,0 +1,55 @@
9c78e9
+/* GTK+ - accessibility implementations
9c78e9
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
9c78e9
+ *
9c78e9
+ * This library is free software; you can redistribute it and/or
9c78e9
+ * modify it under the terms of the GNU Library General Public
9c78e9
+ * License as published by the Free Software Foundation; either
9c78e9
+ * version 2 of the License, or (at your option) any later version.
9c78e9
+ *
9c78e9
+ * This library is distributed in the hope that it will be useful,
9c78e9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9c78e9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9c78e9
+ * Library General Public License for more details.
9c78e9
+ *
9c78e9
+ * You should have received a copy of the GNU Library General Public
9c78e9
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
9c78e9
+ */
9c78e9
+
9c78e9
+#ifndef __GTK_HEADER_BAR_ACCESSIBLE_H__
9c78e9
+#define __GTK_HEADER_BAR_ACCESSIBLE_H__
9c78e9
+
9c78e9
+#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
9c78e9
+#error "Only <gtk/gtk-a11y.h> can be included directly."
9c78e9
+#endif
9c78e9
+
9c78e9
+#include <gtk/a11y/gtkcontaineraccessible.h>
9c78e9
+
9c78e9
+G_BEGIN_DECLS
9c78e9
+
9c78e9
+#define GTK_TYPE_HEADER_BAR_ACCESSIBLE                  (gtk_header_bar_accessible_get_type ())
9c78e9
+#define GTK_HEADER_BAR_ACCESSIBLE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessible))
9c78e9
+#define GTK_HEADER_BAR_ACCESSIBLE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessibleClass))
9c78e9
+#define GTK_IS_HEADER_BAR_ACCESSIBLE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HEADER_BAR_ACCESSIBLE))
9c78e9
+#define GTK_IS_HEADER_BAR_ACCESSIBLE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HEADER_BAR_ACCESSIBLE))
9c78e9
+#define GTK_HEADER_BAR_ACCESSIBLE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HEADER_BAR_ACCESSIBLE, GtkHeaderBarAccessibleClass))
9c78e9
+
9c78e9
+typedef struct _GtkHeaderBarAccessible        GtkHeaderBarAccessible;
9c78e9
+typedef struct _GtkHeaderBarAccessibleClass   GtkHeaderBarAccessibleClass;
9c78e9
+typedef struct _GtkHeaderBarAccessiblePrivate GtkHeaderBarAccessiblePrivate;
9c78e9
+
9c78e9
+struct _GtkHeaderBarAccessible
9c78e9
+{
9c78e9
+  GtkContainerAccessible parent;
9c78e9
+};
9c78e9
+
9c78e9
+struct _GtkHeaderBarAccessibleClass
9c78e9
+{
9c78e9
+  GtkContainerAccessibleClass parent_class;
9c78e9
+};
9c78e9
+
9c78e9
+GDK_AVAILABLE_IN_ALL
9c78e9
+GType gtk_header_bar_accessible_get_type (void);
9c78e9
+
9c78e9
+G_END_DECLS
9c78e9
+
9c78e9
+#endif /* __GTK_HEADER_BAR_ACCESSIBLE_H__ */
9c78e9
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
9c78e9
index 7402a6676b..547e0295c3 100644
9c78e9
--- a/gtk/gtkcontainerprivate.h
9c78e9
+++ b/gtk/gtkcontainerprivate.h
9c78e9
@@ -42,6 +42,7 @@ void      _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
9c78e9
 gboolean  _gtk_container_get_border_width_set   (GtkContainer *container);
9c78e9
 void      _gtk_container_set_border_width_set   (GtkContainer *container,
9c78e9
                                                  gboolean      border_width_set);
9c78e9
+GList *   gtk_container_get_all_children        (GtkContainer  *container);
9c78e9
 void      gtk_container_get_children_clip       (GtkContainer  *container,
9c78e9
                                                  GtkAllocation *out_clip);
9c78e9
 void      gtk_container_set_default_resize_mode (GtkContainer *container,
9c78e9
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
9c78e9
index dd7d2093c9..0ef94e3c84 100644
9c78e9
--- a/gtk/gtkheaderbar.c
9c78e9
+++ b/gtk/gtkheaderbar.c
9c78e9
@@ -30,7 +30,7 @@
9c78e9
 #include "gtkwindowprivate.h"
9c78e9
 #include "gtkwidgetprivate.h"
9c78e9
 #include "gtkcontainerprivate.h"
9c78e9
-#include "a11y/gtkcontaineraccessible.h"
9c78e9
+#include "a11y/gtkheaderbaraccessible.h"
9c78e9
 
9c78e9
 #include <string.h>
9c78e9
 
9c78e9
@@ -2118,6 +2118,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
9c78e9
 
9c78e9
   g_object_class_install_properties (object_class, LAST_PROP, header_bar_props);
9c78e9
 
9c78e9
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_HEADER_BAR_ACCESSIBLE);
9c78e9
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
9c78e9
   gtk_widget_class_set_css_name (widget_class, "headerbar");
9c78e9
 }
9c78e9
-- 
9c78e9
2.21.0
9c78e9