Re: [evolution-patches] Patch to enable cursor and keyboard navigation in mail reader,(v6), menu version



Hi,

Found conflict when I update code, so I resolve the conflict in the
new gtkhtml patch attached.

And a error cause evolution hang when setting gtkhtml style is also
fixed in the patch.  See snippet below,

--- src/gtkhtml.c       25 Jun 2003 18:15:46 -0000      1.518
+++ src/gtkhtml.c       27 Jun 2003 05:00:43 -0000
@@ -737,9 +737,9 @@
        if (fixed_name) {
                fixed_desc = pango_font_description_from_string (fixed_name);
                if (pango_font_description_get_family (fixed_desc)) {
                        fixed_size = PANGO_PIXELS (pango_font_description_get_size (fixed_desc));
-                       (const gchar *) fixed_family = pango_font_description_get_family (fixed_desc);
+                       (const gchar *) fixed_family = g_strdup(pango_font_description_get_family (fixed_desc));
                } else {
                        g_free (fixed_name);
                        fixed_name = NULL;
                }

The fixed_family is g_free() at end the gtk_html_set_fonts(), by
looking at the defination, it should not be freed:

G_CONST_RETURN char *
pango_font_description_get_family (const PangoFontDescription *desc)
{
  g_return_val_if_fail (desc != NULL, NULL);
                                                                                
  return desc->family_name;
}


Thanks
-York


HI all,

Now put the option in the view/message display submenu. It is of
'toggle' type. see the snippet of evolution-mail-message.xml
below(cannot take screenshot for menu, seems to be limitation of
printscreen key):

  </submenu>
    <submenu name="MessageDisplay" _label="_Message Display">
    <menuitem name="ViewLoadImages" verb="" _label="Load _Images"/>
+   <menuitem name="CaretMode" verb="" _label="Show _Blinking Cursor"/>
     ... ...

And to find a name for the menu entry is really a headache. Anna, if you
do not agree with the name "Show blinking cursor", could you give me a
suggestion? 

A small change in patch of gtkhtml. Previously only setup the blinking
cursor handler in focus in event handler. But if user already focus in a
mail reader, and type f7 to turn on cursor, no focus in event. So we
need to setup the blinking cursor there, and thus after cursor blinking
event no focus in event.

Tested,

Regards
York


> Anyway, if we make this option available in the menus using the "F7"
> key, then it will be more easy to quickly turn on and turn off than if
> it is in the settings dialog. 
> 
> Further, it seems to me that many of the options which control how an
> email is displayed are listed in the "View" menu. From that menu, one
> can: 
> 
> * turn the preview pane on/off
> * change the size of the text
> * specify whether or not images are loaded
> * specify whether email headers/source should be shown
> 
> It makes sense to me, therefore, to put the setting for caret mode in
> the same menu, given that it is of similar scope (all these options
> allow you to specify how you want to read your email messages.)
> 
> What do you think? 
> 
> Take care, 
> Anna
> 
> 
> 
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.516
diff -u -r1.516 gtkhtml.c
--- src/gtkhtml.c	13 Jun 2003 21:42:59 -0000	1.516
+++ src/gtkhtml.c	26 Jun 2003 14:11:30 -0000
@@ -720,6 +720,24 @@
 		(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
 
+static void
+set_caret_mode(HTMLEngine *engine, gboolean caret_mode)
+{
+	if (engine->editable) return;
+
+	engine->caret_mode = caret_mode;
+
+	/* Normally, blink cursor handler is setup in focus in event.
+	 * However, in the case focus already in this engine, and user
+	 * type F7 to enable cursor, we must setup the handler by 
+	 * ourselves.
+         */
+	if (caret_mode && !engine->blinking_timer_id && engine->have_focus)
+		html_engine_setup_blinking_cursor (engine);
+
+	return;
+}
+
 /* GtkWidget methods.  */
 static void
 style_set (GtkWidget *widget, GtkStyle  *previous_style)
@@ -730,6 +748,7 @@
 	gint  fixed_size = 0;
 	char *font_var = NULL;
 	gint  font_var_size = 0;
+	gboolean caret_mode = FALSE;
 
 	/* we don't need to set font's in idle time so call idle callback directly to avoid
 	   recalculating whole document
@@ -766,11 +785,14 @@
 			html_engine_calc_size (engine, FALSE);
 			html_engine_schedule_update (engine);
 		}
+
 		
 		g_free (fixed_name);
 		g_free (font_var);
 	}
 
+	gtk_widget_style_get (widget, "caret_mode", &caret_mode, NULL);
+	set_caret_mode(engine, caret_mode);
 
 	html_colorset_set_style (engine->defaultSettings->color_set, widget);
 	html_colorset_set_unchanged (engine->settings->color_set,
@@ -1477,8 +1499,10 @@
 				if (obj && ((HTML_IS_IMAGE (obj) && HTML_IMAGE (obj)->url && *HTML_IMAGE (obj)->url)
 					    || HTML_IS_LINK_TEXT (obj)))
 					html_engine_set_focus_object (orig_e, obj);
-				else
+				else {
 					html_engine_set_focus_object (orig_e, NULL);
+					html_engine_jump_at (engine, x, y);
+				}
 			}
 			if (html->allow_selection) {
 				if (event->state & GDK_SHIFT_MASK)
@@ -2598,6 +2622,12 @@
 								     GDK_TYPE_COLOR,
 								     G_PARAM_READABLE));
 
+	gtk_widget_class_install_style_property (widget_class,
+						 g_param_spec_boxed ("caret_mode",
+								     _("Caret Mode"),
+								     _("Enable cursor when reading mail"),
+								     G_TYPE_BOOLEAN,
+								     G_PARAM_READABLE));
 	widget_class->realize = realize;
 	widget_class->unrealize = unrealize;
 	widget_class->style_set = style_set;
@@ -3787,8 +3817,6 @@
 {
 	gint amount;
 
-	if (!html_engine_get_editable (html->engine))
-		return;
 
 	if (html->engine->selection_mode) {
 		if (!html->engine->mark)
Index: src/htmlengine-edit-cursor.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cursor.c,v
retrieving revision 1.22
diff -u -r1.22 htmlengine-edit-cursor.c
--- src/htmlengine-edit-cursor.c	2 Apr 2003 05:41:47 -0000	1.22
+++ src/htmlengine-edit-cursor.c	26 Jun 2003 14:11:31 -0000
@@ -29,6 +29,7 @@
 #include "htmlengine-edit-table.h"
 #include "htmlengine-edit-tablecell.h"
 #include "htmlimage.h"
+#include "htmliframe.h"
 #include "htmlobject.h"
 #include "htmltable.h"
 
@@ -47,14 +48,42 @@
 static GdkColor image_stipple_active_on      = { 0, 0xffff, 0,      0 };
 static GdkColor image_stipple_active_off     = { 0, 0xffff, 0xffff, 0xffff };
 
+static HTMLEngine *
+get_direct_engine(HTMLObject * obj)
+{
+        HTMLObject * parent;
+	int i = 0;
+                                                                                
+        parent = obj;
+        while (parent) {
+                if ((HTML_OBJECT_TYPE (parent) == HTML_TYPE_FRAME)
+                    || (HTML_OBJECT_TYPE (parent) == HTML_TYPE_IFRAME)) {
+                       return html_object_get_engine (parent, NULL);
+                }
+                parent = parent->parent;
+        }
+                                                                                
+        return NULL;
+}
+
 void
 html_engine_hide_cursor  (HTMLEngine *engine)
 {
+	HTMLEngine *e = engine;
+
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
 
-	if (engine->editable && engine->cursor_hide_count == 0)
-		html_engine_draw_cursor_in_area (engine, 0, 0, -1, -1);
+	if ((engine->editable || engine->caret_mode) && engine->cursor_hide_count == 0) {
+		if (!engine->editable) {
+        		e = get_direct_engine(engine->cursor->object);
+			if (e) {
+				e->caret_mode = engine->caret_mode;
+				html_cursor_copy(e->cursor, engine->cursor);
+			} else 	e = engine;
+		}
+		html_engine_draw_cursor_in_area (e, 0, 0, -1, -1);
+	}
 
 	engine->cursor_hide_count++;
 }
@@ -62,22 +91,37 @@
 void
 html_engine_show_cursor  (HTMLEngine *engine)
 {
+        HTMLEngine * e = engine;
+
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
+	g_return_if_fail (engine->cursor != NULL);
 
 	if (engine->cursor_hide_count > 0) {
 		engine->cursor_hide_count--;
-		if (engine->editable && engine->cursor_hide_count == 0)
-			html_engine_draw_cursor_in_area (engine, 0, 0, -1, -1);
+		if ((engine->editable || engine->caret_mode) && engine->cursor_hide_count == 0) {
+			if (!engine->editable) {
+        			e = get_direct_engine(engine->cursor->object);
+				if (e) {
+					e->caret_mode = engine->caret_mode;
+					html_cursor_copy(e->cursor, engine->cursor);
+				} else e = engine;
+			}
+			html_engine_draw_cursor_in_area (e, 0, 0, -1, -1);
+		}
 	}
 }
 
 static gboolean
 clip_rect (HTMLEngine *engine, gint x, gint y, gint width, gint height, gint *x1, gint *y1, gint *x2, gint *y2)
 {
-	if (*x1 >= x + width || *y1 >= y + height || *x2 < x || *y2 < y)
+	if (*x1 > x + width || *y1 > y + height || *x2 < x || *y2 < y)
 		return FALSE;
 
+	if (*x1 == x + width)
+		*x1 = x + width - 1;
+	if (*y1 == y + width)
+		*y1 = y + height - 1;
 	if (*x2 >= x + width)
 		*x2 = x + width - 1;
 	if (*y2 >= y + height)
@@ -265,15 +309,13 @@
 	gint x1, y1, x2, y2;
 	GdkRectangle pos;
 
-	g_assert (engine->editable);
-
-	if (engine->editable && (engine->cursor_hide_count <= 0 && !engine->thaw_idle_id)) {
+	if ((engine->editable || engine->caret_mode) && (engine->cursor_hide_count <= 0 && !engine->thaw_idle_id)) {
 		html_engine_draw_table_cursor (engine);
 		html_engine_draw_cell_cursor (engine);
 		html_engine_draw_image_cursor (engine);
 	}
 
-	if (!cursor_enabled || engine->cursor_hide_count > 0 || ! engine->editable || engine->thaw_idle_id)
+	if (!cursor_enabled || engine->cursor_hide_count > 0 || !(engine->editable || engine->caret_mode) || engine->thaw_idle_id)
 		return;
 
 	obj = engine->cursor->object;
@@ -289,14 +331,23 @@
 		y = 0;
 	}
 
-	
 	html_object_get_cursor (obj, engine->painter, offset, &x1, &y1, &x2, &y2);
-	
 	pos.x = x1; 
 	pos.y = y1;
 	pos.width = x2 - x1;
 	pos.height = x2 - x1;
 	gtk_im_context_set_cursor_location (GTK_HTML (engine->widget)->priv->im_context, &pos);
+
+	obj = g_object_get_data(G_OBJECT(gtk_widget_get_parent(GTK_WIDGET(engine->widget))), "embeddedelement");	
+	if (obj) {
+		HTMLEmbedded * element;
+
+		element = HTML_EMBEDDED(obj);
+		x1 -= element->abs_x;
+		x2 -= element->abs_x;
+		y1 -= element->abs_y;
+		y2 -= element->abs_y;
+	}
 
 	if (clip_rect (engine, x, y, width, height, &x1, &y1, &x2, &y2)) {
 		gdk_draw_line (engine->window, engine->invert_gc, x1, y1, x2, y2);
Index: src/htmlengine-edit-movement.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-movement.c,v
retrieving revision 1.15
diff -u -r1.15 htmlengine-edit-movement.c
--- src/htmlengine-edit-movement.c	25 Apr 2001 21:31:53 -0000	1.15
+++ src/htmlengine-edit-movement.c	26 Jun 2003 14:11:32 -0000
@@ -275,8 +275,10 @@
 		if (new_y == y)
 			break;
 
-		if (new_y < start_y)
+		if (new_y < start_y) {
+			html_engine_show_cursor (engine);
 			return 0;
+		}
 
 		if (new_y - start_y >= amount) {
 			html_cursor_copy (cursor, &prev_cursor);
Index: src/htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.544
diff -u -r1.544 htmlengine.c
--- src/htmlengine.c	13 Jun 2003 21:42:59 -0000	1.544
+++ src/htmlengine.c	26 Jun 2003 14:11:50 -0000
@@ -3569,6 +3569,7 @@
 	engine->allow_frameset = FALSE;
 
 	engine->editable = FALSE;
+	engine->caret_mode = FALSE;
 	engine->clipboard = NULL;
 	engine->clipboard_stack = NULL;
 	engine->selection_stack  = NULL;
@@ -4589,12 +4590,14 @@
 		html_engine_ensure_editable (e);
 		html_cursor_home (e->cursor, e);
 		e->newPage = FALSE;
-
 		if (e->have_focus)
 			html_engine_setup_blinking_cursor (e);
 	} else {
-		if (e->have_focus)
-			html_engine_stop_blinking_cursor (e);
+		if (e->have_focus )
+			if (e->caret_mode)
+				html_engine_setup_blinking_cursor (e);
+			else 
+				html_engine_stop_blinking_cursor (e);
 	}
 }
 
@@ -4626,7 +4629,7 @@
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
 
-	if (engine->editable) {
+	if (engine->editable || engine->caret_mode) {
 		if (! engine->have_focus && have_focus)
 			html_engine_setup_blinking_cursor (engine);
 		else if (engine->have_focus && ! have_focus)
@@ -4665,9 +4668,6 @@
 	gint x1, y1, x2, y2, xo, yo;
 
 	g_return_val_if_fail (e != NULL, FALSE);
-
-	if (! e->editable)
-		return FALSE;
 
 	if (e->cursor->object == NULL)
 		return FALSE;
Index: src/htmlengine.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.h,v
retrieving revision 1.168
diff -u -r1.168 htmlengine.h
--- src/htmlengine.h	19 May 2003 12:58:36 -0000	1.168
+++ src/htmlengine.h	26 Jun 2003 14:11:51 -0000
@@ -65,6 +65,7 @@
 	GdkGC *invert_gc;
 
 	gboolean editable;
+	gboolean caret_mode;
 
 	HTMLObject *clipboard;
 	guint       clipboard_len;
Index: src/htmliframe.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmliframe.c,v
retrieving revision 1.74
diff -u -r1.74 htmliframe.c
--- src/htmliframe.c	19 May 2003 13:12:04 -0000	1.74
+++ src/htmliframe.c	26 Jun 2003 14:11:55 -0000
@@ -592,6 +592,7 @@
 
 	new_widget = gtk_html_new ();
 	new_html = GTK_HTML (new_widget);
+	new_html->engine->cursor_hide_count = 0;
 
 	new_tokenizer = html_tokenizer_clone (parent_html->engine->ht);
 
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.518
diff -u -4 -r1.518 gtkhtml.c
--- src/gtkhtml.c	25 Jun 2003 18:15:46 -0000	1.518
+++ src/gtkhtml.c	27 Jun 2003 05:00:43 -0000
@@ -737,9 +737,9 @@
 	if (fixed_name) {
 		fixed_desc = pango_font_description_from_string (fixed_name);
 		if (pango_font_description_get_family (fixed_desc)) {
 			fixed_size = PANGO_PIXELS (pango_font_description_get_size (fixed_desc));
-			(const gchar *) fixed_family = pango_font_description_get_family (fixed_desc);
+			(const gchar *) fixed_family = g_strdup(pango_font_description_get_family (fixed_desc));
 		} else {
 			g_free (fixed_name);
 			fixed_name = NULL;
 		}
@@ -760,13 +760,32 @@
 	g_free (fixed_name);
 	g_free (fixed_family);
 }
 
+static void
+set_caret_mode(HTMLEngine *engine, gboolean caret_mode)
+{
+	if (engine->editable) return;
+
+	engine->caret_mode = caret_mode;
+
+	/* Normally, blink cursor handler is setup in focus in event.
+	 * However, in the case focus already in this engine, and user
+	 * type F7 to enable cursor, we must setup the handler by
+	 * ourselves.
+	 */
+	if (caret_mode && !engine->blinking_timer_id && engine->have_focus)
+		html_engine_setup_blinking_cursor (engine);
+
+	return;
+}
+
 /* GtkWidget methods.  */
 static void
 style_set (GtkWidget *widget, GtkStyle  *previous_style)
 {
 	HTMLEngine *engine = GTK_HTML (widget)->engine;
+	gboolean caret_mode = FALSE;
 
 	/* we don't need to set font's in idle time so call idle callback directly to avoid
 	   recalculating whole document
 	*/
@@ -779,8 +798,10 @@
 			html_engine_schedule_update (engine);
 		}
 	}
 
