[evolution-patches] gtkhtml, fix the inconsistency of caret and focus
- From: Eric Zhao <eric zhao sun com>
- To: evolution-patches lists ximian com, Radek Doulík <rodo ximian com>
- Subject: [evolution-patches] gtkhtml, fix the inconsistency of caret and focus
- Date: Sun, 06 Jun 2004 14:40:11 +0800
Hi,
Attached is a patch which fixes the inconsistency of caret and focus:
* when the focus is changed, change the caret to the focused object.
* when the caret is moved to a focusable object, set focus to this
object.
Would you please give this patch a review? Thanks!
Regards,
Eric
Index: htmlengine.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.h,v
retrieving revision 1.183
diff -u -r1.183 htmlengine.h
--- htmlengine.h 6 May 2004 16:04:39 -0000 1.183
+++ htmlengine.h 6 Jun 2004 06:07:37 -0000
@@ -471,6 +471,9 @@
void html_engine_set_focus_object (HTMLEngine *e,
HTMLObject *o,
gint offset);
+void html_engine_update_focus_if_necessary (HTMLEngine *e,
+ HTMLObject *o,
+ gint offset);
HTMLMap *html_engine_get_map (HTMLEngine *e,
const gchar *name);
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.609
diff -u -r1.609 htmlengine.c
--- htmlengine.c 4 Jun 2004 15:05:48 -0000 1.609
+++ htmlengine.c 6 Jun 2004 06:07:53 -0000
@@ -6172,6 +6172,14 @@
}
}
+void
+html_engine_update_focus_if_necessary (HTMLEngine *e, HTMLObject *obj, gint offset)
+{
+ if (obj && ((HTML_IS_IMAGE (obj) && HTML_IMAGE (obj)->url && *HTML_IMAGE (obj)->url))
+ || (HTML_IS_TEXT (obj) && html_object_get_complete_url (obj, offset)))
+ html_engine_set_focus_object (e, obj, offset);
+}
+
void
html_engine_set_focus_object (HTMLEngine *e, HTMLObject *o, gint offset)
{
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.566
diff -u -r1.566 gtkhtml.c
--- gtkhtml.c 4 Jun 2004 15:05:48 -0000 1.566
+++ gtkhtml.c 6 Jun 2004 06:08:05 -0000
@@ -2262,6 +2262,8 @@
if (!GTK_WIDGET_HAS_FOCUS (w) && !html_object_is_embedded (obj))
gtk_widget_grab_focus (w);
+ if (e->caret_mode)
+ html_engine_jump_to_object (e, obj, offset);
return TRUE;
}
Index: htmlengine-edit-movement.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-movement.c,v
retrieving revision 1.18
diff -u -r1.18 htmlengine-edit-movement.c
--- htmlengine-edit-movement.c 4 Jun 2004 15:05:48 -0000 1.18
+++ htmlengine-edit-movement.c 6 Jun 2004 06:08:06 -0000
@@ -83,6 +83,7 @@
break;
}
+ html_engine_update_focus_if_necessary (e, e->cursor->object, e->cursor->offset);
html_engine_show_cursor (e);
html_engine_update_selection_if_necessary (e);
@@ -159,6 +160,7 @@
html_engine_hide_cursor (engine);
html_cursor_beginning_of_document (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -172,6 +174,7 @@
html_engine_hide_cursor (engine);
html_cursor_end_of_document (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -188,6 +191,7 @@
html_engine_hide_cursor (engine);
retval = html_cursor_beginning_of_line (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -205,6 +209,7 @@
html_engine_hide_cursor (engine);
retval = html_cursor_end_of_line (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -222,6 +227,7 @@
html_engine_hide_cursor (engine);
retval = html_cursor_beginning_of_paragraph (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -239,6 +245,7 @@
html_engine_hide_cursor (engine);
retval = html_cursor_end_of_paragraph (engine->cursor, engine);
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -292,6 +299,7 @@
y = new_y;
}
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -344,6 +352,7 @@
y = new_y;
}
+ html_engine_update_focus_if_necessary (engine, engine->cursor->object, engine->cursor->offset);
html_engine_show_cursor (engine);
html_engine_update_selection_if_necessary (engine);
@@ -365,6 +374,7 @@
rv = TRUE;
while (g_unichar_isalnum (html_cursor_get_current_char (e->cursor)) && html_cursor_forward (e->cursor, e))
rv = TRUE;
+ html_engine_update_focus_if_necessary (e, e->cursor->object, e->cursor->offset);
html_engine_show_cursor (e);
html_engine_update_selection_if_necessary (e);
@@ -384,6 +394,7 @@
rv = TRUE;
while (g_unichar_isalnum (html_cursor_get_prev_char (e->cursor)) && html_cursor_backward (e->cursor, e))
rv = TRUE;
+ html_engine_update_focus_if_necessary (e, e->cursor->object, e->cursor->offset);
html_engine_show_cursor (e);
html_engine_update_selection_if_necessary (e);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2010
diff -u -r1.2010 ChangeLog
--- ChangeLog 4 Jun 2004 15:05:48 -0000 1.2010
+++ ChangeLog 6 Jun 2004 06:18:20 -0000
@@ -1,3 +1,19 @@
+2004-06-06 Eric Zhao <eric zhao sun com>
+
+ make the caret consistent with focus.
+
+ * gtkhtml.c: (focus): change caret to the focused object.
+ * htmlengine-edit-movement.c: (html_engine_move_cursor),
+ (html_engine_beginning_of_document), (html_engine_end_of_document),
+ (html_engine_beginning_of_line), (html_engine_end_of_line),
+ (html_engine_beginning_of_paragraph),
+ (html_engine_end_of_paragraph), (html_engine_scroll_down),
+ (html_engine_scroll_up), (html_engine_forward_word),
+ (html_engine_backward_word): set focus to the object under cursor if
+ it's focusable.
+ * htmlengine.c: (html_engine_update_focus_if_necessary):
+ * htmlengine.h: set focus to the object if it's focusable.
+
2004-06-04 Radek Doulik <rodo ximian com>
* added few missing inludes of header files
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]