Re: [evolution-patches] Re: seek review for bug 47024: implement set/get_caret_offset method of AtkText interface



Hi Radek,

Attached is newer version of the patch. Please review.
This patch trying to fix the html_a11y_get_gtkhtml_parent(). There are 2
reasons that why the function not work:

1. ClueV do not have corresponding accessible object. So the process of
finding gtkhtml parent will terminate when it reach cluev object. So I
just add in html_utils_get_accesible
+       case HTML_TYPE_CLUEV:
+               accessible = html_a11y_new (o, ATK_ROLE_INVALID);
+               break;


2. ClueV->parent will not point to the gtkhtml widget. The 'parent
pointers' only work in HTML Object tree. gtkhtml is outside of this
tree.  This can be resolved, however, because atk let us to set atk
parent of the cluev to the gtkhtml.

This patch set atk parent relationship in 2 places:

a. When new the gtkhtml a11y object,

       g_signal_connect_after(widget, "cursor_move",
                        G_CALLBACK(gtk_html_a11y_cursor_move_cb),
                        NULL);
+       html_utils_get_accessible(GTK_HTML(widget)->engine->clue,
accessible);
                                                                                
        /* printf ("created new gtkhtml accessible object\n"); */
... ...

	html_utils_get_accessible() will set the parent relationship.

b. And when gtkhtml widget grab focus,
+
+       clue = html_utils_get_accessible(GTK_HTML(widget)->engine->clue,
obj);
+       atk_object_set_parent(clue, obj);
+

Because when user read another mail, gtkhtml will reconstruct the html
object tree. So clue will change, and we need to re-setup
'clue->gtkhtml' relationship.

                                                                                

And finally, the patch assume each htmlobject tree start at cluev. Below
is dump from testgtkhtml. Although the patch work fine in my
environment, I think it need your confirmation.

