? doc/libgnomeprintui-scan.c
? doc/tmpl/gnome-print-job-preview.sgml
? examples/s
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/ChangeLog,v
retrieving revision 1.324
diff -u -r1.324 ChangeLog
--- ChangeLog	8 Dec 2002 03:44:13 -0000	1.324
+++ ChangeLog	8 Dec 2002 04:10:08 -0000
@@ -1,5 +1,8 @@
 2002-12-07  Chema Celorio  <chema@ximian.com>
 
+	* libgnomeprintui/gnome-print-paper-preview.c: Fix #96802
+	* libgnomeprintui/gpaui/gpa-paper-preview-item.c:
+
 	* tests/Makefile.am: link to the 2-2 library
 
 2002-12-04  Chema Celorio  <chema@celorio.com>
Index: libgnomeprintui/gnome-print-paper-preview.c
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gnome-print-paper-preview.c,v
retrieving revision 1.1
diff -u -r1.1 gnome-print-paper-preview.c
--- libgnomeprintui/gnome-print-paper-preview.c	6 Sep 2002 06:01:28 -0000	1.1
+++ libgnomeprintui/gnome-print-paper-preview.c	8 Dec 2002 04:10:08 -0000
@@ -109,8 +109,7 @@
 	preview->canvas = gnome_canvas_new_aa ();
 	gtk_widget_pop_colormap ();
 
-	preview->item = gpa_paper_preview_item_new (config, gnome_canvas_root (GNOME_CANVAS (preview->canvas)));
-
+	preview->item = gpa_paper_preview_item_new (config, preview->canvas);
 	gtk_box_pack_start (GTK_BOX (preview), GTK_WIDGET (preview->canvas), TRUE, TRUE, 0);
 	gtk_widget_show (GTK_WIDGET (preview->canvas));
 
Index: libgnomeprintui/gpaui/gpa-paper-preview-item.c
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gpaui/gpa-paper-preview-item.c,v
retrieving revision 1.4
diff -u -r1.4 gpa-paper-preview-item.c
--- libgnomeprintui/gpaui/gpa-paper-preview-item.c	9 Sep 2002 01:04:01 -0000	1.4
+++ libgnomeprintui/gpaui/gpa-paper-preview-item.c	8 Dec 2002 04:10:08 -0000
@@ -45,7 +45,7 @@
 
 typedef struct _GpaPaperPreviewItemClass GpaPaperPreviewItemClass;
 
-GnomeCanvasItem * gpa_paper_preview_item_new (GnomePrintConfig *config, GnomeCanvasGroup *parent);
+GnomeCanvasItem * gpa_paper_preview_item_new (GnomePrintConfig *config, GtkWidget *canvas);
 
 void gpa_paper_preview_item_set_physical_size        (GpaPaperPreviewItem *item, gdouble width, gdouble height);
 void gpa_paper_preview_item_set_physical_orientation (GpaPaperPreviewItem *item, const gdouble *orientation);
@@ -61,13 +61,6 @@
 #define PAD 4
 #define EPSILON 1e-9
 #define SHADOW_SIZE 5
-#define BORDER_COLOR  0x000000ff
-#define SHADOW_COLOR  0x00003fff
-#define PAGE_COLOR    0xffffdfff
-#define PMARGIN_COLOR 0xff0000bf
-#define LMARGIN_COLOR 0x0000ffbf
-#define LMARGIN_COLOR_HL 0xaa0000ff
-#define ARROW_COLOR   0xff7f003f
 
 struct _GpaPaperPreviewItem {
 	GnomeCanvasItem canvasitem;
@@ -105,6 +98,16 @@
 
 	GnomePrintConfig *config;
 
+	/* Colors */
+	guint32 color_page;
+	guint32 color_border;
+	guint32 color_shadow;
+	guint32 color_arrow;
+	guint32 color_pmargin;
+	guint32 color_lmargin;
+	guint32 color_lmargin_hl;
+	guint32 color_stripe;
+
 	/* Needed so that we can disconect after use */
 	GPANode *node_media, *node_printer, *node_page;
 	guint handler_media, handler_printer, handler_page;
@@ -446,47 +449,47 @@
 		buf->is_buf = TRUE;
 		buf->is_bg = FALSE;
 		/* Top */
-		gppi_hline (buf, pp->area.y0, pp->area.x0, pp->area.x1, BORDER_COLOR);
+		gppi_hline (buf, pp->area.y0, pp->area.x0, pp->area.x1, pp->color_border);
 		/* Bottom */
-		gppi_hline (buf, pp->area.y1, pp->area.x0, pp->area.x1, BORDER_COLOR);
+		gppi_hline (buf, pp->area.y1, pp->area.x0, pp->area.x1, pp->color_border);
 		/* Left */
-		gppi_vline (buf, pp->area.x0, pp->area.y0 + 1, pp->area.y1 - 1, BORDER_COLOR);
+		gppi_vline (buf, pp->area.x0, pp->area.y0 + 1, pp->area.y1 - 1, pp->color_border);
 		/* Right */
-		gppi_vline (buf, pp->area.x1, pp->area.y0 + 1, pp->area.y1 - 1, BORDER_COLOR);
+		gppi_vline (buf, pp->area.x1, pp->area.y0 + 1, pp->area.y1 - 1, pp->color_border);
 		/* Shadow */
 		if (SHADOW_SIZE > 0) {
 			/* Right */
 			gppi_rect (buf, pp->area.x1 + 1, pp->area.y0 + SHADOW_SIZE,
-				   pp->area.x1 + SHADOW_SIZE, pp->area.y1 + SHADOW_SIZE, SHADOW_COLOR);
+				   pp->area.x1 + SHADOW_SIZE, pp->area.y1 + SHADOW_SIZE, pp->color_shadow);
 			/* Bottom */
 			gppi_rect (buf, pp->area.x0 + SHADOW_SIZE, pp->area.y1 + 1,
-				   pp->area.x1, pp->area.y1 + SHADOW_SIZE, SHADOW_COLOR);
+				   pp->area.x1, pp->area.y1 + SHADOW_SIZE, pp->color_shadow);
 		}
 		/* Fill */
 		gppi_rect (buf, pp->area.x0 + 1, pp->area.y0 + 1,
-			   pp->area.x1 - 1, pp->area.y1 - 1, PAGE_COLOR);
+			   pp->area.x1 - 1, pp->area.y1 - 1, pp->color_page);
 
 		/* Arrows */
 		if (pp->up)
