[evolution-patches] patch about gtkhtml, fix #70078



hi, rodo

I resend my patches. One mail only contains one patch against one bug.

Please ignore all patches I send you before.

Thanks for your review.

Your,
Mengjie Yu
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2062
diff -u -p -r1.2062 ChangeLog
--- ChangeLog	6 Dec 2004 16:41:35 -0000	1.2062
+++ ChangeLog	14 Dec 2004 10:14:01 -0000
@@ -1,3 +1,15 @@
+2004-12-14  Mengjie Yu  <meng-jie yu sun com>
+
+	* gtkhtml.c: (focus), (gtk_html_class_init), (cursor_move):
+	fix #70078 Add new signals when for insert/delete
+		   change gtk_html_a11y_cursor_move_cb to cursor_changed_cb
+	* gtkhtml.h:
+	fix #70078 add signal field
+
+	* htmlengine-edit-cut-and-paste.c: (insert_object_for_undo),
+	(html_engine_delete):
+	fix #70078 emit signal when insert/delete objects
+
 2004-09-29  Radek Doulik  <rodo ximian com>
 
 	* gtkhtml.c (drag_data_received): call gdk_window_get_pointer so
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.583
diff -u -p -r1.583 gtkhtml.c
--- gtkhtml.c	6 Dec 2004 16:41:35 -0000	1.583
+++ gtkhtml.c	14 Dec 2004 10:14:13 -0000
@@ -124,6 +124,9 @@ enum {
 	SCROLL,
 	CURSOR_MOVE,
 	COMMAND,
+	CURSOR_CHANGED,
+	OBJECT_INSERTED,
+	OBJECT_DELETED,
 	/* now only last signal */
 	LAST_SIGNAL
 };
@@ -2337,9 +2340,10 @@ focus (GtkWidget *w, GtkDirectionType di
 
 		if (!GTK_WIDGET_HAS_FOCUS (w) && !html_object_is_embedded (obj))
 			gtk_widget_grab_focus (w);
-		if (e->caret_mode)
+		if (e->caret_mode) {
 			html_engine_jump_to_object (e, obj, offset);
-
+			g_signal_emit (GTK_HTML (w), signals [CURSOR_CHANGED], 0);
+		}
 		return TRUE;
 	}
 
@@ -2879,6 +2883,34 @@ gtk_html_class_init (GtkHTMLClass *klass
 			      g_cclosure_marshal_VOID__ENUM,
 			      G_TYPE_NONE, 1, GTK_TYPE_HTML_COMMAND);
 
+	signals [CURSOR_CHANGED] = 
+		g_signal_new ("cursor_changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GtkHTMLClass, cursor_changed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+
+	signals [OBJECT_INSERTED] = 
+		g_signal_new ("object_inserted",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GtkHTMLClass, object_inserted),
+			      NULL, NULL,
+			      html_g_cclosure_marshal_VOID__INT_INT,
+			      G_TYPE_NONE, 2,
+			      G_TYPE_INT, G_TYPE_INT);
+
+	signals [OBJECT_DELETED] = 
+		g_signal_new ("object_deleted",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GtkHTMLClass, object_deleted),
+			      NULL, NULL,
+			      html_g_cclosure_marshal_VOID__INT_INT,
+			      G_TYPE_NONE, 2,
+			      G_TYPE_INT, G_TYPE_INT);
 	object_class->destroy = destroy;
 	
 
@@ -4400,6 +4432,7 @@ cursor_move (GtkHTML *html, GtkDirection
 	html->priv->update_styles = TRUE;
 	gtk_html_edit_make_cursor_visible (html);
 	html_engine_update_selection_active_state (html->engine, html->priv->event_time);
+	g_signal_emit (GTK_HTML (html), signals [CURSOR_CHANGED], 0);
 }
 
 static gboolean
Index: gtkhtml.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.h,v
retrieving revision 1.154
diff -u -p -r1.154 gtkhtml.h
--- gtkhtml.h	1 Nov 2004 12:20:26 -0000	1.154
+++ gtkhtml.h	14 Dec 2004 10:14:15 -0000
@@ -101,6 +101,9 @@ struct _GtkHTMLClass {
 					   gfloat position);
 	void     (* cursor_move)          (GtkHTML *html, GtkDirectionType dir_type, GtkHTMLCursorSkipType skip);
 	gboolean (* command)              (GtkHTML *html, GtkHTMLCommandType com_type);
+	void (* cursor_changed)       (GtkHTML *html);
+	void (* object_inserted)       (GtkHTML *html, int pos, int len);
+	void (* object_deleted)        (GtkHTML *html, int pos, int len);
 
 	/* properties */
 	GtkHTMLClassProperties *properties;
Index: htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.104
diff -u -p -r1.104 htmlengine-edit-cut-and-paste.c
--- htmlengine-edit-cut-and-paste.c	10 Nov 2004 17:23:42 -0000	1.104
+++ htmlengine-edit-cut-and-paste.c	14 Dec 2004 10:14:17 -0000
@@ -1076,6 +1076,7 @@ insert_object_for_undo (HTMLEngine *e, H
 	html_cursor_jump_to_position_no_spell (e->cursor, e, position_after + (delete_paragraph_before ? 1 : 0));
 	insert_setup_undo (e, len, position_before + (delete_paragraph_before ? 1 : 0),
 			   dir, delete_paragraph_before, delete_paragraph_after);
+	g_signal_emit_by_name (e->widget, "object_inserted", position_before, len);
 }
 
 static void
