--- libgnomeprintui/ChangeLog	Wed Oct 23 13:54:11 2002
+++ libgnomeprintui-new/ChangeLog	Thu Oct 24 10:34:49 2002
@@ -1,3 +1,8 @@
+2002-10-23  Pasupathi Duraisamy <pasupathi.duraisamy@wipro.com>
+
+	* libgnomeprintui/gnome-print-paper-selector.c: Assign colors for Paper preview
+	from theme. Partially fixes #90313.
+
 2002-09-15  Chema Celorio  <chema@ximian.com>
 
 	* configure.in: 1.116.1 here we go
--- libgnomeprintui/libgnomeprintui/gnome-print-paper-selector.c	Wed Oct 23 13:54:13 2002
+++ libgnomeprintui-new/libgnomeprintui/gnome-print-paper-selector.c	Thu Oct 24 11:16:23 2002
@@ -91,17 +91,23 @@ void gnome_paper_preview_item_set_layout
 #define MM(v) ((v) * 72.0 / 25.4)
 #define CM(v) ((v) * 72.0 / 2.54)
 #define M(v) ((v) * 72.0 / 0.0254)
+#define GDK_COLOR_RGBA(color, ALPHA)                                        \
+                               ((guint32) (ALPHA                          | \
+                                          (((color).red / 256) << 24)     | \
+                                          (((color).green / 256) << 16)   | \
+                                          (((color).blue  / 256) << 8)))
 
 #define EPSILON 1e-9
 #define PAD 4
 #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
