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





Radek Doulík wrote:
On Wed, 2003-08-06 at 09:38, Yuedong Du wrote: 
  
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;
                }
        }
    

html_a11y_get_parent can be called from elsewhere as well. so it has to
just return parent's object accessible object or if you change it to
create one if it doesn't exist, it has to create it correctly and not
with accessible parent unset (NULL second argument in
html_utils_get_accessible)

Cheers
Radek

I see, here change to:
                                                                               
@@ -160,7 +160,10 @@
                                                                               
                parent_obj = get_parent_html (accessible);
                if (parent_obj) {
-                       parent = HTML_OBJECT_ACCESSIBLE (parent_obj);
+                       parent = html_utils_get_accessible (parent_obj, NULL);
+                       if ((p = html_a11y_get_parent(parent)) != NULL) {
+                               atk_object_set_parent(parent, p);
+                       }
                }
        }


Recursively call html_a11y_get_parent to get parent of the parent object.

Works well in my environment.

Thanks
York

  
? text.c.edit.c
? text.c.noedit.c
? 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	6 Aug 2003 09:16:59 -0000
@@ -149,7 +149,7 @@
 static AtkObject* 
 html_a11y_get_parent (AtkObject *accessible)
 {
-	AtkObject *parent;
+	AtkObject *parent, *p;
 
 	parent = accessible->accessible_parent;
 
@@ -160,7 +160,10 @@
 
 		parent_obj = get_parent_html (accessible);
 		if (parent_obj) {
-			parent = HTML_OBJECT_ACCESSIBLE (parent_obj);
+			parent = html_utils_get_accessible (parent_obj, NULL);
+			if ((p = html_a11y_get_parent(parent)) != NULL) {
+				atk_object_set_parent(parent, p);
+			}
 		}
 	}
 
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 09:16:59 -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 09:17:01 -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	6 Aug 2003 09:17:02 -0000
@@ -90,7 +90,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]