Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.8351
diff -u -p -r1.8351 ChangeLog
--- ChangeLog	13 Sep 2006 17:23:11 -0000	1.8351
+++ ChangeLog	14 Sep 2006 15:17:02 -0000
@@ -1,3 +1,10 @@
+2006-09-14  Ryan Lortie  <desrt@desrt.ca>
+
+	* gdk/gdkpango.h:
+	* gdk/gdkpango.c: Bug 355343.  Add a GdkPangoAttrEmbossColor.
+	  (gdk_pango_layout_get_clip_region): Remove an unused variable.
+	  (gdk_pango_attr_embossed_new): Fix documentation.
+
 2006-09-13 Matthias Clasen <mclasen@redhat.com>
 
 	* gtk/gtkcolorsel.c: Use a GtkWindow instead of a GtkInvisible
Index: gdk/gdkpango.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpango.c,v
retrieving revision 1.58
diff -u -p -r1.58 gdkpango.c
--- gdk/gdkpango.c	10 Sep 2006 06:39:14 -0000	1.58
+++ gdk/gdkpango.c	14 Sep 2006 15:17:05 -0000
@@ -48,6 +48,7 @@ struct _GdkPangoRendererPrivate
   gboolean override_color_set[MAX_RENDER_PART + 1];
   
   GdkBitmap *stipple[MAX_RENDER_PART + 1];
+  PangoColor emboss_color;
   gboolean embossed;
 
   cairo_t *cr;
@@ -62,6 +63,7 @@ struct _GdkPangoRendererPrivate
 
 static PangoAttrType gdk_pango_attr_stipple_type;
 static PangoAttrType gdk_pango_attr_embossed_type;