-			gnome_canvas_render_svp (buf, pp->up, ARROW_COLOR);
+			gnome_canvas_render_svp (buf, pp->up, pp->color_arrow);
 		if (pp->right)
-			gnome_canvas_render_svp (buf, pp->right, ARROW_COLOR);
+			gnome_canvas_render_svp (buf, pp->right, pp->color_arrow);
 
 		/* Fun part */
 
 		/* Physical margins */
 		imargin = (gint) fabs (pp->pml * pp->PPDP2C[0]);
 		if (imargin > 0)
-			gppi_vline (buf, pp->area.x0 + imargin, pp->area.y0 + 1, pp->area.y1 - 1, PMARGIN_COLOR);
+			gppi_vline (buf, pp->area.x0 + imargin, pp->area.y0 + 1, pp->area.y1 - 1, pp->color_pmargin);
 		imargin = (gint) fabs (pp->pmr * pp->PPDP2C[0]);
 		if (imargin > 0)
-			gppi_vline (buf, pp->area.x1 - imargin, pp->area.y0 + 1, pp->area.y1 - 1, PMARGIN_COLOR);
+			gppi_vline (buf, pp->area.x1 - imargin, pp->area.y0 + 1, pp->area.y1 - 1, pp->color_pmargin);
 		imargin = (gint) fabs (pp->pmt * pp->PPDP2C[3]);
 		if (imargin > 0)
-			gppi_hline (buf, pp->area.y0 + imargin, pp->area.x0 + 1, pp->area.x1 - 1, PMARGIN_COLOR);
+			gppi_hline (buf, pp->area.y0 + imargin, pp->area.x0 + 1, pp->area.x1 - 1, pp->color_pmargin);
 		imargin = (gint) fabs (pp->pmb * pp->PPDP2C[3]);
 		if (imargin > 0)
-			gppi_hline (buf, pp->area.y1 - imargin, pp->area.x0 + 1, pp->area.x1 - 1, PMARGIN_COLOR);
+			gppi_hline (buf, pp->area.y1 - imargin, pp->area.x0 + 1, pp->area.x1 - 1, pp->color_pmargin);
 
 		/* Extra fun */
 
@@ -508,13 +511,13 @@
 
 			/* Draw logical margins */
 			gppi_tvline (buf, pp->lml, 0, pp->LH, lp2c,
-				     pp->lml_hl ? LMARGIN_COLOR_HL : LMARGIN_COLOR);
+				     pp->lml_hl ? pp->color_lmargin_hl : pp->color_lmargin);
 			gppi_tvline (buf, pp->LW - pp->lmr, 0, pp->LH, lp2c,
-				     pp->lmr_hl ? LMARGIN_COLOR_HL : LMARGIN_COLOR);
+				     pp->lml_hl ? pp->color_lmargin_hl : pp->color_lmargin);
 			gppi_thline (buf, pp->LH - pp->lmt, 0, pp->LW, lp2c,
-				     pp->lmt_hl ? LMARGIN_COLOR_HL : LMARGIN_COLOR);
+				     pp->lml_hl ? pp->color_lmargin_hl : pp->color_lmargin);
 			gppi_thline (buf, pp->lmb, 0, pp->LW, lp2c,
-				     pp->lmb_hl ? LMARGIN_COLOR_HL : LMARGIN_COLOR);
+				     pp->lml_hl ? pp->color_lmargin_hl : pp->color_lmargin);
 			/* Render fancy page */
 			w = pp->LW - pp->lml - pp->lmr;
 			h = pp->LH - pp->lmt - pp->lmb;
