[evolution-patches] *NEW* Patch for #74226 (Updated)



Dear rodo,

Here is the new patch for #74226
the related URL is:
http://bugzilla.ximian.com/show_bug.cgi?id=74226

I have updated it according to your proposal.

Will you please help me to review it?

Thanks a lot.

Yours,
Mengjie
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/ChangeLog,v
retrieving revision 1.21
diff -u -p -r1.21 ChangeLog
--- ChangeLog	2 Mar 2005 08:46:58 -0000	1.21
+++ ChangeLog	4 Apr 2005 15:02:54 -0000
@@ -1,3 +1,31 @@
+2005-04-04  Yu Mengjie  <meng-jie yu sun com>
+
+	* Makefile.am:
+	remove link.h link.c
+
+	* hyperlink.c: (html_a11y_hyper_link_get_start_index),
+	(html_a11y_hyper_link_get_end_index),
+	(html_a11y_hyper_link_class_init), (html_a11y_hyper_link_new):
+	overload the atk_hyperlink_get_start_index and atk_hyperlink_get_end_index
+	function
+
+	* hyperlink.h:
+	add int num field indicating the number of links in a text object.
+
+	* link.c:
+	* link.h:
+	remove link.c and link.h.
+
+	* text.c: (html_a11y_text_get_type), (html_a11y_text_paste_text),
+	(atk_hyper_text_interface_init), (html_a11y_text_get_link),
+	(html_a11y_text_get_n_links), (html_a11y_text_get_link_index):
+	implement atkhypertext interface.
+
+	* utils.c: (create_accessible):
+	remove related link part
+
+	Fixes #74226
+
 2005-03-01  Mengjie Yu  <meng-jie yu sun com>
 
 	* object.c: (gtk_html_a11y_new):we need to notify gnopernicus
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/Makefile.am,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile.am
--- Makefile.am	1 Nov 2004 09:41:59 -0000	1.6
+++ Makefile.am	4 Apr 2005 15:02:54 -0000
@@ -17,8 +17,6 @@ libgtkhtml_a11y_la_SOURCES =				\
 	hyperlink.c					\
 	image.h						\
 	image.c						\
-	link.h						\
-	link.c						\
 	object.h					\
 	object.c					\
 	paragraph.h					\
Index: hyperlink.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/hyperlink.c,v
retrieving revision 1.5
diff -u -p -r1.5 hyperlink.c
--- hyperlink.c	7 Jun 2004 18:07:43 -0000	1.5
+++ hyperlink.c	4 Apr 2005 15:02:54 -0000
@@ -99,13 +99,34 @@ html_a11y_hyper_link_finalize (GObject *
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
 
+
+static gint
+html_a11y_hyper_link_get_start_index (AtkHyperlink *link)
+{
+	HTMLA11YHyperLink *hl = HTML_A11Y_HYPER_LINK (link);
+	HTMLText *text = HTML_TEXT (HTML_A11Y_HTML (hl->a11y));
+	Link *a = (Link *) g_slist_nth_data (text->links, hl->num);
+	return a ? a->start_offset : -1;
+}
+
+
+static gint
+html_a11y_hyper_link_get_end_index (AtkHyperlink *link)
+{
+	HTMLA11YHyperLink *hl = HTML_A11Y_HYPER_LINK (link);
+	Link *a = (Link *) g_slist_nth_data (HTML_TEXT (HTML_A11Y_HTML (hl->a11y))->links, hl->num);
+	return a ? a->end_offset : -1;
+}
+
 static void
 html_a11y_hyper_link_class_init (HTMLA11YHyperLinkClass *klass)
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
+	AtkHyperlinkClass *atk_hyperlink_class = ATK_HYPERLINK_CLASS (klass);
 	parent_class = g_type_class_peek_parent (klass);
 
+	atk_hyperlink_class->get_start_index = html_a11y_hyper_link_get_start_index;
+	atk_hyperlink_class->get_end_index = html_a11y_hyper_link_get_end_index; 
 	gobject_class->finalize = html_a11y_hyper_link_finalize;
 }
 
@@ -116,7 +137,7 @@ html_a11y_hyper_link_init (HTMLA11YHyper
 }
 
 AtkHyperlink * 