+	gtk_widget_style_get (widget, "caret_mode", &caret_mode, NULL);
+	set_caret_mode(engine, caret_mode);
 
 	html_colorset_set_style (engine->defaultSettings->color_set, widget);
 	html_colorset_set_unchanged (engine->settings->color_set,
 				     engine->defaultSettings->color_set);
@@ -1485,10 +1506,12 @@
 								 NULL, FALSE);
 				if (obj && ((HTML_IS_IMAGE (obj) && HTML_IMAGE (obj)->url && *HTML_IMAGE (obj)->url)
 					    || HTML_IS_LINK_TEXT (obj)))
 					html_engine_set_focus_object (orig_e, obj);
-				else
+				else {
 					html_engine_set_focus_object (orig_e, NULL);
+					html_engine_jump_at (engine, x, y);
+				}
 			}
 			if (html->allow_selection) {
 				if (event->state & GDK_SHIFT_MASK)
 					html_engine_select_region (engine,
@@ -2605,8 +2628,15 @@
 								     _("Spelling Error Color"),
 								     _("The color of the spelling error markers"),
 								     GDK_TYPE_COLOR,
 								     G_PARAM_READABLE));
+	gtk_widget_class_install_style_property (widget_class,
+						g_param_spec_boxed ("caret_mode",
+								    _("Caret Mode"),
+								    _("Enable cursor when reading mail"),
+								    G_TYPE_BOOLEAN,
+								    G_PARAM_READABLE));
+
 
 	widget_class->realize = realize;
 	widget_class->unrealize = unrealize;
 	widget_class->style_set = style_set;
