[evolution-patches] Patch for #74226



Dear rodo,

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

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	30 Mar 2005 11:16:23 -0000
@@ -1,3 +1,29 @@
+2005-03-30  Yu Mengjie  <meng-jie yu sun com>
+
+	* 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: (html_a11y_link_get_link), (html_a11y_link_get_n_links):
+	return the number of links.
+
+	* object.c: (gtk_html_a11y_get_n_children),
+	(gtk_html_a11y_ref_child), (gtk_html_a11y_get_focus_object),
+	(gtk_html_a11y_grab_focus_cb), (gtk_html_a11y_cursor_changed_cb),
+	(gtk_html_a11y_insert_object_cb), (gtk_html_a11y_delete_object_cb),
+	(gtk_html_a11y_new):
+	set atkobject parent.
+
+	* utils.c: (create_accessible), (acc_unref):get the engine, create related 
+	atkobject accroding to the editable-state of the engine.
+
+	Fixes #74226
+
 2005-03-01  Mengjie Yu  <meng-jie yu sun com>
 
 	* object.c: (gtk_html_a11y_new):we need to notify gnopernicus
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	30 Mar 2005 11:16:23 -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	30 Mar 2005 11:16:24 -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: link.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/link.c,v
retrieving revision 1.4
diff -u -p -r1.4 link.c
--- link.c	16 Sep 2003 21:05:38 -0000	1.4
+++ link.c	30 Mar 2005 11:16:24 -0000
@@ -141,13 +141,14 @@ html_a11y_link_new (HTMLObject *html_obj
 static AtkHyperlink *
 html_a11y_link_get_link (AtkHypertext *hypertext, gint link_index)
 {
-	return html_a11y_hyper_link_new (HTML_A11Y (hypertext));
+	return html_a11y_hyper_link_new (HTML_A11Y (hypertext), link_index);
 }
 
 static gint
 html_a11y_link_get_n_links (AtkHypertext *hypertext)
 {
-	return 1;
+	HTMLText *text = HTML_TEXT (HTML_A11Y_HTML (hypertext));
+	return g_slist_length (text->links);
 }
 
 static gint
Index: object.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/object.c,v
retrieving revision 1.11
diff -u -p -r1.11 object.c
--- object.c	2 Mar 2005 08:46:58 -0000	1.11
+++ object.c	30 Mar 2005 11:16:25 -0000
@@ -186,7 +186,7 @@ gtk_html_a11y_get_n_children (AtkObject 
 
 	clue = GTK_HTML_A11Y_GTKHTML (accessible)->engine->clue;
 	if (clue) {
-		AtkObject *atk_clue = html_utils_get_accessible (clue, NULL);
+		AtkObject *atk_clue = html_utils_get_accessible (clue, accessible);
 		if (atk_clue) {
 			AtkStateSet *ss_clue = atk_object_ref_state_set (atk_clue);
 			if (atk_state_set_contains_state (ss_clue, ATK_STATE_DEFUNCT)) {
@@ -223,7 +223,7 @@ gtk_html_a11y_ref_child (AtkObject *acce
 	g_object_unref (ss);
 
 	if (GTK_HTML_A11Y_GTKHTML (accessible)->engine->clue) {
-		AtkObject *atk_clue = html_utils_get_accessible (GTK_HTML_A11Y_GTKHTML (accessible)->engine->clue, NULL);
+		AtkObject *atk_clue = html_utils_get_accessible (GTK_HTML_A11Y_GTKHTML (accessible)->engine->clue, accessible);
 		if (atk_clue) {
 			AtkStateSet *ss_clue = atk_object_ref_state_set (atk_clue);
 			if (atk_state_set_contains_state (ss_clue, ATK_STATE_DEFUNCT)) {
@@ -278,7 +278,7 @@ gtk_html_a11y_init (GtkHTMLA11Y *a11y)
 }
 
 static AtkObject *
-gtk_html_a11y_get_focus_object (GtkWidget * widget)
+gtk_html_a11y_get_focus_object (GtkWidget * widget, AtkObject *accessible)
 {
 	GtkHTML * html;
 	HTMLObject * htmlobj = NULL;
@@ -295,7 +295,7 @@ gtk_html_a11y_get_focus_object (GtkWidge
 		htmlobj = html->engine->cursor->object;
 
 	if (htmlobj)
-		obj = html_utils_get_accessible (htmlobj, NULL);
+		obj = html_utils_get_accessible (htmlobj, accessible);
 
 	return obj;
 }
@@ -306,9 +306,9 @@ gtk_html_a11y_grab_focus_cb(GtkWidget * 
         AtkObject *focus_object, *obj, *clue;
 
 
-	focus_object = gtk_html_a11y_get_focus_object (widget);
-	g_return_if_fail (focus_object != NULL);
 	obj = gtk_widget_get_accessible (widget);
+	focus_object = gtk_html_a11y_get_focus_object (widget, obj);
+	g_return_if_fail (focus_object != NULL);
 	g_object_set_data (G_OBJECT(obj), "gail-focus-object", focus_object);
 
 	clue = html_utils_get_accessible(GTK_HTML(widget)->engine->clue, obj);
@@ -326,9 +326,9 @@ gtk_html_a11y_cursor_changed_cb (GtkWidg
 {
         AtkObject *focus_object, *obj;
 
-	focus_object = gtk_html_a11y_get_focus_object (widget);  
-	g_return_if_fail (focus_object != NULL);
 	obj = gtk_widget_get_accessible (widget);
+	focus_object = gtk_html_a11y_get_focus_object (widget, obj);  
+	g_return_if_fail (focus_object != NULL);
 	
 	if (gtk_html_a11y_focus_object != focus_object) {
 		gtk_html_a11y_focus_object = focus_object;
@@ -350,7 +350,7 @@ gtk_html_a11y_insert_object_cb (GtkWidge
 	AtkObject * a11y, *obj;
 
         obj = gtk_widget_get_accessible (widget);
-	a11y = gtk_html_a11y_get_focus_object (widget);
+	a11y = gtk_html_a11y_get_focus_object (widget, obj);
 	g_return_if_fail (a11y != NULL);
 
 	if (gtk_html_a11y_focus_object != a11y) {
@@ -371,7 +371,7 @@ gtk_html_a11y_delete_object_cb (GtkWidge
 	AtkObject * a11y, *obj;
 
         obj = gtk_widget_get_accessible (widget);
-	a11y = gtk_html_a11y_get_focus_object (widget);
+	a11y = gtk_html_a11y_get_focus_object (widget, obj);
 	g_return_if_fail (a11y != NULL);
 
 	if (gtk_html_a11y_focus_object != a11y) {
@@ -416,7 +416,7 @@ gtk_html_a11y_new (GtkWidget *widget)
 
 	/* printf ("created new gtkhtml accessible object\n"); */
 
-	focus_object = gtk_html_a11y_get_focus_object (widget);  
+	focus_object = gtk_html_a11y_get_focus_object (widget, accessible);  
 
 	if (focus_object && gtk_html_a11y_focus_object != focus_object) {
 		gtk_html_a11y_focus_object = focus_object;
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	30 Mar 2005 11:16:25 -0000
@@ -23,6 +23,8 @@
 
 #include "htmlembedded.h"
 #include "htmlobject.h"
+#include "htmlengine.h"
+#include "gtkhtml.h"
 
 #include "cell.h"
 #include "image.h"
@@ -36,14 +38,28 @@ static AtkObject *
 create_accessible (HTMLObject *o, AtkObject *parent)
 {
 	AtkObject *accessible = NULL;
+	HTMLEngine *engine = NULL;
 
 	switch (HTML_OBJECT_TYPE (o)) {
 	case HTML_TYPE_CLUEFLOW:
 		accessible = html_a11y_paragraph_new (o);
 		break;
 	case HTML_TYPE_TEXT:
-		accessible = html_a11y_text_new (o);
+		if (parent != NULL) {
+			if (G_IS_GTK_HTML_A11Y (parent)) {
+				engine = GTK_HTML_A11Y_GTKHTML (parent)->engine;
+			} else if (G_IS_HTML_A11Y (parent)) {
+				engine = GTK_HTML_A11Y_GTKHTML (html_a11y_get_gtkhtml_parent (HTML_A11Y (parent)))->engine;
+			}
+		}
+			
+		if (engine != NULL && html_engine_get_editable (engine)) {
+			accessible = html_a11y_text_new (o);
+		} else {
+			accessible = html_a11y_link_new (o);	
+		}
 		break;
+
 	case HTML_TYPE_LINKTEXT:
 		accessible = html_a11y_link_new (o);
 		break;
@@ -101,6 +117,7 @@ acc_unref(gpointer data)
 	ss = atk_object_ref_state_set (data);
 
 	atk_state_set_add_state (ss, ATK_STATE_DEFUNCT);
+	g_object_unref (ss);
 	atk_object_notify_state_change (data, ATK_STATE_DEFUNCT, TRUE);
 	g_object_unref(G_OBJECT(data));
 }


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