Simple Object Tree
-----------
ClueV
        ClueFlow
                Table 1,2
                        TableCell 0,0
                                ClueFlow
                                        Image
                                        Text `myportal:'
                        TableCell 0,1
        ClueFlow
                Image
	... ...


Thanks
York

On Thu, 2003-07-31 at 00:31, Radek Doulík wrote: 
> Hi York,
> 
> On Tue, 2003-07-29 at 04:00, Yuedong Du wrote:
> > Hi Radek,
> > 
> > Seems you do not notice this mail.
> > Change the subject to the 'nomarlize form'.  And resend.
> > 
> > Regards
> > York
> > 
> > Hi Radek,
> > 
> > The patch mainly implemented get/set_caret_offset method. After this
> > patch
> > gnopernicus can report current character when you move cursor, and can
> > set
> > caret to some text using at-poke. 
> > 
> > Some explain of the patch below,
> > 
> > I introduced a method to get/set current gtkhtml widget in html_utils,
> > as below:
> > 
> > 
> >         +static GtkHTML * gtkhtml = NULL;
> >         +                                                                                 
> >         +void
> >         +html_utils_set_gtk_html(GtkHTML * p)
> >         +{
> >         +        gtkhtml = p;
> >         +}
> >         +                                                                                 
> >         +GtkHTML *
> >         +html_utils_get_gtk_html(void)
> >         +{
> >         +        return gtkhtml;
> >          }
> >         
> >         
> > I notice original code seems try to using the
> > html_a11y_get_gtkhtml_parent() to reach the same goal.
> > But the function do not work. We cannot get the gtkhtml widget from a
> > html object.
> 
> do you now why does this function not work? remembering widget in static
> variable will not work for multiple gtkhtml instances in one process. I
> will prefer to fix html_a11y_get_gtkhtml_parent rather.
> 
> Cheers
> Radek
> 
> 
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
? text.c.edit
? text.c.sv
Index: html.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/html.c,v
retrieving revision 1.2
diff -u -r1.2 html.c
--- html.c	1 Nov 2002 15:34:27 -0000	1.2
+++ html.c	3 Aug 2003 08:40:06 -0000
@@ -160,7 +160,7 @@
 
 		parent_obj = get_parent_html (accessible);
 		if (parent_obj) {
-			parent = HTML_OBJECT_ACCESSIBLE (parent_obj);
+			parent = html_utils_get_accessible (parent_obj, NULL);
 		}
 	}
 
Index: object.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/object.c,v
retrieving revision 1.3
diff -u -r1.3 object.c
--- object.c	24 Jul 2003 08:25:06 -0000	1.3
+++ object.c	3 Aug 2003 08:40:06 -0000
@@ -28,6 +28,7 @@
 #include "object.h"
 #include "paragraph.h"
 #include "utils.h"
+#include "text.h"
 
 static void gtk_html_a11y_class_init (GtkHTMLA11YClass *klass);
 static void gtk_html_a11y_init       (GtkHTMLA11Y *a11y);
@@ -165,12 +166,16 @@
 static void
 gtk_html_a11y_grab_focus_cb(GtkWidget * widget)
 {
-        AtkObject *focus_object, *obj;
+        AtkObject *focus_object, *obj, *clue;
 
 
 	 focus_object = gtk_html_a11y_get_focus_object (widget);
         obj = gtk_widget_get_accessible (widget);
         g_object_set_data (G_OBJECT(obj), "gail-focus-object", focus_object);
+
+	clue = html_utils_get_accessible(GTK_HTML(widget)->engine->clue, obj);
+	atk_object_set_parent(clue, obj);
+
         atk_focus_tracker_notify (focus_object);
 
 }
@@ -188,7 +193,14 @@
 		prev_object = focus_object;
         	g_object_set_data (G_OBJECT(obj), "gail-focus-object", focus_object);
         	atk_focus_tracker_notify (focus_object);
-	}
+	} else {
+		if (G_IS_HTML_A11Y_TEXT(focus_object)) {
+			gint offset;
+
+			offset = (GTK_HTML(widget))->engine->cursor->offset;
+			g_signal_emit_by_name(focus_object, "text_caret_moved",offset);
+                }
+        }
 }
 
 AtkObject* 
@@ -211,6 +223,7 @@
 	g_signal_connect_after(widget, "cursor_move",
 			G_CALLBACK(gtk_html_a11y_cursor_move_cb),
 			NULL);
+	html_utils_get_accessible(GTK_HTML(widget)->engine->clue, accessible);
 
 	/* printf ("created new gtkhtml accessible object\n"); */
 
Index: text.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/text.c,v
retrieving revision 1.3
diff -u -r1.3 text.c
--- text.c	15 Nov 2002 13:56:44 -0000	1.3
+++ text.c	3 Aug 2003 08:40:06 -0000
@@ -59,6 +59,8 @@
 static gboolean html_a11y_text_add_selection (AtkText *text, gint start_offset, gint end_offset);
 static gboolean html_a11y_text_remove_selection (AtkText *text, gint selection_num);
 static gboolean html_a11y_text_set_selection (AtkText *text, gint selection_num, gint start_offset, gint end_offset);
+static gint html_a11y_text_get_caret_offset (AtkText *text);
+static gboolean html_a11y_text_set_caret_offset (AtkText *text, gint offset);
 
 static AtkObjectClass *parent_class = NULL;
 
@@ -125,6 +127,8 @@
 	iface->get_selection = html_a11y_text_get_selection;
 	iface->remove_selection = html_a11y_text_remove_selection;
 	iface->set_selection = html_a11y_text_set_selection;
+	iface->get_caret_offset = html_a11y_text_get_caret_offset;
+	iface->set_caret_offset = html_a11y_text_set_caret_offset;
 }
 
 static void
@@ -259,6 +263,45 @@
 	return g_strndup (str, g_utf8_offset_to_pointer (str, end_offset - start_offset) - str);
 }
 
+static gint
+html_a11y_text_get_caret_offset(AtkText * text)
+{
+	HTMLObject * p;
+	HTMLEngine * e;
+	GtkHTML * html;
+
+	g_return_val_if_fail(text, 0);
+
+	p= HTML_A11Y_HTML(text);
+	g_return_val_if_fail(p && HTML_IS_TEXT(p), 0);
+
+	html = GTK_HTML_A11Y_GTKHTML(html_a11y_get_gtkhtml_parent(HTML_A11Y(text)));
+	g_return_val_if_fail(html && GTK_IS_HTML(html) && html->engine, 0);
+
+	e = html_engine_get_top_html_engine(html->engine);
+
+	g_return_val_if_fail(e && e->cursor && e->cursor->object == p, 0);
+
+	return e->cursor->offset;
+}
+
+static gboolean
+html_a11y_text_set_caret_offset(AtkText * text, gint offset)
+{
+	GtkHTML * html;
+	HTMLEngine * e;
+	HTMLObject * obj = HTML_A11Y_HTML(text);
+
+	html = GTK_HTML_A11Y_GTKHTML(html_a11y_get_gtkhtml_parent(HTML_A11Y(text)));
+
+	g_return_val_if_fail(obj && html && html->engine, FALSE);
+
+	e = html->engine;
+	html_engine_jump_to_object(e, obj, offset);
+
+	return TRUE;
+}
+
 static gchar *
 html_a11y_text_get_text_after_offset (AtkText *text, gint offset, AtkTextBoundary boundary_type,
 				      gint *start_offset, gint *end_offset)
@@ -326,6 +369,8 @@
 	HTMLObject *obj = HTML_A11Y_HTML (text);
 	HTMLInterval *i;
 
+	g_return_val_if_fail(html && html->engine, FALSE);
+
 	if (html_engine_is_selection_active (html->engine))
 		return FALSE;
 
@@ -357,6 +402,7 @@
 
 	return html_a11y_text_add_selection (text, start_offset, end_offset);
 }
+
 
 /*
   AtkAttributeSet* (* get_run_attributes)         (AtkText	    *text,
Index: utils.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/utils.c,v
retrieving revision 1.3
diff -u -r1.3 utils.c
--- utils.c	24 Jul 2003 08:25:06 -0000	1.3
+++ utils.c	3 Aug 2003 08:40:06 -0000
@@ -41,6 +41,9 @@
 	case HTML_TYPE_CLUEFLOW:
 		accessible = html_a11y_paragraph_new (o);
 		break;
+	case HTML_TYPE_CLUEV:
+		accessible = html_a11y_new (o, ATK_ROLE_INVALID);
+		break;
 	case HTML_TYPE_TEXT:
 		accessible = html_a11y_text_new (o);
 		break;
@@ -90,7 +93,7 @@
 {
 	AtkObject *accessible;
 
-	if (!o) return NULL;
+	g_return_val_if_fail(o != NULL, NULL);
 
 	accessible = html_object_get_data (o, ACCESSIBLE_ID);
 


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