@@ -752,28 +755,58 @@
 	gpa_paper_preview_item_set_logical_margins (item, ml, mr, mt, mb);
 }
 
+#define PMARGIN_ALPHA_VALUE    0xbf
+#define LMARGIN_ALPHA_VALUE    0xbf
+#define STRIPE_ALPHA_VALUE     0x5f
+#define FULL_ALPHA             0xff
+#define GPA_COLOR_RGBA(color, ALPHA)              \
+		((guint32) (ALPHA               | \
+                (((color).red / 256) << 24)     | \
+                (((color).green / 256) << 16)   | \
+                (((color).blue  / 256) << 8)))
+static void
+gpa_paper_preview_item_load_colors (GpaPaperPreviewItem *item, GtkWidget *widget)
+{
+	GtkStyle *style;
 
+	style = gtk_widget_get_style (widget);
 
+	item->color_page       = GPA_COLOR_RGBA (style->base [GTK_STATE_NORMAL],   FULL_ALPHA);
+	item->color_border     = GPA_COLOR_RGBA (style->text [GTK_STATE_NORMAL],   FULL_ALPHA);
+	item->color_shadow     = GPA_COLOR_RGBA (style->bg   [GTK_STATE_ACTIVE],   FULL_ALPHA);
+	item->color_arrow      = GPA_COLOR_RGBA (style->base [GTK_STATE_SELECTED], FULL_ALPHA);
+	item->color_pmargin    = GPA_COLOR_RGBA (style->base [GTK_STATE_SELECTED], PMARGIN_ALPHA_VALUE);
+	item->color_lmargin    = GPA_COLOR_RGBA (style->bg   [GTK_STATE_SELECTED], LMARGIN_ALPHA_VALUE);
+	item->color_lmargin_hl = GPA_COLOR_RGBA (style->bg   [GTK_STATE_SELECTED], FULL_ALPHA);
+	item->color_stripe     = GPA_COLOR_RGBA (style->text [GTK_STATE_NORMAL],   STRIPE_ALPHA_VALUE);
+}
 
-
+static void 
+gpa_paper_preview_item_style_color_cb (GtkWidget *widget, GtkStyle *ps, GpaPaperPreviewItem *item)
+{
+	gpa_paper_preview_item_load_colors (item, widget);
+}
 
 GnomeCanvasItem *
-gpa_paper_preview_item_new (GnomePrintConfig *config, GnomeCanvasGroup *parent)
+gpa_paper_preview_item_new (GnomePrintConfig *config, GtkWidget *canvas)
 {
 	GpaPaperPreviewItem *pp;
 	GnomeCanvasItem *item;
 	GPANode *node = NULL;
 
 	g_return_val_if_fail (config != NULL, NULL);
-	g_return_val_if_fail (parent != NULL, NULL);
+	g_return_val_if_fail (canvas != NULL, NULL);
+	g_return_val_if_fail (GNOME_IS_CANVAS (canvas), NULL);
 	
-	item = gnome_canvas_item_new (parent, GPA_TYPE_PAPER_PREVIEW_ITEM, NULL);
+	item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)), GPA_TYPE_PAPER_PREVIEW_ITEM, NULL);
 	pp = GPA_PAPER_PREVIEW_ITEM (item);
 
 	pp->config = gnome_print_config_ref (config);
-	
-	gpa_paper_preview_item_reload_values (node, 0, pp);
 
+	gpa_paper_preview_item_load_colors (pp, canvas);
+	g_signal_connect (G_OBJECT (canvas), "style_set", G_CALLBACK (gpa_paper_preview_item_style_color_cb), pp);
+	gpa_paper_preview_item_reload_values (node, 0, pp);
+	
 	node = gpa_node_get_child_from_path (GNOME_PRINT_CONFIG_NODE (config), "Printer");
 	if (node) {
 		pp->node_printer = node;
@@ -792,7 +825,6 @@
 		pp->handler_page = g_signal_connect (G_OBJECT (node), "modified",
 						     (GCallback) gpa_paper_preview_item_reload_values, pp);
 	}
-	
 
 	return item;
 }
Index: libgnomeprintui/gpaui/gpa-paper-preview-item.h
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gpaui/gpa-paper-preview-item.h,v
retrieving revision 1.2
diff -u -r1.2 gpa-paper-preview-item.h
--- libgnomeprintui/gpaui/gpa-paper-preview-item.h	7 Sep 2002 05:35:05 -0000	1.2
+++ libgnomeprintui/gpaui/gpa-paper-preview-item.h	8 Dec 2002 04:10:08 -0000
@@ -45,7 +45,7 @@
 
 GType             gpa_paper_preview_item_get_type (void);
 
-GnomeCanvasItem *  gpa_paper_preview_item_new (GnomePrintConfig *config, GnomeCanvasGroup *parent);
+GnomeCanvasItem *  gpa_paper_preview_item_new (GnomePrintConfig *config, GtkWidget *widget);
 void               gpa_paper_preview_item_set_lm_highlights (GpaPaperPreviewItem *pp,
 							     gboolean mt, gboolean mb, gboolean ml, gboolean mr);
 