+static PangoAttrType gdk_pango_attr_emboss_color_type;
 
 enum {
   PROP_0,
@@ -115,9 +117,11 @@ gdk_pango_renderer_constructor (GType   
 /* Adjusts matrix and color for the renderer to draw the secondary
  * "shadow" copy for embossed text */
 static void
-emboss_context (cairo_t *cr)
+emboss_context (GdkPangoRenderer *renderer, cairo_t *cr)
 {
+  GdkPangoRendererPrivate *priv = renderer->priv;
   cairo_matrix_t tmp_matrix;
+  double red, green, blue;
 
   /* The gymnastics here to adjust the matrix are because we want
    * to offset by +1,+1 in device-space, not in user-space,
@@ -128,11 +132,15 @@ emboss_context (cairo_t *cr)
   tmp_matrix.y0 += 1.0;
   cairo_set_matrix (cr, &tmp_matrix);
 
-  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  red = (double) priv->emboss_color.red / 65535.;
+  green = (double) priv->emboss_color.green / 65535.;
+  blue = (double) priv->emboss_color.blue / 65535.;
+
+  cairo_set_source_rgb (cr, red, green, blue);
 }
 
 static inline gboolean
-color_equal (PangoColor *c1, PangoColor *c2)
+color_equal (const PangoColor *c1, const PangoColor *c2)
 {
   if (!c1 && !c2)
     return TRUE;
@@ -233,12 +241,12 @@ gdk_pango_renderer_draw_glyphs (PangoRen
   if (priv->embossed)
     {
       cairo_save (cr);
-      emboss_context (cr);
+      emboss_context (gdk_renderer, cr);
       cairo_move_to (cr, (double)x / PANGO_SCALE, (double)y / PANGO_SCALE);
       pango_cairo_show_glyph_string (cr, font, glyphs);
       cairo_restore (cr);
     }
-  
+
   cairo_move_to (cr, (double)x / PANGO_SCALE, (double)y / PANGO_SCALE);
   pango_cairo_show_glyph_string (cr, font, glyphs);
 }
@@ -339,7 +347,7 @@ gdk_pango_renderer_draw_rectangle (Pango
   if (priv->embossed && part != PANGO_RENDER_PART_BACKGROUND)
     {
       cairo_save (cr);
-      emboss_context (cr);
+      emboss_context (gdk_renderer, cr);
       cairo_rectangle (cr,
 		       (double)x / PANGO_SCALE, (double)y / PANGO_SCALE,
 		       (double)width / PANGO_SCALE, (double)height / PANGO_SCALE);
@@ -370,7 +378,7 @@ gdk_pango_renderer_draw_error_underline 
   if (priv->embossed)
     {
       cairo_save (cr);
-      emboss_context (cr);
+      emboss_context (gdk_renderer, cr);
       draw_error_underline (cr,
 			    (double)x / PANGO_SCALE, (double)y / PANGO_SCALE,
 			    (double)width / PANGO_SCALE, (double)height / PANGO_SCALE);
@@ -426,12 +434,16 @@ gdk_pango_renderer_prepare_run (PangoRen
   GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer);
   gboolean embossed = FALSE;
   GdkBitmap *stipple = NULL;
+  gboolean changed = FALSE;
+  PangoColor emboss_color;
   GSList *l;
   int i;
-  
-  embossed = FALSE;
-  stipple = NULL;
-  
+
+  /* less expensive than calling pango_color_parse */
+  emboss_color.red = 0xffff;
+  emboss_color.green = 0xffff;
+  emboss_color.blue = 0xffff;
+
   for (l = run->item->analysis.extra_attrs; l; l = l->next)
     {
       PangoAttribute *attr = l->data;
@@ -448,6 +460,10 @@ gdk_pango_renderer_prepare_run (PangoRen
 	{
 	  embossed = ((GdkPangoAttrEmbossed*)attr)->embossed;
 	}
+      else if (attr->klass->type == gdk_pango_attr_emboss_color_type)
+	{
+	  emboss_color = ((GdkPangoAttrEmbossColor*)attr)->color;
+	}
     }
 
   gdk_pango_renderer_set_stipple (gdk_renderer, PANGO_RENDER_PART_FOREGROUND, stipple);
@@ -458,9 +474,18 @@ gdk_pango_renderer_prepare_run (PangoRen
   if (embossed != gdk_renderer->priv->embossed)
     {
       gdk_renderer->priv->embossed = embossed;
-      pango_renderer_part_changed (renderer, PANGO_RENDER_PART_FOREGROUND);
+      changed = TRUE;
+    }
+
+  if (!color_equal (&gdk_renderer->priv->emboss_color, &emboss_color))
+    {
+      gdk_renderer->priv->emboss_color = emboss_color;
+      changed = TRUE;
     }
 
+  if (changed)
+    pango_renderer_part_changed (renderer, PANGO_RENDER_PART_FOREGROUND);
+
   PANGO_RENDERER_CLASS (gdk_pango_renderer_parent_class)->prepare_run (renderer, run);
 
   for (i = 0; i <= MAX_RENDER_PART; i++)
@@ -1091,6 +1116,8 @@ gdk_draw_layout (GdkDrawable     *drawab
   gdk_draw_layout_with_colors (drawable, gc, x, y, layout, NULL, NULL);
 }
 
+/* GdkPangoAttrStipple */
+
 static PangoAttribute *
 gdk_pango_attr_stipple_copy (const PangoAttribute *attr)
 {
@@ -1157,6 +1184,8 @@ gdk_pango_attr_stipple_new (GdkBitmap *s
   return (PangoAttribute *)result;
 }
 
+/* GdkPangoAttrEmbossed */
+
 static PangoAttribute *
 gdk_pango_attr_embossed_copy (const PangoAttribute *attr)
 {
@@ -1183,10 +1212,9 @@ gdk_pango_attr_embossed_compare (const P
 
 /**
  * gdk_pango_attr_embossed_new:
- * @embossed: a bitmap to be set as embossed
+ * @embossed: if the region should be embossed
  *
- * Creates a new attribute containing a embossed bitmap to be used when
- * rendering the text.
+ * Creates a new attribute flagging a region as embossed or not.
  *
  * Return value: new #PangoAttribute
  **/
@@ -1214,6 +1242,72 @@ gdk_pango_attr_embossed_new (gboolean em
   return (PangoAttribute *)result;
 }
 
+/* GdkPangoAttrEmbossColor */
+
+static PangoAttribute *
+gdk_pango_attr_emboss_color_copy (const PangoAttribute *attr)
+{
+  const GdkPangoAttrEmbossColor *old = (const GdkPangoAttrEmbossColor*) attr;
+  GdkPangoAttrEmbossColor *copy;
+
+  copy = g_new (GdkPangoAttrEmbossColor, 1);
+  copy->attr.klass = old->attr.klass;
+  copy->color = old->color;
+
+  return (PangoAttribute *) copy;
+}
+
+static void
+gdk_pango_attr_emboss_color_destroy (PangoAttribute *attr)
+{
+  g_free (attr);
+}
+
+static gboolean
+gdk_pango_attr_emboss_color_compare (const PangoAttribute *attr1,
+                                     const PangoAttribute *attr2)
+{
+  const GdkPangoAttrEmbossColor *c1 = (const GdkPangoAttrEmbossColor*) attr1;
+  const GdkPangoAttrEmbossColor *c2 = (const GdkPangoAttrEmbossColor*) attr2;
+
+  return color_equal (&c1->color, &c2->color);
+}
+
+/**
+ * gdk_pango_attr_emboss_color_new:
+ * @color: a GdkColor representing the color to emboss with
+ *
+ * Creates a new attribute specifying the color to emboss text with.
+ *
+ * Return value: new #PangoAttribute
+ *
+ * Since: 2.12
+ **/
+PangoAttribute *
+gdk_pango_attr_emboss_color_new (const GdkColor *color)
+{
+  GdkPangoAttrEmbossColor *result;
+  
+  static PangoAttrClass klass = {
+    0,
+    gdk_pango_attr_emboss_color_copy,
+    gdk_pango_attr_emboss_color_destroy,
+    gdk_pango_attr_emboss_color_compare
+  };
+
+  if (!klass.type)
+    klass.type = gdk_pango_attr_emboss_color_type =
+      pango_attr_type_register ("GdkPangoAttrEmbossColor");
+
+  result = g_new (GdkPangoAttrEmbossColor, 1);
+  result->attr.klass = &klass;
+  result->color.red = color->red;
+  result->color.green = color->green;
+  result->color.blue = color->blue;
+
+  return (PangoAttribute *) result;
+}
+
 /* Get a clip region to draw only part of a layout. index_ranges
  * contains alternating range starts/stops. The region is the
  * region which contains the given ranges, i.e. if you draw with the
@@ -1366,7 +1460,6 @@ gdk_pango_layout_get_clip_region (PangoL
   do
     {
       PangoRectangle logical_rect;
-      PangoLayoutLine *line;
       GdkRegion *line_region;
       gint baseline;
       
Index: gdk/gdkpango.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpango.h,v
retrieving revision 1.9
diff -u -p -r1.9 gdkpango.h
--- gdk/gdkpango.h	12 Jun 2005 05:32:24 -0000	1.9
+++ gdk/gdkpango.h	14 Sep 2006 15:17:05 -0000
@@ -133,6 +133,7 @@ GdkRegion    *gdk_pango_layout_get_clip_
 
 typedef struct _GdkPangoAttrStipple GdkPangoAttrStipple;
 typedef struct _GdkPangoAttrEmbossed GdkPangoAttrEmbossed;
+typedef struct _GdkPangoAttrEmbossColor GdkPangoAttrEmbossColor;
 
 struct _GdkPangoAttrStipple
 {
@@ -146,8 +147,15 @@ struct _GdkPangoAttrEmbossed
   gboolean embossed;
 };
 
+struct _GdkPangoAttrEmbossColor
+{
+  PangoAttribute attr;
+  PangoColor color;
+};
+
 PangoAttribute *gdk_pango_attr_stipple_new  (GdkBitmap *stipple);
 PangoAttribute *gdk_pango_attr_embossed_new (gboolean embossed);
+PangoAttribute *gdk_pango_attr_emboss_color_new (const GdkColor *color);
 
 G_END_DECLS
 