+#define BORDER_ALPHA_VALUE     0xff
+#define SHADOW_ALPHA_VALUE     0xff
+#define PAGE_ALPHA_VALUE       0xff
+#define PMARGIN_ALPHA_VALUE    0xbf
+#define LMARGIN_ALPHA_VALUE    0xbf
+#define LMARGIN_ALPHA_VALUE_HL 0xff
+#define ARROW_ALPHA_VALUE      0xff
+#define STRIPE_ALPHA_VALUE     0x5f
 
 struct _GnomePaperPreviewItem {
 	GnomeCanvasItem canvasitem;
@@ -154,9 +160,21 @@ static void gppi_vline (GnomeCanvasBuf *
 static void gppi_rect (GnomeCanvasBuf *buf, gint xs, gint ys, gint xe, gint ye, guint32 rgba);
 static void gppi_tvline (GnomeCanvasBuf *buf, gdouble x, gdouble sy, gdouble ey, gdouble *affine, guint32 rgba);
 static void gppi_thline (GnomeCanvasBuf *buf, gdouble y, gdouble sx, gdouble ex, gdouble *affine, guint32 rgba);
+static void style_color_callback(GtkWidget *widget, GtkStyle *ps, void *data);
+static void theme_color_init();
+
 
 static GnomeCanvasItemClass *item_parent_class;
 
+guint32 PAGE_COLOR;
+guint32 BORDER_COLOR;
+guint32 SHADOW_COLOR;
+guint32 ARROW_COLOR;
+guint32 PMARGIN_COLOR;
+guint32 LMARGIN_COLOR;
+guint32 LMARGIN_COLOR_HL;
+guint32 STRIPE_COLOR;
+
 GType
 gnome_paper_preview_item_get_type (void)
 {
@@ -251,6 +269,58 @@ gnome_paper_preview_item_finalize (GObje
 
 #define SQ(v) ((v) * (v))
 
+
+static void 
+theme_color_init (GtkWidget *widget)
+{
+	GdkColor color;
+	GtkStyle *style;
+
+	style = gtk_widget_get_style (widget);
+
+	PAGE_COLOR = 0;
+	color = style->base[GTK_STATE_NORMAL];
+	PAGE_COLOR = GDK_COLOR_RGBA (color, PAGE_ALPHA_VALUE);
+
+	BORDER_COLOR = 0;
+	color = style->text[GTK_STATE_NORMAL];
+	BORDER_COLOR = GDK_COLOR_RGBA (color, BORDER_ALPHA_VALUE);
+
+	SHADOW_COLOR = 0;
+	color = style->bg[GTK_STATE_ACTIVE];
+	SHADOW_COLOR = GDK_COLOR_RGBA (color, SHADOW_ALPHA_VALUE);
+
+	ARROW_COLOR = 0;
+	color = style->base[GTK_STATE_SELECTED];
+	ARROW_COLOR = GDK_COLOR_RGBA (color, ARROW_ALPHA_VALUE);
+
+	PMARGIN_COLOR = 0;
+	color = style->base[GTK_STATE_SELECTED];
+	PMARGIN_COLOR = GDK_COLOR_RGBA (color, PMARGIN_ALPHA_VALUE);
+
+	LMARGIN_COLOR = 0;
+	color = style->bg[GTK_STATE_SELECTED];
+	LMARGIN_COLOR = GDK_COLOR_RGBA (color, LMARGIN_ALPHA_VALUE);
+
+	LMARGIN_COLOR_HL = 0;
+	color = style->bg[GTK_STATE_SELECTED];
+	LMARGIN_COLOR_HL = GDK_COLOR_RGBA (color, LMARGIN_ALPHA_VALUE_HL); 
+
+	STRIPE_COLOR = 0;
+	color = style->text[GTK_STATE_NORMAL];
+	STRIPE_COLOR = GDK_COLOR_RGBA (color, STRIPE_ALPHA_VALUE);
+
+}
+
+static void 
+style_color_callback (GtkWidget *widget, GtkStyle *ps, void *data)
+{
+
+	theme_color_init (widget);
+}
+
+
+
 static void
 gnome_paper_preview_item_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip, gint flags)
 {
@@ -535,7 +605,7 @@ gnome_paper_preview_item_render (GnomeCa
 					r.x1 = pp->lml + CM(5);
 					r.y1 = pp->lmb + y;
 					art_drect_affine_transform (&a, &r, lp2c);
-					gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, 0x0000007f);
+					gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, STRIPE_COLOR);
 					if (w >= CM(7)) {
 						gint l;
 						for (l = 0; l < 3; l++) {
@@ -545,7 +615,7 @@ gnome_paper_preview_item_render (GnomeCa
 							r.x1 = pp->lml + w;
 							r.y1 = pp->lmb + y - l * CM(2) - CM(0.5);
 							art_drect_affine_transform (&a, &r, lp2c);
-							gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, 0x0000005f);
+							gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, STRIPE_COLOR);
 						}
 					}
 					y -= CM(6.5);
@@ -557,7 +627,7 @@ gnome_paper_preview_item_render (GnomeCa
 					r.x1 = pp->lml + w;
 					r.y1 = pp->lmb + y;
 					art_drect_affine_transform (&a, &r, lp2c);
-					gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, 0x0000005f);
+					gppi_rect (buf, a.x0, a.y0, a.x1, a.y1, STRIPE_COLOR);
 					y -= CM(2);
 				}
 			}
@@ -913,6 +983,8 @@ gnome_paper_preview_new (GnomePrintConfi
 	preview = GNOME_PAPER_PREVIEW (gtk_type_new (GNOME_TYPE_PAPER_PREVIEW));
 	item = GNOME_PAPER_PREVIEW_ITEM (preview->item);
 
+	theme_color_init(GTK_WIDGET(preview));
+
 	/* Read out some important values */
 	w = 1;
 	gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAPER_WIDTH, &w, NULL);
@@ -963,6 +1035,8 @@ gnome_paper_preview_new (GnomePrintConfi
 	gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &mb, NULL);
 
 	gnome_paper_preview_item_set_logical_margins (item, ml, mr, mt, mb);
+
+	g_signal_connect (G_OBJECT (preview), "style_set", G_CALLBACK (style_color_callback), preview);
 
 	return GTK_WIDGET(preview);
 }