@@ -1710,6 +1711,8 @@ html_engine_delete (HTMLEngine *e)
 		HTMLCursor *start = html_cursor_dup (e->mark->position < e->cursor->position ? e->mark : e->cursor);
 		HTMLCursor *end = html_cursor_dup (e->mark->position < e->cursor->position ? e->cursor : e->mark);
 		gint start_position = start->position;
+		gint end_position = end->position;
+
 
 		while (start->position < end->position) {
 			if (start->object->parent->parent == end->object->parent->parent) {
@@ -1755,6 +1758,11 @@ html_engine_delete (HTMLEngine *e)
 		if (end)
 			html_cursor_destroy (end);
 		html_cursor_jump_to_position (e->cursor, e, start_position);
+
+		if (end_position - start_position > 0) {
+			int len = end_position - start_position;
+			g_signal_emit_by_name (e->widget, "object_deleted", start_position, len);
+		}
 	}
 	html_undo_level_end (e->undo);
 }
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/ChangeLog,v
retrieving revision 1.12
diff -u -p -r1.12 ChangeLog
--- ChangeLog	1 Nov 2004 09:41:59 -0000	1.12
+++ ChangeLog	14 Dec 2004 10:11:22 -0000
@@ -1,3 +1,11 @@
+2004-12-14  Mengjie Yu  <meng-jie yu sun com>
+
+	* object.c: (gtk_html_a11y_cursor_changed_cb),
+	(gtk_html_a11y_insert_object_cb), (gtk_html_a11y_delete_object_cb),
+	(gtk_html_a11y_new):
+	fix #70078 listen and handle the insert/delete signal. 
+		   For text object, emit text_changed signal.
+
 2004-11-01  Radek Doulik  <rodo ximian com>
 
 	* Makefile.am (AM_CFLAGS): use AM_FLAGS instead of CFLAGS
Index: object.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/object.c,v
retrieving revision 1.5
diff -u -p -r1.5 object.c
--- object.c	26 May 2004 02:26:17 -0000	1.5
+++ object.c	14 Dec 2004 10:11:23 -0000
@@ -178,11 +178,13 @@ gtk_html_a11y_grab_focus_cb(GtkWidget * 
 
 }
 
+
+static AtkObject * prev_object = NULL;
+
 static void
-gtk_html_a11y_cursor_move_cb(GtkWidget *widget,  GtkDirectionType dir_type, GtkHTMLCursorSkipType skip)
+gtk_html_a11y_cursor_changed_cb (GtkWidget *widget)
 {
         AtkObject *focus_object, *obj;
-	static AtkObject * prev_object = NULL;
 
 	focus_object = gtk_html_a11y_get_focus_object (widget);
        obj = gtk_widget_get_accessible (widget);
@@ -201,6 +203,47 @@ gtk_html_a11y_cursor_move_cb(GtkWidget *
         }
 }
 
+static void
+gtk_html_a11y_insert_object_cb (GtkWidget * widget, int pos, int len) 
+{
+	AtkObject * a11y, *obj;
+	HTMLText * text;
+
+        obj = gtk_widget_get_accessible (widget);
+	a11y = gtk_html_a11y_get_focus_object (widget);
+
+	if (prev_object != a11y) {
+		prev_object = a11y;
+        	g_object_set_data (G_OBJECT(obj), "gail-focus-object", a11y);
+        	atk_focus_tracker_notify (a11y);
+	}
+
+	if (G_IS_HTML_A11Y_TEXT(a11y)) {
+		g_signal_emit_by_name (a11y, "text_changed::insert", pos, len);
+
+	} 
+}
+
+static void
+gtk_html_a11y_delete_object_cb (GtkWidget * widget, int pos, int len) 
+{
+	AtkObject * a11y, *obj;
+	HTMLText * text;
+
+        obj = gtk_widget_get_accessible (widget);
+	a11y = gtk_html_a11y_get_focus_object (widget);
+
+	if (prev_object != a11y) {
+		prev_object = a11y;
+        	g_object_set_data (G_OBJECT(obj), "gail-focus-object", a11y);
+        	atk_focus_tracker_notify (a11y);
+	}
+
+	if (G_IS_HTML_A11Y_TEXT(a11y)) {
+		g_signal_emit_by_name (a11y, "text_changed::delete", pos, len);
+	}
+}
+
 AtkObject* 
 gtk_html_a11y_new (GtkWidget *widget)
 {
@@ -215,12 +258,19 @@ gtk_html_a11y_new (GtkWidget *widget)
 	atk_object_initialize (accessible, widget);
 
 	accessible->role = ATK_ROLE_HTML_CONTAINER;
-	g_signal_connect_after(widget, "grab_focus", 
+	g_signal_connect_after (widget, "grab_focus", 
 			G_CALLBACK (gtk_html_a11y_grab_focus_cb),
 			NULL);
-	g_signal_connect_after(widget, "cursor_move",
-			G_CALLBACK(gtk_html_a11y_cursor_move_cb),
+	g_signal_connect (widget, "cursor_changed",
+			G_CALLBACK(gtk_html_a11y_cursor_changed_cb),
+			NULL);
+	g_signal_connect_after (widget, "object_inserted",
+			G_CALLBACK(gtk_html_a11y_insert_object_cb),
 			NULL);
+	g_signal_connect_after (widget, "object_deleted",
+			G_CALLBACK(gtk_html_a11y_delete_object_cb),
+			NULL);
+
 	html_utils_get_accessible(GTK_HTML(widget)->engine->clue, accessible);
 
 	/* printf ("created new gtkhtml accessible object\n"); */


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