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





This doesn't seem quite right, cluev should not have role INVALID
(why?). by default branch in switch statement it will get accessible
object with role UNKNOWN which should be OK. So I don't see reason for
this.
  
You are right, I misunderstund the function. Just remove them is ok.

  
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.
    

This looks OK. I hope it's the only way it can happen.

  
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.
    

Yeah, it starts always with engine->cluev. At least for now. Larry is
refactoring parser in trunk so it may change, but for 1.4.x you are
safe.

Also this change doesn't seem to be quite right:

@@ -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);
                }
        }

I think you have to create recursively accessible objects for all
parents of parent_obj here.


In the loop of html_a11y_get_gtkhtml_parent(), the while loop will go through all parent of obj. And all the accessible objects will be  created in each loops.
So I do not need to create all of them here, right?

        while (obj) {
                obj = atk_object_get_parent (obj);
                if (G_IS_GTK_HTML_A11Y (obj)) {
                        gtkhtml_a11y = GTK_HTML_A11Y (obj);
                        break;
                }
        }

New patch attached.


Cheers
Radek


_______________________________________________
Evolution-patches mailing list
Evolution-patches lists ximian com
http://lists.ximian.com/mailman/listinfo/evolution-patches
  
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	6 Aug 2003 07:35:46 -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	6 Aug 2003 07:35:47 -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	6 Aug 2003 07:35:47 -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,


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