-html_a11y_hyper_link_new (HTMLA11Y *a11y)
+html_a11y_hyper_link_new (HTMLA11Y *a11y, gint link_index)
 {
 	HTMLA11YHyperLink *hl;
 
@@ -125,6 +146,8 @@ html_a11y_hyper_link_new (HTMLA11Y *a11y
 	hl = HTML_A11Y_HYPER_LINK (g_object_new (G_TYPE_HTML_A11Y_HYPER_LINK, NULL));
 
 	hl->a11y = a11y;
+	hl->num = link_index;
+	hl->offset = ((Link *) g_slist_nth_data (HTML_TEXT (HTML_A11Y_HTML (a11y))->links, link_index))->start_offset;
 	g_object_add_weak_pointer (G_OBJECT (hl->a11y), (gpointer *) &hl->a11y);
 
 	return ATK_HYPERLINK (hl);
Index: hyperlink.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/hyperlink.h,v
retrieving revision 1.3
diff -u -p -r1.3 hyperlink.h
--- hyperlink.h	16 Sep 2003 21:05:38 -0000	1.3
+++ hyperlink.h	4 Apr 2005 15:02:54 -0000
@@ -25,7 +25,6 @@
 #define __HTML_A11Y_HYPER_LINK_H__
 
 #include "text.h"
-
 #define G_TYPE_HTML_A11Y_HYPER_LINK            (html_a11y_hyper_link_get_type ())
 #define HTML_A11Y_HYPER_LINK(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
 									   G_TYPE_HTML_A11Y_HYPER_LINK, \
@@ -45,6 +44,7 @@ struct _HTMLA11YHyperLink {
 	AtkHyperlink atk_hyper_link;
 
 	HTMLA11Y *a11y;
+	gint num;
 	gint offset;
 	gchar *description;
 };
@@ -55,6 +55,6 @@ struct _HTMLA11YHyperLinkClass {
 	AtkHyperlinkClass parent_class;
 };
 
-AtkHyperlink * html_a11y_hyper_link_new (HTMLA11Y *a11y);
+AtkHyperlink * html_a11y_hyper_link_new (HTMLA11Y *a11y, gint link_index);
 
 #endif
Index: text.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/text.c,v
retrieving revision 1.13
diff -u -p -r1.13 text.c
--- text.c	31 Jan 2005 10:46:33 -0000	1.13
+++ text.c	4 Apr 2005 15:02:55 -0000
@@ -24,6 +24,8 @@
 #include <config.h>
 #include <atk/atkcomponent.h>
 #include <atk/atktext.h>
+#include <atk/atkhypertext.h>
+#include <atk/atkhyperlink.h>
 #include <glib/gi18n.h>
 #include <glib/gmacros.h>
 
@@ -41,6 +43,7 @@
 #include "object.h"
 #include "html.h"
 #include "text.h"
+#include "hyperlink.h"
 
 static void html_a11y_text_class_init    (HTMLA11YTextClass *klass);
 static void html_a11y_text_init          (HTMLA11YText *a11y_text);
@@ -74,6 +77,14 @@ static void html_a11y_text_get_character
 static gint html_a11y_text_get_offset_at_point (AtkText *text, gint x, gint y,
 					AtkCoordType coords);
 
+/* Hyperlink interface */
+static void atk_hyper_text_interface_init (AtkHypertextIface *iface);
+
+static AtkHyperlink * html_a11y_text_get_link (AtkHypertext *hypertext, gint link_index);
+static gint html_a11y_text_get_n_links (AtkHypertext *hypertext);
+static gint html_a11y_text_get_link_index (AtkHypertext *hypertext, gint char_index);
+
+
 /* Editable text interface. */
 static void 	atk_editable_text_interface_init      (AtkEditableTextIface *iface);
 static void	html_a11y_text_set_text_contents	(AtkEditableText      *text,
@@ -179,17 +190,24 @@ html_a11y_text_get_type (void)
 			NULL
 		};
 
+		static const GInterfaceInfo atk_hyper_text_info = {
+			(GInterfaceInitFunc) atk_hyper_text_interface_init,
+			(GInterfaceFinalizeFunc) NULL,
+			NULL
+		};
 
 		type = g_type_register_static (G_TYPE_HTML_A11Y, "HTMLA11YText", &tinfo, 0);
 		g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info);
 		g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info);
 		g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT, &atk_editable_text_info);
 		g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info);
+		g_type_add_interface_static (type, ATK_TYPE_HYPERTEXT, &atk_hyper_text_info);
 	}
 
 	return type;
 }
 
+
 static void 
 atk_component_interface_init (AtkComponentIface *iface)
 {
@@ -929,4 +947,41 @@ html_a11y_text_paste_text	(AtkEditableTe
         html_engine_show_cursor (html->engine);
 
         g_signal_emit_by_name(html, "grab_focus");
+}
+
+
+static void
+atk_hyper_text_interface_init (AtkHypertextIface *iface)
+{
+	g_return_if_fail (iface != NULL);
+
+	iface->get_link = html_a11y_text_get_link;
+	iface->get_n_links = html_a11y_text_get_n_links;
+	iface->get_link_index = html_a11y_text_get_link_index;
+}
+
+/*
+ * AtkHyperLink interface
+ */
+
+static AtkHyperlink *
+html_a11y_text_get_link (AtkHypertext *hypertext, gint link_index)
+{
+	return html_a11y_hyper_link_new (HTML_A11Y (hypertext), link_index);
+}
+
+static gint
+html_a11y_text_get_n_links (AtkHypertext *hypertext)
+{
+	HTMLText *text = HTML_TEXT (HTML_A11Y_HTML (hypertext));
+	return g_slist_length (text->links);
+}
+
+static gint
+html_a11y_text_get_link_index (AtkHypertext *hypertext, gint char_index)
+{
+	HTMLObject *obj = HTML_A11Y_HTML (hypertext);
+	Link *link = html_text_get_link_at_offset (HTML_TEXT (obj), char_index);
+
+	return link ? link->start_offset : -1;
 }
Index: utils.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/utils.c,v
retrieving revision 1.7
diff -u -p -r1.7 utils.c
--- utils.c	26 Jan 2005 07:51:49 -0000	1.7
+++ utils.c	4 Apr 2005 15:02:55 -0000
@@ -44,9 +44,6 @@ create_accessible (HTMLObject *o, AtkObj
 	case HTML_TYPE_TEXT:
 		accessible = html_a11y_text_new (o);
 		break;
-	case HTML_TYPE_LINKTEXT:
-		accessible = html_a11y_link_new (o);
-		break;
 	case HTML_TYPE_IMAGE:
 		accessible = html_a11y_image_new (o);
 		break;


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