@@ -3794,11 +3824,8 @@
 static void
 cursor_move (GtkHTML *html, GtkDirectionType dir_type, GtkHTMLCursorSkipType skip)
 {
 	gint amount;
-
-	if (!html_engine_get_editable (html->engine))
-		return;
 
 	if (html->engine->selection_mode) {
 		if (!html->engine->mark)
 			html_engine_set_mark (html->engine);
Index: src/htmlengine-edit-cursor.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cursor.c,v
retrieving revision 1.22
diff -u -4 -r1.22 htmlengine-edit-cursor.c
--- src/htmlengine-edit-cursor.c	2 Apr 2003 05:41:47 -0000	1.22
+++ src/htmlengine-edit-cursor.c	27 Jun 2003 05:00:45 -0000
@@ -28,8 +28,9 @@
 #include "htmlengine-edit-cursor.h"
 #include "htmlengine-edit-table.h"
 #include "htmlengine-edit-tablecell.h"
 #include "htmlimage.h"
+#include "htmliframe.h"
 #include "htmlobject.h"
 #include "htmltable.h"
 
 #define BLINK_TIMEOUT 500
@@ -46,39 +47,82 @@
 
 static GdkColor image_stipple_active_on      = { 0, 0xffff, 0,      0 };
 static GdkColor image_stipple_active_off     = { 0, 0xffff, 0xffff, 0xffff };
 
+static HTMLEngine *
+get_direct_engine(HTMLObject * obj)
+{
+        HTMLObject * parent;
+	int i = 0;
+                                                                                
+        parent = obj;
+        while (parent) {
+                if ((HTML_OBJECT_TYPE (parent) == HTML_TYPE_FRAME)
+                    || (HTML_OBJECT_TYPE (parent) == HTML_TYPE_IFRAME)) {
+                       return html_object_get_engine (parent, NULL);
+                }
+                parent = parent->parent;
+        }
+                                                                                
+        return NULL;
+}
+
 void
 html_engine_hide_cursor  (HTMLEngine *engine)
 {
+	HTMLEngine *e = engine;
+
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
 
-	if (engine->editable && engine->cursor_hide_count == 0)
-		html_engine_draw_cursor_in_area (engine, 0, 0, -1, -1);
+	if ((engine->editable || engine->caret_mode) && engine->cursor_hide_count == 0) {
+		if (!engine->editable) {
+        		e = get_direct_engine(engine->cursor->object);
+			if (e) {
+				e->caret_mode = engine->caret_mode;
+				html_cursor_copy(e->cursor, engine->cursor);
+			} else 	e = engine;
+		}
+		html_engine_draw_cursor_in_area (e, 0, 0, -1, -1);
+	}
 
 	engine->cursor_hide_count++;
 }
 
 void
 html_engine_show_cursor  (HTMLEngine *engine)
 {
+        HTMLEngine * e = engine;
+
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
+	g_return_if_fail (engine->cursor != NULL);
 
 	if (engine->cursor_hide_count > 0) {
 		engine->cursor_hide_count--;
-		if (engine->editable && engine->cursor_hide_count == 0)
-			html_engine_draw_cursor_in_area (engine, 0, 0, -1, -1);
+		if ((engine->editable || engine->caret_mode) && engine->cursor_hide_count == 0) {
+			if (!engine->editable) {
+        			e = get_direct_engine(engine->cursor->object);
+				if (e) {
+					e->caret_mode = engine->caret_mode;
+					html_cursor_copy(e->cursor, engine->cursor);
+				} else e = engine;
+			}
+			html_engine_draw_cursor_in_area (e, 0, 0, -1, -1);
+		}
 	}
 }
 
 static gboolean
 clip_rect (HTMLEngine *engine, gint x, gint y, gint width, gint height, gint *x1, gint *y1, gint *x2, gint *y2)
 {
-	if (*x1 >= x + width || *y1 >= y + height || *x2 < x || *y2 < y)
+	if (*x1 > x + width || *y1 > y + height || *x2 < x || *y2 < y)
 		return FALSE;
 
+	if (*x1 == x + width)
+		*x1 = x + width - 1;
+	if (*y1 == y + width)
+		*y1 = y + height - 1;
 	if (*x2 >= x + width)
 		*x2 = x + width - 1;
 	if (*y2 >= y + height)
 		*y2 = y + height - 1;
@@ -264,17 +308,15 @@
 	guint offset;
 	gint x1, y1, x2, y2;
 	GdkRectangle pos;
 
-	g_assert (engine->editable);
-
-	if (engine->editable && (engine->cursor_hide_count <= 0 && !engine->thaw_idle_id)) {
+	if ((engine->editable || engine->caret_mode) && (engine->cursor_hide_count <= 0 && !engine->thaw_idle_id)) {
 		html_engine_draw_table_cursor (engine);
 		html_engine_draw_cell_cursor (engine);
 		html_engine_draw_image_cursor (engine);
 	}
 
-	if (!cursor_enabled || engine->cursor_hide_count > 0 || ! engine->editable || engine->thaw_idle_id)
+	if (!cursor_enabled || engine->cursor_hide_count > 0 || !(engine->editable || engine->caret_mode) || engine->thaw_idle_id)
 		return;
 
 	obj = engine->cursor->object;
 	if (obj == NULL)
@@ -288,16 +330,25 @@
 		x = 0;
 		y = 0;
 	}
 
-	
 	html_object_get_cursor (obj, engine->painter, offset, &x1, &y1, &x2, &y2);
-	
 	pos.x = x1; 
 	pos.y = y1;
 	pos.width = x2 - x1;
 	pos.height = x2 - x1;
 	gtk_im_context_set_cursor_location (GTK_HTML (engine->widget)->priv->im_context, &pos);
+
+	obj = g_object_get_data(G_OBJECT(gtk_widget_get_parent(GTK_WIDGET(engine->widget))), "embeddedelement");	
+	if (obj) {
+		HTMLEmbedded * element;
+
+		element = HTML_EMBEDDED(obj);
+		x1 -= element->abs_x;
+		x2 -= element->abs_x;
+		y1 -= element->abs_y;
+		y2 -= element->abs_y;
+	}
 
 	if (clip_rect (engine, x, y, width, height, &x1, &y1, &x2, &y2)) {
 		gdk_draw_line (engine->window, engine->invert_gc, x1, y1, x2, y2);
 	}
Index: src/htmlengine-edit-movement.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-movement.c,v
retrieving revision 1.15
diff -u -4 -r1.15 htmlengine-edit-movement.c
--- src/htmlengine-edit-movement.c	25 Apr 2001 21:31:53 -0000	1.15
+++ src/htmlengine-edit-movement.c	27 Jun 2003 05:00:47 -0000
@@ -274,10 +274,12 @@
 		   now.  */
 		if (new_y == y)
 			break;
 
-		if (new_y < start_y)
+		if (new_y < start_y) {
+			html_engine_show_cursor (engine);
 			return 0;
+		}
 
 		if (new_y - start_y >= amount) {
 			html_cursor_copy (cursor, &prev_cursor);
 			break;
Index: src/htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.545
diff -u -4 -r1.545 htmlengine.c
--- src/htmlengine.c	25 Jun 2003 18:15:46 -0000	1.545
+++ src/htmlengine.c	27 Jun 2003 05:01:10 -0000
@@ -3582,8 +3582,9 @@
 	engine->newPage = FALSE;
 	engine->allow_frameset = FALSE;
 
 	engine->editable = FALSE;
+	engine->caret_mode = FALSE;
 	engine->clipboard = NULL;
 	engine->clipboard_stack = NULL;
 	engine->selection_stack  = NULL;
 
@@ -4602,14 +4603,16 @@
 	if (editable) {
 		html_engine_ensure_editable (e);
 		html_cursor_home (e->cursor, e);
 		e->newPage = FALSE;
-
 		if (e->have_focus)
 			html_engine_setup_blinking_cursor (e);
 	} else {
-		if (e->have_focus)
-			html_engine_stop_blinking_cursor (e);
+		if (e->have_focus )
+			if (e->caret_mode)
+				html_engine_setup_blinking_cursor (e);
+			else 
+				html_engine_stop_blinking_cursor (e);
 	}
 }
 
 gboolean
@@ -4639,9 +4642,9 @@
 {
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (HTML_IS_ENGINE (engine));
 
-	if (engine->editable) {
+	if (engine->editable || engine->caret_mode) {
 		if (! engine->have_focus && have_focus)
 			html_engine_setup_blinking_cursor (engine);
 		else if (engine->have_focus && ! have_focus)
 			html_engine_stop_blinking_cursor (engine);
@@ -4678,11 +4681,8 @@
 {
 	gint x1, y1, x2, y2, xo, yo;
 
 	g_return_val_if_fail (e != NULL, FALSE);
-
-	if (! e->editable)
-		return FALSE;
 
 	if (e->cursor->object == NULL)
 		return FALSE;
 
Index: src/htmlengine.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.h,v
retrieving revision 1.168
diff -u -4 -r1.168 htmlengine.h
--- src/htmlengine.h	19 May 2003 12:58:36 -0000	1.168
+++ src/htmlengine.h	27 Jun 2003 05:01:11 -0000
@@ -64,8 +64,9 @@
 	GdkWindow *window;
 	GdkGC *invert_gc;
 
 	gboolean editable;
+	gboolean caret_mode;
 
 	HTMLObject *clipboard;
 	guint       clipboard_len;
 	GList      *clipboard_stack;
Index: src/htmliframe.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmliframe.c,v
retrieving revision 1.74
diff -u -4 -r1.74 htmliframe.c
--- src/htmliframe.c	19 May 2003 13:12:04 -0000	1.74
+++ src/htmliframe.c	27 Jun 2003 05:01:13 -0000
@@ -591,8 +591,9 @@
 	html_iframe_set_scrolling (iframe, GTK_POLICY_AUTOMATIC);
 
 	new_widget = gtk_html_new ();
 	new_html = GTK_HTML (new_widget);
+	new_html->engine->cursor_hide_count = 0;
 
 	new_tokenizer = html_tokenizer_clone (parent_html->engine->ht);
 
 	html_engine_set_tokenizer (new_html->engine, new_tokenizer);


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