[evolution-patches] [Fwd: [gtkhtml] color fixes]



Looks like that mail didn't make it to the list (and probably to Rodrigo and Rodney) first time => resending.
--- Begin Message ---
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2107
diff -u -p -r1.2107 ChangeLog
--- ChangeLog	16 Mar 2005 07:47:58 -0000	1.2107
+++ ChangeLog	16 Mar 2005 10:47:25 -0000
@@ -1,3 +1,14 @@
+2005-03-16  Radek Doulik  <rodo novell com>
+
+	* whenever getting engine from painter, use html_object_engine to
+	retrieve the right engine for that object as painters are shared
+	between different frame level engines
+
+	* htmlgdkpainter.c (draw_glyphs): use pen color, only set fg color
+	if overriden by pango attributes or passed color
+
+	* htmltextslave.c (draw_text): set pen color before drawing glyphs
+
 2005-03-15  Radek Doulik  <rodo novell com>
 
 	* htmltext.c (prepare_attrs): add size attributes in case
Index: htmlclueflow.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclueflow.c,v
retrieving revision 1.321
diff -u -p -r1.321 htmlclueflow.c
--- htmlclueflow.c	28 Feb 2005 15:36:25 -0000	1.321
+++ htmlclueflow.c	16 Mar 2005 10:47:28 -0000
@@ -1209,7 +1209,7 @@ draw_quotes (HTMLObject *self, HTMLPaint
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (self, GTK_HTML (painter->widget)->engine);
 	else
 		return;
 	
@@ -1280,7 +1280,7 @@ draw_item (HTMLObject *self, HTMLPainter
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (self, GTK_HTML (painter->widget)->engine);
 	else
 		return;
 
Index: htmlcluev.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlcluev.c,v
retrieving revision 1.81
diff -u -p -r1.81 htmlcluev.c
--- htmlcluev.c	3 Feb 2005 17:18:43 -0000	1.81
+++ htmlcluev.c	16 Mar 2005 10:47:30 -0000
@@ -431,9 +431,12 @@ draw (HTMLObject *o,
 		if (cluev->border_color) {
 			html_painter_alloc_color (p, &cluev->border_color->color);
 			color = &cluev->border_color->color;
-		} else
-			color = &html_colorset_get_color_allocated (GTK_HTML (p->widget)->engine->settings->color_set,
+		} else {
+			HTMLEngine *e = html_object_engine (o, GTK_HTML (p->widget)->engine);
+			color = &html_colorset_get_color_allocated (e->settings->color_set,
 								    p, HTMLTextColor)->color;
+		}
+
 		html_painter_draw_border (p, color,
 					  tx, ty, 
 					  o->width,
Index: htmlgdkpainter.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlgdkpainter.c,v
retrieving revision 1.147
diff -u -p -r1.147 htmlgdkpainter.c
--- htmlgdkpainter.c	25 Jan 2005 15:09:40 -0000	1.147
+++ htmlgdkpainter.c	16 Mar 2005 10:47:31 -0000
@@ -721,16 +721,13 @@ set_gdk_color_from_pango_color (GdkColor
 }
      
 static void
-set_item_gc (HTMLPainter *p, HTMLPangoProperties *properties, GdkColor *fg_color, GdkColor **bg_color)
+set_item_gc (HTMLPainter *p, HTMLPangoProperties *properties, GdkColor **fg_color, GdkColor **bg_color)
 {
-	HTMLEngine *e = GTK_HTML (p->widget)->engine;
-
 	if (properties->fg_color) {
-		set_gdk_color_from_pango_color (fg_color, properties->fg_color);
-	} else {
-		*fg_color = html_colorset_get_color_allocated (e->settings->color_set,
-							       e->painter, HTMLTextColor)->color;
-	}
+		*fg_color = g_new0 (GdkColor, 1);
+		set_gdk_color_from_pango_color (*fg_color, properties->fg_color);
+	} else
+		*fg_color = NULL;
 
 	if (properties->bg_color) {
 		*bg_color = g_new0 (GdkColor, 1);
@@ -767,7 +764,7 @@ draw_glyphs (HTMLPainter *painter, gint 
 	HTMLGdkPainter *gdk_painter;
 	guint i;
 	HTMLPangoProperties properties;
-	GdkColor fg_text_color;
+	GdkColor *fg_text_color;
 	GdkColor *bg_text_color;
 	gint cw = 0;
 
@@ -780,8 +777,6 @@ draw_glyphs (HTMLPainter *painter, gint 
 
 	set_item_gc (painter, &properties, &fg_text_color, &bg_text_color);
 
-	if (fg)
-		gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg);
 
 	if (bg_text_color || bg) {
 		PangoRectangle log_rect;
@@ -795,10 +790,13 @@ draw_glyphs (HTMLPainter *painter, gint 
 		gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, TRUE, x, y - PANGO_PIXELS (PANGO_ASCENT (log_rect)),
 				    PANGO_PIXELS (log_rect.width), PANGO_PIXELS (log_rect.height));
 	}
-	if (fg)
-		gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg);
-	else
-		gdk_gc_set_rgb_fg_color (gdk_painter->gc, &fg_text_color);
+
+	if (fg_text_color || fg) {
+		if (fg)
+			gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg);
+		else
+			gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg_text_color);
+	}
 
 	gdk_draw_glyphs (gdk_painter->pixmap, gdk_painter->gc,
 			 item->analysis.font, x, y, glyphs);
@@ -807,6 +805,9 @@ draw_glyphs (HTMLPainter *painter, gint 
 	else
 		for (i=0; i < glyphs->num_glyphs; i ++)
 			cw += glyphs->glyphs [i].geometry.width;
+
+	if (fg_text_color)
+		g_free (fg_text_color);
 
 	if (bg_text_color)
 		g_free (bg_text_color);
Index: htmlimage.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlimage.c,v
retrieving revision 1.208
diff -u -p -r1.208 htmlimage.c
--- htmlimage.c	23 Nov 2004 14:06:21 -0000	1.208
+++ htmlimage.c	16 Mar 2005 10:47:35 -0000
@@ -350,7 +350,7 @@ draw_plain (HTMLObject *o, HTMLPainter *
 	HTMLEngine *e;
 
 	if (p->widget && GTK_IS_HTML (p->widget))
-		e = GTK_HTML (p->widget)->engine;
+		e = html_object_engine (o, GTK_HTML (p->widget)->engine);
 	else
 		return;
 
@@ -380,7 +380,7 @@ draw_plain (HTMLObject *o, HTMLPainter *
 }
 
 static void
-draw_focus  (HTMLPainter *painter, GdkRectangle *box)
+draw_focus  (HTMLImage *image, HTMLPainter *painter, GdkRectangle *box)
 {
 	HTMLGdkPainter *p;
 	GdkGCValues values;
@@ -388,7 +388,7 @@ draw_focus  (HTMLPainter *painter, GdkRe
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (HTML_OBJECT (image), GTK_HTML (painter->widget)->engine);
 	else
 		return;
 
@@ -428,7 +428,7 @@ draw (HTMLObject *o,
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (o, GTK_HTML (painter->widget)->engine);
 	else
 		return;
 
@@ -517,7 +517,7 @@ draw (HTMLObject *o,
 			rect.width = scale_width + (2 * image->border) * pixel_size;
 			rect.height = scale_height + (2 * image->border) * pixel_size;
 
-			draw_focus (painter, &rect);
+			draw_focus (image, painter, &rect);
 		}				     
 
 		return;
@@ -554,7 +554,7 @@ draw (HTMLObject *o,
 		rect.width = scale_width + (2 * image->border) * pixel_size;
 		rect.height = scale_height + (2 * image->border) * pixel_size;
 
-		draw_focus (painter, &rect);
+		draw_focus (image, painter, &rect);
 	}
 }
 
Index: htmlobject.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlobject.c,v
retrieving revision 1.189
diff -u -p -r1.189 htmlobject.c
--- htmlobject.c	11 Mar 2005 15:16:10 -0000	1.189
+++ htmlobject.c	16 Mar 2005 10:47:47 -0000
@@ -322,9 +322,11 @@ get_bg_color (HTMLObject *o,
 	if (o->parent)
 		return html_object_get_bg_color (o->parent, p);	
 
-	if (p->widget && GTK_IS_HTML (p->widget))
-		return &((html_colorset_get_color (GTK_HTML (p->widget)->engine->settings->color_set,
-						   HTMLBgColor))->color);
+	if (p->widget && GTK_IS_HTML (p->widget)) {
+		HTMLEngine *e = html_object_engine (o, GTK_HTML (p->widget)->engine);
+		return &((html_colorset_get_color (e->settings->color_set, HTMLBgColor))->color);
+	}
+
 	return NULL;
 }
 
Index: htmlrule.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlrule.c,v
retrieving revision 1.40
diff -u -p -r1.40 htmlrule.c
--- htmlrule.c	19 Nov 2004 10:19:52 -0000	1.40
+++ htmlrule.c	16 Mar 2005 10:47:48 -0000
@@ -149,7 +149,7 @@ html_rule_draw (HTMLObject *o,
 	HTMLEngine *e;
 
 	if (p->widget && GTK_IS_HTML (p->widget))
-		e = GTK_HTML (p->widget)->engine;
+		e = html_object_engine (o, GTK_HTML (p->widget)->engine);
 	else
 		return;
 
Index: htmltext.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltext.c,v
retrieving revision 1.278
diff -u -p -r1.278 htmltext.c
--- htmltext.c	16 Mar 2005 07:47:58 -0000	1.278
+++ htmltext.c	16 Mar 2005 10:47:52 -0000
@@ -1187,7 +1187,7 @@ prepare_attrs (HTMLText *text, HTMLPaint
 		flow = HTML_CLUEFLOW (HTML_OBJECT (text)->parent);
 		
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (HTML_OBJECT (text), GTK_HTML (painter->widget)->engine);
 
 	if (flow && e)
 		html_text_add_cite_color (attrs, text, flow, e);
@@ -1217,7 +1217,7 @@ prepare_attrs (HTMLText *text, HTMLPaint
 		pango_attr_list_splice (attrs, text->extra_attr_list, 0, 0);
 	if (!HTML_IS_PLAIN_PAINTER (painter)) {
 		if (flow && e)
-			html_text_change_attrs (attrs, html_clueflow_get_default_font_style (flow), GTK_HTML (painter->widget)->engine, 0, text->text_bytes, TRUE);
+			html_text_change_attrs (attrs, html_clueflow_get_default_font_style (flow), e, 0, text->text_bytes, TRUE);
 	}
 
 	if (text->links && e) {
Index: htmltextslave.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltextslave.c,v
retrieving revision 1.190
diff -u -p -r1.190 htmltextslave.c
--- htmltextslave.c	14 Mar 2005 18:36:14 -0000	1.190
+++ htmltextslave.c	16 Mar 2005 10:47:55 -0000
@@ -747,7 +747,7 @@ draw_text (HTMLTextSlave *self,
 	selection = isect_start < isect_end;
 
 	if (p->widget && GTK_IS_HTML (p->widget))
-		e = GTK_HTML (p->widget)->engine;
+		e = html_object_engine (HTML_OBJECT (self->owner), GTK_HTML (p->widget)->engine);
 
 	if (selection) {
 		gchar *end;
@@ -777,6 +777,9 @@ draw_text (HTMLTextSlave *self,
 		GList *cur_se;
 		int cur_width;
 
+		if (e)
+			html_painter_set_pen (p, &html_colorset_get_color_allocated (e->settings->color_set,
+										     e->painter, HTMLTextColor)->color);
 		cur_width = html_painter_draw_glyphs (p, obj->x + tx + html_painter_pango_to_engine (p, run_width),
 						      obj->y + ty + get_ys (text, p), gi->glyph_item.item, gi->glyph_item.glyphs, NULL, NULL);
 
@@ -841,7 +844,7 @@ draw_text (HTMLTextSlave *self,
 }
 
 static void
-draw_focus_rectangle  (HTMLPainter *painter, GdkRectangle *box)
+draw_focus_rectangle  (HTMLTextSlave *slave, HTMLPainter *painter, GdkRectangle *box)
 {
 	HTMLGdkPainter *p;
 	GdkGCValues values;
@@ -849,7 +852,7 @@ draw_focus_rectangle  (HTMLPainter *pain
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
-		e = GTK_HTML (painter->widget)->engine;
+		e = html_object_engine (HTML_OBJECT (slave->owner), GTK_HTML (painter->widget)->engine);
 	else
 		return;
 
@@ -889,7 +892,7 @@ draw_focus (HTMLTextSlave *slave, HTMLPa
 			rect.width -= html_text_calc_part_width (slave->owner, p, slave->owner->text + link->end_index, link->end_offset,
 								 slave->posStart + slave->posLen - link->end_offset, NULL, NULL);
 		rect.y += ty;
-		draw_focus_rectangle (p, &rect);
+		draw_focus_rectangle (slave, p, &rect);
 	}
 }
 

--- End Message ---


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