File gtkhtml-a11y-refactor.patch of Package gtkhtml

From bf664ecd0d8d76490f42f080ad64b5b3dbeeeabf Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 8 Jan 2013 03:09:58 +0100
Subject: [PATCH] Adjust to gtk+ a11y changes

https://bugzilla.gnome.org/show_bug.cgi?id=669441
---
 a11y/Makefile.am  |  2 --
 a11y/factory.c    | 64 -------------------------------------------------------
 a11y/factory.h    | 29 -------------------------
 a11y/object.c     | 55 +++++++++++++++--------------------------------
 a11y/object.h     |  5 +++--
 configure.ac      |  2 +-
 gtkhtml/gtkhtml.c |  4 ++--
 7 files changed, 23 insertions(+), 138 deletions(-)
 delete mode 100644 a11y/factory.c
 delete mode 100644 a11y/factory.h

diff --git a/a11y/Makefile.am b/a11y/Makefile.am
index 64bfdba..b9702e7 100644
--- a/a11y/Makefile.am
+++ b/a11y/Makefile.am
@@ -9,8 +9,6 @@ noinst_LTLIBRARIES = libgtkhtml-a11y.la
 libgtkhtml_a11y_la_SOURCES =				\
 	cell.h						\
 	cell.c						\
-	factory.h					\
-	factory.c					\
 	html.h						\
 	html.c						\
 	hyperlink.h					\
diff --git a/a11y/factory.c b/a11y/factory.c
deleted file mode 100644
index 4604d95..0000000
--- a/a11y/factory.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <atk/atkobjectfactory.h>
-
-#include "gtkhtml.h"
-#include "factory.h"
-#include "object.h"
-
-static GType
-gtk_html_a11y_factory_get_accessible_type (void)
-{
-	return G_TYPE_GTK_HTML_A11Y;
-}
-
-static AtkObject *
-gtk_html_a11y_factory_create_accessible (GObject *obj)
-{
-	GtkWidget *widget;
-	AtkObject *accessible;
-
-	g_return_val_if_fail (GTK_IS_WIDGET (obj), NULL);
-
-	widget = GTK_WIDGET (obj);
-
-	accessible = gtk_html_a11y_new (widget);
-
-	return accessible;
-}
-
-static void
-gtk_html_a11y_factory_class_init (AtkObjectFactoryClass *klass)
-{
-	klass->create_accessible   = gtk_html_a11y_factory_create_accessible;
-	klass->get_accessible_type = gtk_html_a11y_factory_get_accessible_type;
-}
-
-static GType
-gtk_html_a11y_factory_get_type (void)
-{
-	static GType t = 0;
-
-	if (!t) {
-		static const GTypeInfo tinfo = {
-			sizeof (AtkObjectFactoryClass),
-			NULL, NULL, (GClassInitFunc) gtk_html_a11y_factory_class_init,
-			NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL
-		};
-
-		t = g_type_register_static (ATK_TYPE_OBJECT_FACTORY, "GtkHTMLA11YNFactory", &tinfo, 0);
-	}
-	return t;
-}
-
-static gint accessibility_initialized = FALSE;
-
-void
-gtk_html_accessibility_init (void)
-{
-	if (accessibility_initialized)
-		return;
-
-	if (atk_get_root ())
-		atk_registry_set_factory_type (atk_get_default_registry (), GTK_TYPE_HTML, gtk_html_a11y_factory_get_type ());
-
-	accessibility_initialized = TRUE;
-}
diff --git a/a11y/factory.h b/a11y/factory.h
deleted file mode 100644
index a297662..0000000
--- a/a11y/factory.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*  This file is part of the GtkHTML library.
- *
- *  Copyright 2002 Ximian, Inc.
- *
- *  Author: Radek Doulik
- *
- *
- *  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; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- */
-
-#ifndef __GTK_HTML_A11Y_FACTORY_H__
-#define __GTK_HTML_A11Y_FACTORY_H__
-
-void gtk_html_accessibility_init (void);
-
-#endif
diff --git a/a11y/object.c b/a11y/object.c
index 207dc53..6ec52af 100644
--- a/a11y/object.c
+++ b/a11y/object.c
@@ -35,8 +35,10 @@
 
 static void gtk_html_a11y_class_init (GtkHTMLA11YClass *klass);
 static void gtk_html_a11y_init       (GtkHTMLA11Y *a11y);
+static void gtk_html_a11y_initialize (AtkObject *obj,
+                                      gpointer data);
 
-static GtkAccessibleClass *parent_class = NULL;
+static GtkContainerAccessibleClass *parent_class = NULL;
 
 static gint
 get_n_actions (AtkAction *action)
@@ -129,21 +131,7 @@ gtk_html_a11y_get_type (void)
 			NULL
 		};
 
-		/*
-		 * Figure out the size of the class and instance
-		 * we are deriving from
-		 */
-		AtkObjectFactory *factory;
-		GTypeQuery query;
-		GType derived_atk_type;
-
-		factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET);
-		derived_atk_type = atk_object_factory_get_accessible_type (factory);
-		g_type_query (derived_atk_type, &query);
-		tinfo.class_size = query.class_size;
-		tinfo.instance_size = query.instance_size;
-
-		type = g_type_register_static (derived_atk_type, "GtkHTMLA11Y", &tinfo, 0);
+		type = g_type_register_static (GTK_TYPE_CONTAINER_ACCESSIBLE, "GtkHTMLA11Y", &tinfo, 0);
 
 		g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info);
 	}
@@ -157,18 +145,6 @@ gtk_html_a11y_finalize (GObject *obj)
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
 
-static void
-gtk_html_a11y_initialize (AtkObject *obj,
-                          gpointer data)
-{
-	/* printf ("gtk_html_a11y_initialize\n"); */
-
-	if (ATK_OBJECT_CLASS (parent_class)->initialize)
-		ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
-
-	g_object_set_data (G_OBJECT (obj), GTK_HTML_ID, data);
-}
-
 static gint
 gtk_html_a11y_get_n_children (AtkObject *accessible)
 {
@@ -386,22 +362,27 @@ gtk_html_a11y_delete_object_cb (GtkWidget *widget,
 	}
 }
 
-AtkObject *
-gtk_html_a11y_new (GtkWidget *widget)
+static void
+gtk_html_a11y_initialize (AtkObject *obj,
+                          gpointer data)
 {
+	GtkWidget *widget;
 	GtkHTML *html;
-	GObject *object;
 	AtkObject *accessible;
 	AtkObject *focus_object = NULL;
 
-	g_return_val_if_fail (GTK_IS_HTML (widget), NULL);
+	/* printf ("gtk_html_a11y_initialize\n"); */
+
+	if (ATK_OBJECT_CLASS (parent_class)->initialize)
+		ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
+
+	g_object_set_data (G_OBJECT (obj), GTK_HTML_ID, data);
 
-	object = g_object_new (G_TYPE_GTK_HTML_A11Y, NULL);
+	obj->role = ATK_ROLE_PANEL;
 
-	accessible = ATK_OBJECT (object);
-	atk_object_initialize (accessible, widget);
+	widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+	accessible = ATK_OBJECT (obj);
 
-	accessible->role = ATK_ROLE_PANEL;
 	g_signal_connect (widget, "grab_focus",
 			G_CALLBACK (gtk_html_a11y_grab_focus_cb),
 			NULL);
@@ -426,6 +407,4 @@ gtk_html_a11y_new (GtkWidget *widget)
 		gtk_html_a11y_focus_object = focus_object;
 		atk_focus_tracker_notify (focus_object);
 	}
-
-	return accessible;
 }
diff --git a/a11y/object.h b/a11y/object.h
index 5d71712..09f4c2d 100644
--- a/a11y/object.h
+++ b/a11y/object.h
@@ -25,6 +25,7 @@
 #define __GTK_HTML_A11Y_OBJECT_H__
 
 #include <gtk/gtk.h>
+#include <gtk/gtk-a11y.h>
 
 #define G_TYPE_GTK_HTML_A11Y                     (gtk_html_a11y_get_type ())
 #define GTK_HTML_A11Y(obj)                       (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_GTK_HTML_A11Y, GtkHTMLA11Y))
@@ -42,14 +43,14 @@ typedef struct _GtkHTMLA11YClass GtkHTMLA11YClass;
 
 struct _GtkHTMLA11Y
 {
-	GtkAccessible parent;
+	GtkContainerAccessible parent;
 };
 
 GType gtk_html_a11y_get_type (void);
 
 struct _GtkHTMLA11YClass
 {
-  GtkAccessibleClass parent_class;
+  GtkContainerAccessibleClass parent_class;
 };
 
 AtkObject * gtk_html_a11y_new (GtkWidget *widget);
diff --git a/configure.ac b/configure.ac
index 54bb902..d73c692 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ AC_CONFIG_SRCDIR(README)
 PACKAGE=gtkhtml
 
 dnl Required Package Versions
-m4_define([gtk_minimum_version], [3.0.2])
+m4_define([gtk_minimum_version], [3.2.0])
 m4_define([enchant_minimum_version], [1.1.7])
 m4_define([gnome_icon_theme_minimum_version], [2.22.0])
 m4_define([cairo_minimum_version], [1.10.0])
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index 8d8f820..861200c 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -26,7 +26,7 @@
 #include <glib/gi18n-lib.h>
 #include <string.h>
 
-#include "../a11y/factory.h"
+#include "../a11y/object.h"
 
 #include "htmlcolorset.h"
 #include "htmlcluev.h"
@@ -3270,7 +3270,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 	html_class->properties        = gtk_html_class_properties_new ();
 
 	add_bindings (klass);
-	gtk_html_accessibility_init ();
+	gtk_widget_class_set_accessible_type (widget_class, G_TYPE_GTK_HTML_A11Y);
 
 	filename = g_build_filename (PREFIX, "share", GTKHTML_RELEASE_STRING, "keybindingsrc.emacs", NULL);
 	gtk_rc_parse (filename);
--- gtkhtml-4.6.6.orig/a11y/Makefile.in	2013-07-23 12:52:02.000000000 -0500
+++ gtkhtml-4.6.6/a11y/Makefile.in	2014-02-26 17:10:44.660763437 -0600
@@ -68,7 +68,7 @@
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libgtkhtml_a11y_la_LIBADD =
 am__objects_1 =
-am_libgtkhtml_a11y_la_OBJECTS = cell.lo factory.lo html.lo \
+am_libgtkhtml_a11y_la_OBJECTS = cell.lo html.lo \
 	hyperlink.lo image.lo object.lo paragraph.lo table.lo text.lo \
 	utils.lo $(am__objects_1)
 libgtkhtml_a11y_la_OBJECTS = $(am_libgtkhtml_a11y_la_OBJECTS)
@@ -308,8 +308,6 @@
 libgtkhtml_a11y_la_SOURCES = \
 	cell.h						\
 	cell.c						\
-	factory.h					\
-	factory.c					\
 	html.h						\
 	html.c						\
 	hyperlink.h					\
@@ -383,7 +381,6 @@
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cell.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/factory.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/html.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hyperlink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/image.Plo@am__quote@