[gtk-theme-engine-clearlooks] Adapt classic clearlooks parameters to take a GtkThemingEngine



commit 8d881a1ebd4858f7fd586aa879c16fa2689e023b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 16 00:51:31 2010 +0100

    Adapt classic clearlooks parameters to take a GtkThemingEngine

 src/clearlooks_draw.c  | 1176 ++++++++++++++++++++++++++++++++----------------
 src/clearlooks_draw.h  |   15 +-
 src/clearlooks_types.h |  117 ++----
 3 files changed, 847 insertions(+), 461 deletions(-)
---
diff --git a/src/clearlooks_draw.c b/src/clearlooks_draw.c
index 80ec9eb..e504af8 100644
--- a/src/clearlooks_draw.c
+++ b/src/clearlooks_draw.c
@@ -39,8 +39,7 @@
 #define SHADE_BOTTOM 0.90
 
 typedef void (*menubar_draw_proto) (cairo_t *cr,
-                                    const ClearlooksColors *colors,
-                                    const WidgetParameters *params,
+				    GtkThemingEngine *engine,
                                     const MenuBarParameters *menubar,
                                     int x, int y, int width, int height);
 
@@ -105,12 +104,13 @@ clearlooks_draw_inset (cairo_t          *cr,
 }
 
 static void
-clearlooks_draw_shadow (cairo_t *cr, const ClearlooksColors *colors, gfloat radius, int width, int height)
+clearlooks_draw_shadow (cairo_t *cr, GtkThemingEngine *engine, gfloat radius, int width, int height)
 {
-	CairoColor shadow;
+	CairoColor shade, shadow;
 	cairo_save (cr);
 
-	ge_shade_color (&colors->shade[6], 0.92, &shadow);
+	clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &shade);
+	ge_shade_color (&shade, 0.92, &shadow);
 
 	cairo_set_line_width (cr, 1.0);
 	cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
@@ -128,16 +128,20 @@ clearlooks_draw_shadow (cairo_t *cr, const ClearlooksColors *colors, gfloat radi
 /* This is copied at least in clearlooks_draw_gummy.c.
  * KEEP IN SYNC IF POSSIBLE! */
 static void
-clearlooks_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
-                                    const WidgetParameters *params,
-                                    int x, int y, int width, int height,
-                                    gdouble radius, CairoCorners corners)
+clearlooks_draw_top_left_highlight (cairo_t *cr,
+				    const CairoColor *color,
+				    GtkThemingEngine *engine,
+                                    int x, int y, int width, int height)
 {
+	ClearlooksEngine *clearlooks_engine;
 	CairoColor hilight;
 
 	double line_width = cairo_get_line_width (cr);
 	double offset = line_width / 2.0;
 	double light_top, light_bottom, light_left, light_right;
+	double radius;
+
+	clearlooks_engine = CLEARLOOKS_ENGINE (engine);
 
 	cairo_save (cr);
 
@@ -147,19 +151,28 @@ clearlooks_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
 	light_bottom = y + height;
 	light_left = x + offset;
 	light_right = x + width;
-	
+
+#if 0
 	if (corners & CR_CORNER_BOTTOMLEFT)
 		light_bottom -= radius;
 	if (corners & CR_CORNER_TOPRIGHT)
 		light_right -= radius;
+#endif
+
+	gtk_theming_engine_get (engine,
+				gtk_theming_engine_get_state (engine),
+				"radius", &radius,
+				NULL);
+
+	ge_shade_color (color, clearlooks_engine->style_constants->topleft_highlight_shade, &hilight);
 
-	ge_shade_color (color, params->style_constants->topleft_highlight_shade, &hilight);
 	cairo_move_to         (cr, light_left, light_bottom);
 
-	ge_cairo_rounded_corner (cr, light_left, light_top, radius, corners & CR_CORNER_TOPLEFT);
+	ge_cairo_rounded_corner (cr, light_left, light_top, radius, 0); //corners & CR_CORNER_TOPLEFT);
 
 	cairo_line_to         (cr, light_right, light_top);
-	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, params->style_constants->topleft_highlight_alpha);
+	cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b,
+			       clearlooks_engine->style_constants->topleft_highlight_alpha);
 	cairo_stroke          (cr);
 
 	cairo_restore (cr);
@@ -240,18 +253,18 @@ clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hil
 }
 
 static void
-clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, int y,
+clearlooks_draw_gripdots (cairo_t *cr, GtkThemingEngine *engine, int x, int y,
                           int width, int height, int xr, int yr,
                           float contrast)
 {
-	const CairoColor *dark = &colors->shade[4];
-	CairoColor hilight;
+	CairoColor dark, hilight;
 	int i, j;
 	int xoff, yoff;
 	int x_start, y_start;
 
-	ge_shade_color (dark, 1.5, &hilight);
-	
+	clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &dark);
+	ge_shade_color (&dark, 1.5, &hilight);
+
 	/* The "- 1" is because there is no space in front of the first dot. */
 	x_start = x + width / 2 - ((xr * 3 - 1) / 2);
 	y_start = y + height / 2 - ((yr * 3 - 1) / 2);
@@ -267,7 +280,7 @@ clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, in
 			cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.8+contrast);
 			cairo_fill (cr);
 			cairo_rectangle (cr, x_start + xoff, y_start + yoff, 1, 1);
-			cairo_set_source_rgba (cr, dark->r, dark->g, dark->b, 0.8+contrast);
+			cairo_set_source_rgba (cr, dark.r, dark.g, dark.b, 0.8+contrast);
 			cairo_fill (cr);
 		}
 	}
@@ -275,45 +288,63 @@ clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, in
 
 static void
 clearlooks_draw_button (cairo_t *cr,
-                        const ClearlooksColors *colors,
-                        const WidgetParameters *params,
+			GtkThemingEngine *engine,
                         int x, int y, int width, int height)
 {
+	ClearlooksStyleFunctions *style_functions;
 	double xoffset = 0, yoffset = 0;
-	double radius = params->radius;
-	const CairoColor *fill = &colors->bg[params->state_type];
-	CairoColor border_normal = colors->shade[6];
-	CairoColor border_disabled = colors->shade[4];
-
+	double radius;
+	GtkStateFlags state;
+	const CairoColor *fill;
+	CairoColor border_normal;
+	CairoColor border_disabled;
 	CairoColor shadow;
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+	clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border_normal);
+	clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &border_disabled);
+
 	ge_shade_color (&border_normal, 1.04, &border_normal);
 	ge_shade_color (&border_normal, 0.94, &shadow);
 	ge_shade_color (&border_disabled, 1.08, &border_disabled);
 
+	state = gtk_theming_engine_get_state (engine);
+
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				"background-color", &fill,
+				NULL);
+
 	cairo_save (cr);
 
 	cairo_translate (cr, x, y);
 	cairo_set_line_width (cr, 1.0);
 
+#if 0
 	if (params->xthickness >= 3 && params->ythickness >= 3)
 	{
 		xoffset = 1;
 		yoffset = 1;
 	}
+#endif
 
 	radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
 
+#if 0
 	if (params->xthickness >= 3 && params->ythickness >= 3)
 	{
-		params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
+		style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
 	}
+#endif
 
 	ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
 	                                     width-(xoffset*2)-2,
 	                                     height-(yoffset*2)-2,
-	                                     radius, params->corners);
+				    radius, 0); //params->corners);
 
-	if (!params->active)
+	if (state & GTK_STATE_FLAG_ACTIVE)
 	{
 		cairo_pattern_t *pattern;
 		CairoColor top_shade, topmiddle_shade, bottom_shade, middle_shade;
@@ -341,9 +372,8 @@ clearlooks_draw_button (cairo_t *cr,
 		cairo_stroke (cr);
 
 		/* Draw topleft shadow */
-		params->style_functions->draw_top_left_highlight (cr, fill, params, xoffset + 1, yoffset + 1,
-		                                                  width - 2*(xoffset + 1), height - 2*(yoffset + 1),
-		                                                  MAX(radius-1, 0), params->corners);
+		style_functions->draw_top_left_highlight (cr, fill, engine, xoffset + 1, yoffset + 1,
+							  width - 2*(xoffset + 1), height - 2*(yoffset + 1));
 
 		cairo_restore (cr);
 	}
@@ -363,14 +393,16 @@ clearlooks_draw_button (cairo_t *cr,
 		cairo_pattern_destroy (pattern);
 
 		pattern	= cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
+		cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b,
+						   (state & GTK_STATE_FLAG_INSENSITIVE) ? 0.125 : 0.32);
 		cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
 		cairo_set_source (cr, pattern);
 		cairo_fill_preserve (cr);
 		cairo_pattern_destroy (pattern);
 
 		pattern	= cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
+		cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b,
+						   (state & GTK_STATE_FLAG_INSENSITIVE) ? 0.125 : 0.32);
 		cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
 		cairo_set_source (cr, pattern);
 		cairo_fill (cr);
@@ -378,22 +410,28 @@ clearlooks_draw_button (cairo_t *cr,
 	}
 
 	/* Drawing the border */
-	if (!params->active && params->is_default)
+	if ((state & GTK_STATE_FLAG_ACTIVE) == 0 &&
+	    gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_DEFAULT))
 	{
 		ge_shade_color (&border_normal, 0.74, &border_normal);
 	}
 
-	ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, params->corners);
+	ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, 0); //params->corners);
 
-	if (params->disabled)
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
 	{
 		ge_cairo_set_color (cr, &border_disabled);
 	}
 	else
 	{
-		if (!params->active)
+		if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
+		{
+			gboolean is_default;
+
+			is_default = gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_DEFAULT);
 			clearlooks_set_border_gradient (cr, &border_normal,
-			                                params->is_default ? 1.1 : 1.3, 0, height);
+			                                is_default ? 1.1 : 1.3, 0, height);
+		}
 		else
 		{
 			ge_shade_color (&border_normal, 1.08, &border_normal);
@@ -408,17 +446,31 @@ clearlooks_draw_button (cairo_t *cr,
 
 static void
 clearlooks_draw_entry (cairo_t *cr,
-                       const ClearlooksColors *colors,
-                       const WidgetParameters *params,
+		       GtkThemingEngine *engine,
                        const FocusParameters  *focus,
                        int x, int y, int width, int height)
 {
-	const CairoColor *base = &colors->base[params->state_type];
-	CairoColor border = colors->shade[params->disabled ? 3 : 6];
-	double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
+	CairoColor *base;
+	CairoColor border;
+	double radius;
 	int xoffset, yoffset;
+	GtkStateFlags state;
+
+	state = gtk_theming_engine_get_state (engine);
 
-	if (params->focus)
+	gtk_theming_engine_get (engine, state,
+				"background-color", &base,
+				"radius", &radius,
+				NULL);
+
+	radius = MIN (radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
+
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
+		clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &border);
+	else
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border);
+
+	if (state & GTK_STATE_FLAG_FOCUSED)
 		border = focus->color;
 
 	cairo_save (cr);
@@ -426,6 +478,7 @@ clearlooks_draw_entry (cairo_t *cr,
 	cairo_translate (cr, x, y);
 	cairo_set_line_width (cr, 1.0);
 
+#if 0
 	if (params->xthickness >= 3 && params->ythickness >= 3)
 	{
 		params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
@@ -433,6 +486,7 @@ clearlooks_draw_entry (cairo_t *cr,
 		yoffset = 1;
 	}
 	else
+#endif
 	{
 		xoffset = 0;
 		yoffset = 0;
@@ -440,13 +494,13 @@ clearlooks_draw_entry (cairo_t *cr,
 
 	/* Now fill the area we want to be base[NORMAL]. */
 	ge_cairo_rounded_rectangle (cr, xoffset + 1, yoffset + 1, width - (xoffset + 1)*2,
-	                            height - (yoffset + 1) * 2, MAX(0, radius-1),
-	                            params->corners);
+	                            height - (yoffset + 1) * 2, MAX(0, radius-1), 0);
+//	                            params->corners);
 	ge_cairo_set_color (cr, base);
 	cairo_fill (cr);
 
 	/* Draw the inner shadow */
-	if (params->focus)
+	if (state & GTK_STATE_FLAG_FOCUSED)
 	{
 		CairoColor focus_shadow;
 		ge_shade_color (&border, 1.61, &focus_shadow);
@@ -454,7 +508,7 @@ clearlooks_draw_entry (cairo_t *cr,
 		clearlooks_set_mixed_color (cr, base, &focus_shadow, 0.5);
 		ge_cairo_inner_rounded_rectangle (cr, xoffset + 1, yoffset + 1,
 		                                  width - (xoffset + 1)*2, height - (yoffset + 1)*2,
-		                                  MAX(0, radius-1), params->corners);
+		                                  MAX(0, radius-1), 0); //params->corners);
 		cairo_stroke (cr);
 	}
 	else
@@ -462,7 +516,8 @@ clearlooks_draw_entry (cairo_t *cr,
 		CairoColor shadow;
 		ge_shade_color (&border, 0.925, &shadow);
 
-		cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.05 : 0.1);
+		cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b,
+				       (state & GTK_STATE_FLAG_INSENSITIVE) ? 0.05 : 0.1);
 
 		cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
 		cairo_move_to (cr, 2.5, height-radius);
@@ -474,43 +529,51 @@ clearlooks_draw_entry (cairo_t *cr,
 
 	ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset,
 	                                  width-2*xoffset, height-2*yoffset,
-	                                  radius, params->corners);
-	if (params->focus || params->disabled)
+	                                  radius, 0); //params->corners);
+	if (state & GTK_STATE_FLAG_FOCUSED ||
+	    state & GTK_STATE_FLAG_INSENSITIVE)
 		ge_cairo_set_color (cr, &border);
 	else
 		clearlooks_set_border_gradient (cr, &border, 1.32, 0, height);
 	cairo_stroke (cr);
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) base);
 }
 
 static void
 clearlooks_draw_entry_progress (cairo_t *cr,
-                                const ClearlooksColors *colors,
-                                const WidgetParameters *params,
+				GtkThemingEngine *engine,
                                 const EntryProgressParameters *progress,
                                 int x, int y, int width, int height)
 {
 	CairoColor border;
-	CairoColor fill;
+	CairoColor *fill;
 	gint entry_width, entry_height;
+	GtkStateFlags state;
 	double entry_radius;
 	double radius;
 
 	cairo_save (cr);
 
-	fill = colors->bg[params->state_type];
-	ge_shade_color (&fill, 0.9, &border);
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"background-color", &fill,
+				"border-radius", &radius,
+				NULL);
+
+	ge_shade_color (fill, 0.9, &border);
 
 	if (progress->max_size_known)
 	{
 		entry_width = progress->max_size.width + progress->border.left + progress->border.right;
 		entry_height = progress->max_size.height + progress->border.top + progress->border.bottom;
-		entry_radius = MIN (params->radius, MIN ((entry_width - 4.0) / 2.0, (entry_height - 4.0) / 2.0));
+		entry_radius = MIN (radius, MIN ((entry_width - 4.0) / 2.0, (entry_height - 4.0) / 2.0));
 	}
 	else
 	{
-		entry_radius = params->radius;
+		entry_radius = radius;
 	}
 
 	radius = MAX (0, entry_radius + 1.0 - MAX (MAX (progress->border.left, progress->border.right),
@@ -528,7 +591,7 @@ clearlooks_draw_entry_progress (cairo_t *cr,
 		cairo_clip (cr);
 
 		/* We just draw wider by one pixel ... */
-		ge_cairo_set_color (cr, &fill);
+		ge_cairo_set_color (cr, fill);
 		cairo_rectangle (cr, x, y + 1, width, height - 2);
 		cairo_fill (cr);
 
@@ -544,7 +607,7 @@ clearlooks_draw_entry_progress (cairo_t *cr,
 		ge_cairo_rounded_rectangle (cr, x - 10, y - 10, width + 10, height + 10, radius, CR_CORNER_ALL);
 		cairo_clip (cr);
 
-		ge_cairo_set_color (cr, &fill);
+		ge_cairo_set_color (cr, fill);
 		ge_cairo_rounded_rectangle (cr, x + 1, y + 1, width - 2, height - 2, radius, CR_CORNER_ALL);
 		cairo_fill (cr);
 
@@ -555,51 +618,86 @@ clearlooks_draw_entry_progress (cairo_t *cr,
 	}
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) fill);
 }
 
 static void
 clearlooks_draw_spinbutton (cairo_t *cr,
-                            const ClearlooksColors *colors,
-                            const WidgetParameters *params,
+			    GtkThemingEngine *engine,
                             int x, int y, int width, int height)
 {
-	const CairoColor *border = &colors->shade[!params->disabled ? 5 : 3];
+	ClearlooksStyleFunctions *style_functions;
+	ClearlooksStyleConstants *style_constants;
+	CairoColor *bg_color, border;
 	CairoColor hilight;
+	GtkStateFlags state;
+	gint border_width;
+
+	state = gtk_theming_engine_get_state (engine);
+
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
+		clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border);
+	else
+		clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &border);
 
-	params->style_functions->draw_button (cr, colors, params, x, y, width, height);
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, &style_constants);
 
-	ge_shade_color (&colors->bg[0], params->style_constants->topleft_highlight_shade, &hilight);
-	hilight.a = params->style_constants->topleft_highlight_alpha;
+	gtk_theming_engine_get (engine, state,
+				"background-color", &bg_color,
+				"border-width", &border_width,
+				NULL);
+
+	style_functions->draw_button (cr, engine, x, y, width, height);
+
+	ge_shade_color (bg_color, style_constants->topleft_highlight_shade, &hilight);
+	hilight.a = style_constants->topleft_highlight_alpha;
 
 	cairo_translate (cr, x, y);
 
-	cairo_move_to (cr, params->xthickness + 0.5,       (height/2) + 0.5);
-	cairo_line_to (cr, width-params->xthickness - 0.5, (height/2) + 0.5);
-	ge_cairo_set_color (cr, border);
+	cairo_move_to (cr, border_width + 0.5,       (height/2) + 0.5);
+	cairo_line_to (cr, width-border_width - 0.5, (height/2) + 0.5);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 
-	cairo_move_to (cr, params->xthickness + 0.5,       (height/2)+1.5);
-	cairo_line_to (cr, width-params->xthickness - 0.5, (height/2)+1.5);
+	cairo_move_to (cr, border_width + 0.5,       (height/2)+1.5);
+	cairo_line_to (cr, width-border_width - 0.5, (height/2)+1.5);
 	ge_cairo_set_color (cr, &hilight);
 	cairo_stroke (cr);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
 clearlooks_draw_spinbutton_down (cairo_t *cr,
-                                 const ClearlooksColors *colors,
-                                 const WidgetParameters *params,
+				 GtkThemingEngine *engine,
                                  int x, int y, int width, int height)
 {
 	cairo_pattern_t *pattern;
-	double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
-	CairoColor shadow;
-	ge_shade_color (&colors->bg[0], 0.8, &shadow);
+	double radius;
+	CairoColor *bg_color, shadow;
+
+	gtk_theming_engine_get (engine, 0,
+				"border-radius", &radius,
+				"background-color", &bg_color,
+				NULL);
+
+	ge_shade_color (bg_color, 0.8, &shadow);
+	gdk_rgba_free ((GdkRGBA *) bg_color);
+
+	radius = MIN (radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
+
+	gtk_theming_engine_get (engine,
+				gtk_theming_engine_get_state (engine),
+				"background-color", &bg_color,
+				NULL);
 
 	cairo_translate (cr, x+1, y+1);
 
-	ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, params->corners);
+	ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, 0); //params->corners);
 
-	ge_cairo_set_color (cr, &colors->bg[params->state_type]);
+	ge_cairo_set_color (cr, bg_color);
 
 	cairo_fill_preserve (cr);
 
@@ -611,6 +709,8 @@ clearlooks_draw_spinbutton_down (cairo_t *cr,
 	cairo_fill (cr);
 
 	cairo_pattern_destroy (pattern);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
@@ -640,14 +740,16 @@ clearlooks_scale_draw_gradient (cairo_t *cr,
 #define TROUGH_SIZE 7
 static void
 clearlooks_draw_scale_trough (cairo_t *cr,
-                              const ClearlooksColors *colors,
-                              const WidgetParameters *params,
+			      GtkThemingEngine *engine,
                               const SliderParameters *slider,
                               int x, int y, int width, int height)
 {
+	ClearlooksStyleFunctions *style_functions;
 	int     trough_width, trough_height;
 	double  translate_x, translate_y;
 
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
 	cairo_save (cr);
 
 	if (slider->horizontal)
@@ -670,27 +772,36 @@ clearlooks_draw_scale_trough (cairo_t *cr,
 	cairo_set_line_width (cr, 1.0);
 	cairo_translate (cr, translate_x, translate_y);
 
+#if 0
 	if (!slider->fill_level)
-		params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width, trough_height, 0, 0);
-	
+		style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width, trough_height, 0, 0);
+#endif
+
 	if (!slider->lower && !slider->fill_level)
 	{
-		CairoColor shadow;
-		ge_shade_color (&colors->shade[2], 0.96, &shadow);
+		CairoColor shade1, shade2, shadow;
+
+		clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &shade1);
+		clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &shade2);
+		ge_shade_color (&shade1, 0.96, &shadow);
 
 		clearlooks_scale_draw_gradient (cr, &shadow, /* top */
-		                                &colors->shade[2], /* bottom */
-		                                &colors->shade[4], /* border */
+						&shade1, /* bottom */
+		                                &shade2, /* border */
 		                                1.0, 1.0, trough_width - 2, trough_height - 2,
 		                                slider->horizontal);
 	}
 	else
 	{
-		CairoColor border = colors->spot[2];
+		CairoColor border, spot1, spot2;
+
+		clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
+		clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &spot1);
+		clearlooks_lookup_spot (engine, 0, (GdkRGBA *) &spot2);
 		border.a = 0.64;
 
-		clearlooks_scale_draw_gradient (cr, &colors->spot[1], /* top */
-		                                &colors->spot[0], /* bottom */
+		clearlooks_scale_draw_gradient (cr, &spot1, /* top */
+		                                &spot2, /* bottom */
 		                                &border, /* border */
 		                                1.0, 1.0, trough_width - 2, trough_height - 2,
 		                                slider->horizontal);
@@ -700,42 +811,56 @@ clearlooks_draw_scale_trough (cairo_t *cr,
 
 static void
 clearlooks_draw_slider (cairo_t *cr,
-                        const ClearlooksColors *colors,
-                        const WidgetParameters *params,
+			GtkThemingEngine *engine,
                         int x, int y, int width, int height)
 {
-	const CairoColor *spot   = &colors->spot[1];
-	const CairoColor *fill   = &colors->shade[2];
-	CairoColor border = colors->shade[params->disabled ? 4 : 6];
-	double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
-
+	CairoColor spot, fill, border;
 	cairo_pattern_t *pattern;
+	GtkStateFlags state;
+	double radius;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				NULL);
+
+	radius = MIN (radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
+
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &spot);
+	clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &fill);
+
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
+		clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &border);
+	else
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border);
 
 	cairo_set_line_width (cr, 1.0);
 	cairo_translate      (cr, x, y);
 
-	if (params->prelight)
-		border = colors->spot[2];
+	if (state & GTK_STATE_FLAG_PRELIGHT)
+		clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
 
 	/* fill the widget */
-	ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, params->corners);
+	ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, 0); //params->corners);
 
 	/* Fake light */
-	if (!params->disabled)
+	if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
 	{
-		const CairoColor *top = &colors->shade[0];
-		const CairoColor *bot = &colors->shade[2];
+		CairoColor top, bot;
+
+		clearlooks_lookup_shade (engine, 0, (GdkRGBA *) &top);
+		clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &bot);
 
 		pattern	= cairo_pattern_create_linear (0, 0, 0, height);
-		cairo_pattern_add_color_stop_rgb (pattern, 0.0,  top->r, top->g, top->b);
-		cairo_pattern_add_color_stop_rgb (pattern, 1.0,  bot->r, bot->g, bot->b);
+		cairo_pattern_add_color_stop_rgb (pattern, 0.0,  top.r, top.g, top.b);
+		cairo_pattern_add_color_stop_rgb (pattern, 1.0,  bot.r, bot.g, bot.b);
 		cairo_set_source (cr, pattern);
 		cairo_fill (cr);
 		cairo_pattern_destroy (pattern);
 	}
 	else
 	{
-		ge_cairo_set_color (cr, fill);
+		ge_cairo_set_color (cr, &fill);
 		cairo_fill         (cr);
 	}
 
@@ -748,21 +873,21 @@ clearlooks_draw_slider (cairo_t *cr,
 	cairo_new_path (cr);
 
 	/* Draw the handles */
-	ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners);
+	ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, 0); //params->corners);
 	pattern = cairo_pattern_create_linear (1.0, 1.0, 1.0, 1.0+height);
 
-	if (params->prelight)
+	if (state & GTK_STATE_FLAG_PRELIGHT)
 	{
 		CairoColor highlight;
-		ge_shade_color (spot, 1.3, &highlight);
+		ge_shade_color (&spot, 1.3, &highlight);
 		cairo_pattern_add_color_stop_rgb (pattern, 0.0, highlight.r, highlight.g, highlight.b);
-		cairo_pattern_add_color_stop_rgb (pattern, 1.0, spot->r, spot->g, spot->b);
+		cairo_pattern_add_color_stop_rgb (pattern, 1.0, spot.r, spot.g, spot.b);
 		cairo_set_source (cr, pattern);
 	}
 	else
 	{
 		CairoColor hilight;
-		ge_shade_color (fill, 1.3, &hilight);
+		ge_shade_color (&fill, 1.3, &hilight);
 		cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
 	}
 
@@ -772,9 +897,10 @@ clearlooks_draw_slider (cairo_t *cr,
 	cairo_restore (cr);
 
 	/* Draw the border */
-	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
+	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
 
-	if (params->prelight || params->disabled)
+	if (state & GTK_STATE_FLAG_PRELIGHT ||
+	    state & GTK_STATE_FLAG_INSENSITIVE)
 		ge_cairo_set_color (cr, &border);
 	else
 		clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
@@ -790,7 +916,7 @@ clearlooks_draw_slider (cairo_t *cr,
 		cairo_line_to (cr, width-6.5, height-1);
 
 		cairo_set_line_width (cr, 1.0);
-		border.a = params->disabled ? 0.6 : 0.3;
+		border.a = (state & GTK_STATE_FLAG_INSENSITIVE) ? 0.6 : 0.3;
 		ge_cairo_set_color (cr, &border);
 		cairo_stroke (cr);
 	}
@@ -798,12 +924,22 @@ clearlooks_draw_slider (cairo_t *cr,
 
 static void
 clearlooks_draw_slider_button (cairo_t *cr,
-                               const ClearlooksColors *colors,
-                               const WidgetParameters *params,
+			       GtkThemingEngine *engine,
                                const SliderParameters *slider,
                                int x, int y, int width, int height)
 {
-	double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
+	ClearlooksStyleFunctions *style_functions;
+	double radius;
+
+	gtk_theming_engine_get (engine,
+				gtk_theming_engine_get_state (engine),
+				"border-radius", &radius,
+				NULL);
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+	radius = MIN (radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
 
 	cairo_save (cr);
 	cairo_set_line_width (cr, 1.0);
@@ -812,45 +948,54 @@ clearlooks_draw_slider_button (cairo_t *cr,
 		ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
 	cairo_translate (cr, x, y);
 
-	params->style_functions->draw_shadow (cr, colors, radius, width, height);
-	params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
+	style_functions->draw_shadow (cr, engine, radius, width, height);
+	style_functions->draw_slider (cr, engine, 1, 1, width-2, height-2);
 
 	if (width > 24)
-		params->style_functions->draw_gripdots (cr, colors, 1, 1, width-2, height-2, 3, 3, 0);
+		style_functions->draw_gripdots (cr, engine, 1, 1, width-2, height-2, 3, 3, 0);
 
 	cairo_restore (cr);
 }
 
 static void
 clearlooks_draw_progressbar_trough (cairo_t *cr,
-                                    const ClearlooksColors *colors,
-                                    const WidgetParameters *params,
+				    GtkThemingEngine *engine,
                                     int x, int y, int width, int height)
 {
-	const CairoColor *border = &colors->shade[4];
-	CairoColor        shadow;
+	CairoColor        fill, border, shadow;
 	cairo_pattern_t  *pattern;
-	double            radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
+	double            radius;
+	GtkStateFlags     state;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				NULL);
+
+	clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &fill);
+	clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &border);
+
+	radius = MIN (radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
 
 	cairo_save (cr);
 
 	cairo_set_line_width (cr, 1.0);
 
 	/* Create trough box */
-	ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
-	ge_cairo_set_color (cr, &colors->shade[2]);
+	ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, 0); //params->corners);
+	ge_cairo_set_color (cr, &fill);
 	cairo_fill (cr);
 
 	/* Draw border */
-	ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
-	ge_cairo_set_color (cr, border);
+	ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, 0); //params->corners);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 
 	/* clip the corners of the shadows */
-	ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
+	ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, 0); //params->corners);
 	cairo_clip (cr);
 
-	ge_shade_color (border, 0.925, &shadow);
+	ge_shade_color (&border, 0.925, &shadow);
 
 	/* Top shadow */
 	cairo_rectangle (cr, x+1, y+1, width-2, 4);
@@ -875,12 +1020,12 @@ clearlooks_draw_progressbar_trough (cairo_t *cr,
 
 static void
 clearlooks_draw_progressbar_fill (cairo_t *cr,
-                                  const ClearlooksColors *colors,
-                                  const WidgetParameters *params,
+				  GtkThemingEngine *engine,
                                   const ProgressBarParameters *progressbar,
                                   int x, int y, int width, int height,
                                   gint offset)
 {
+	ClearlooksStyleFunctions *style_functions;
 	boolean      is_horizontal = progressbar->orientation < 2;
 	double       tile_pos = 0;
 	double       stroke_width;
@@ -890,9 +1035,20 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
 	cairo_pattern_t *pattern;
 	CairoColor       bg_shade;
 	CairoColor       border;
-	CairoColor       shadow;
+	CairoColor       shadow, spot;
+	GtkStateFlags    state;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				NULL);
 
-	radius = MAX (0, params->radius - params->xthickness);
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+#if 0
+	radius = MAX (0, radius - params->xthickness);
+#endif
 
 	cairo_save (cr);
 
@@ -919,7 +1075,8 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
 	cairo_clip (cr);
 
 	/* Draw the background gradient */
-	ge_shade_color (&colors->spot[1], 1.1, &bg_shade);
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &spot);
+	ge_shade_color (&spot, 1.1, &bg_shade);
 
 	/* Just leave this disabled, maybe we could use the same gradient
 	 * as the buttons in the future, not flat fill */
@@ -946,9 +1103,10 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
 		tile_pos += stroke_width;
 	}
 
+	clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &spot);
 	pattern = cairo_pattern_create_linear (0, 0, 0, height);
-	cairo_pattern_add_color_stop_rgba (pattern, 0.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0);
-	cairo_pattern_add_color_stop_rgba (pattern, 1.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0.24);
+	cairo_pattern_add_color_stop_rgba (pattern, 0.0, spot.r, spot.g, spot.b, 0);
+	cairo_pattern_add_color_stop_rgba (pattern, 1.0, spot.r, spot.g, spot.b, 0.24);
 	cairo_set_source (cr, pattern);
 	cairo_fill (cr);
 	cairo_pattern_destroy (pattern);
@@ -991,11 +1149,11 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
 /*	cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 1);*/
 /*	cairo_stroke (cr);*/
 
-	params->style_functions->draw_top_left_highlight (cr, &colors->spot[1], params, 1.5, 1.5,
-	                                                  width - 1, height - 1,
-	                                                  radius, params->corners);
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &spot);
+	style_functions->draw_top_left_highlight (cr, &spot, engine, 1.5, 1.5,
+						  width - 1, height - 1);
 
-	border = colors->spot[2];
+	clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
 	border.a = 0.6;
 	ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, CR_CORNER_ALL);
 	ge_cairo_set_color (cr, &border);
@@ -1008,30 +1166,36 @@ clearlooks_draw_progressbar_fill (cairo_t *cr,
 
 static void
 clearlooks_draw_optionmenu (cairo_t *cr,
-                            const ClearlooksColors *colors,
-                            const WidgetParameters *params,
+			    GtkThemingEngine *engine,
                             const OptionMenuParameters *optionmenu,
                             int x, int y, int width, int height)
 {
+	ClearlooksStyleFunctions *style_functions;
 	SeparatorParameters separator;
-	int offset = params->ythickness + 2;
+	int offset = 0; //params->ythickness + 2;
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
 
-	params->style_functions->draw_button (cr, colors, params, x, y, width, height);
+	style_functions->draw_button (cr, engine, x, y, width, height);
 
 	separator.horizontal = FALSE;
-	params->style_functions->draw_separator (cr, colors, params, &separator, x+optionmenu->linepos, y + offset, 2, height - offset*2);
+	style_functions->draw_separator (cr, engine, &separator, x+optionmenu->linepos, y + offset, 2, height - offset*2);
 }
 
 static void
 clearlooks_draw_menu_item_separator (cairo_t                   *cr,
-                                     const ClearlooksColors    *colors,
-                                     const WidgetParameters    *widget,
+				     GtkThemingEngine          *engine,
                                      const SeparatorParameters *separator,
                                      int x, int y, int width, int height)
 {
+	CairoColor shade;
+
+	clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &shade);
+
 	cairo_save (cr);
 	cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
-	ge_cairo_set_color (cr, &colors->shade[5]);
+	ge_cairo_set_color (cr, &shade);
 
 	if (separator->horizontal)
 		cairo_rectangle (cr, x, y, width, 1);
@@ -1045,12 +1209,13 @@ clearlooks_draw_menu_item_separator (cairo_t                   *cr,
 
 static void
 clearlooks_draw_menubar0 (cairo_t *cr,
-                          const ClearlooksColors *colors,
-                          const WidgetParameters *params,
+			  GtkThemingEngine *engine,
                           const MenuBarParameters *menubar,
                           int x, int y, int width, int height)
 {
-	const CairoColor *dark = &colors->shade[3];
+	CairoColor dark;
+
+	clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &dark);
 
 	cairo_save (cr);
 
@@ -1059,7 +1224,7 @@ clearlooks_draw_menubar0 (cairo_t *cr,
 
 	cairo_move_to (cr, 0, height-0.5);
 	cairo_line_to (cr, width, height-0.5);
-	ge_cairo_set_color (cr, dark);
+	ge_cairo_set_color (cr, &dark);
 	cairo_stroke (cr);
 
 	cairo_restore (cr);
@@ -1067,26 +1232,29 @@ clearlooks_draw_menubar0 (cairo_t *cr,
 
 static void
 clearlooks_draw_menubar2 (cairo_t *cr,
-                          const ClearlooksColors *colors,
-                          const WidgetParameters *params,
+			  GtkThemingEngine *engine,
                           const MenuBarParameters *menubar,
                           int x, int y, int width, int height)
 {
-	CairoColor lower;
+	CairoColor *bg_color, lower, shade;
 	cairo_pattern_t *pattern;
 
 	cairo_save (cr);
 
-	ge_shade_color (&colors->bg[0], 0.96, &lower);
+	gtk_theming_engine_get (engine, 0,
+				"background-color", &bg_color,
+				NULL);
+
+	ge_shade_color (bg_color, 0.96, &lower);
 
 	cairo_translate (cr, x, y);
 	cairo_rectangle (cr, 0, 0, width, height);
 
 	/* Draw the gradient */
 	pattern = cairo_pattern_create_linear (0, 0, 0, height);
-	cairo_pattern_add_color_stop_rgb (pattern, 0.0, colors->bg[0].r,
-	                                                colors->bg[0].g,
-	                                                colors->bg[0].b);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.0, bg_color->r,
+	                                                bg_color->g,
+	                                                bg_color->b);
 	cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r,
 	                                                lower.g,
 	                                                lower.b);
@@ -1098,25 +1266,29 @@ clearlooks_draw_menubar2 (cairo_t *cr,
 	cairo_set_line_width (cr, 1.0);
 	cairo_move_to        (cr, 0, height-0.5);
 	cairo_line_to        (cr, width, height-0.5);
-	ge_cairo_set_color   (cr, &colors->shade[3]);
+
+	clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &shade);
+	ge_cairo_set_color   (cr, &shade);
 	cairo_stroke         (cr);
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
 clearlooks_draw_menubar1 (cairo_t *cr,
-                          const ClearlooksColors *colors,
-                          const WidgetParameters *params,
+			  GtkThemingEngine *engine,
                           const MenuBarParameters *menubar,
                           int x, int y, int width, int height)
 {
-	const CairoColor *border = &colors->shade[3];
+	CairoColor border;
 
-	clearlooks_draw_menubar2 (cr, colors, params, menubar,
+	clearlooks_draw_menubar2 (cr, engine, menubar,
 	                          x, y, width, height);
 
-	ge_cairo_set_color (cr, border);
+	clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &border);
+	ge_cairo_set_color (cr, &border);
 	ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
 }
 
@@ -1130,15 +1302,14 @@ static menubar_draw_proto clearlooks_menubar_draw[3] =
 
 static void
 clearlooks_draw_menubar (cairo_t *cr,
-                         const ClearlooksColors *colors,
-                         const WidgetParameters *params,
+			 GtkThemingEngine *engine,
                          const MenuBarParameters *menubar,
                          int x, int y, int width, int height)
 {
 	if (menubar->style < 0 || menubar->style >= G_N_ELEMENTS (clearlooks_menubar_draw))
 		return;
 
-	clearlooks_menubar_draw[menubar->style](cr, colors, params, menubar,
+	clearlooks_menubar_draw[menubar->style](cr, engine, menubar,
 	                             x, y, width, height);
 }
 
@@ -1180,19 +1351,27 @@ clearlooks_get_frame_gap_clip (int x, int y, int width, int height,
 
 static void
 clearlooks_draw_frame            (cairo_t *cr,
-                                  const ClearlooksColors     *colors,
-                                  const WidgetParameters     *params,
+				  GtkThemingEngine           *engine,
                                   const FrameParameters      *frame,
                                   int x, int y, int width, int height)
 {
+	CairoColor *bg_color, dark;
 	const CairoColor *border = frame->border;
-	const CairoColor *dark   = (CairoColor*)&colors->shade[4];
 	ClearlooksRectangle bevel_clip = {0, 0, 0, 0};
 	ClearlooksRectangle frame_clip = {0, 0, 0, 0};
-	double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	double radius;
 	CairoColor hilight;
 
-	ge_shade_color (&colors->bg[0], 1.05, &hilight);
+	gtk_theming_engine_get (engine, 0,
+				"border-radius", &radius,
+				"background-color", &bg_color,
+				NULL);
+
+	radius = MIN (radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	clearlook_lookup_shade (engine, 4, &dark);
+
+	ge_shade_color (bg_color, 1.05, &hilight);
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 
 	if (frame->shadow == CL_SHADOW_NONE)
 		return;
@@ -1221,18 +1400,20 @@ clearlooks_draw_frame            (cairo_t *cr,
 	{
 		ge_cairo_set_color (cr, &hilight);
 		if (frame->shadow == CL_SHADOW_ETCHED_IN)
-			ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
+			ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, 0); //params->corners);
 		else
-			ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
+			ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, 0); //params->corners);
 		cairo_stroke (cr);
 	}
+#if 0
 	else if (frame->shadow != CL_SHADOW_NONE)
 	{
 		ShadowParameters shadow;
-		shadow.corners = params->corners;
+		shadow.corners = 0; //params->corners;
 		shadow.shadow  = frame->shadow;
-		clearlooks_draw_highlight_and_shade (cr, colors, &shadow, width, height, radius);
+		clearlooks_draw_highlight_and_shade (cr, engine, &shadow, width, height, radius);
 	}
+#endif
 
 	/* restore the previous clip region */
 	cairo_restore    (cr);
@@ -1249,16 +1430,16 @@ clearlooks_draw_frame            (cairo_t *cr,
 	/* Draw frame */
 	if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
 	{
-		ge_cairo_set_color (cr, dark);
+		ge_cairo_set_color (cr, &dark);
 		if (frame->shadow == CL_SHADOW_ETCHED_IN)
-			ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
+			ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, 0); //params->corners);
 		else
-			ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
+			ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, 0); //params->corners);
 	}
 	else
 	{
 		ge_cairo_set_color (cr, border);
-		ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
+		ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
 	}
 	cairo_stroke (cr);
 
@@ -1267,17 +1448,14 @@ clearlooks_draw_frame            (cairo_t *cr,
 
 static void
 clearlooks_draw_tab (cairo_t *cr,
-                     const ClearlooksColors *colors,
-                     const WidgetParameters *params,
+		     GtkThemingEngine       *engine,
                      const TabParameters    *tab,
                      int x, int y, int width, int height)
 {
-	const CairoColor *border1       = &colors->shade[6];
-	const CairoColor *border2       = &colors->shade[5];
-	const CairoColor *stripe_fill   = &colors->spot[1];
-	const CairoColor *stripe_border = &colors->spot[2];
-	const CairoColor *fill;
+	CairoColor border1, border2, stripe_fill, stripe_border;
+	CairoColor       *fill;
 	CairoColor        hilight;
+	GtkStateFlags     state;
 
 	cairo_pattern_t  *pattern;
 
@@ -1286,7 +1464,18 @@ clearlooks_draw_tab (cairo_t *cr,
 	double            stripe_fill_size;
 	double            length;
 
-	radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				"background-color", &fill,
+				NULL);
+
+	clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border1);
+	clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border2);
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &stripe_fill);
+	clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &stripe_border);
+
+	radius = MIN (radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
 
 	cairo_save (cr);
 
@@ -1321,12 +1510,9 @@ clearlooks_draw_tab (cairo_t *cr,
 			cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
 	}
 
-	/* Set the fill color */
-	fill = &colors->bg[params->state_type];
-
 	/* Set tab shape */
 	ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
-	                            radius, params->corners);
+	                            radius, 0); //params->corners);
 
 	/* Draw fill */
 	ge_cairo_set_color (cr, fill);
@@ -1336,19 +1522,21 @@ clearlooks_draw_tab (cairo_t *cr,
 	ge_shade_color (fill, 1.3, &hilight);
 
 	/* Draw highlight */
-	if (!params->active)
+	if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
 	{
+#if 0
 		ShadowParameters shadow;
 
 		shadow.shadow  = CL_SHADOW_OUT;
-		shadow.corners = params->corners;
+		shadow.corners = 0; //params->corners;
 
 		clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
 		                                     width,
 		                                     height, radius);
+#endif
 	}
 
-	if (params->active)
+	if (state & GTK_STATE_FLAG_ACTIVE)
 	{
 		CairoColor shadow;
 		switch (tab->gap_side)
@@ -1369,7 +1557,7 @@ clearlooks_draw_tab (cairo_t *cr,
 				pattern = NULL;
 		}
 
-		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
+		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, 0); //params->corners);
 
 		ge_shade_color (fill, 0.92, &shadow);
 
@@ -1402,10 +1590,10 @@ clearlooks_draw_tab (cairo_t *cr,
 				pattern = NULL;
 		}
 
-		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
+		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, 0); //params->corners);
 
-		cairo_pattern_add_color_stop_rgb  (pattern, 0.0,        stripe_fill->r, stripe_fill->g, stripe_fill->b);
-		cairo_pattern_add_color_stop_rgb  (pattern, stripe_fill_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
+		cairo_pattern_add_color_stop_rgb  (pattern, 0.0,        stripe_fill.r, stripe_fill.g, stripe_fill.b);
+		cairo_pattern_add_color_stop_rgb  (pattern, stripe_fill_size, stripe_fill.r, stripe_fill.g, stripe_fill.b);
 		cairo_pattern_add_color_stop_rgba (pattern, stripe_fill_size, hilight.r, hilight.g, hilight.b, 0.5);
 		cairo_pattern_add_color_stop_rgba (pattern, 0.8,        hilight.r, hilight.g, hilight.b, 0.0);
 		cairo_set_source (cr, pattern);
@@ -1413,11 +1601,11 @@ clearlooks_draw_tab (cairo_t *cr,
 		cairo_pattern_destroy (pattern);
 	}
 
-	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
+	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, 0); //params->corners);
 
-	if (params->active)
+	if (state & GTK_STATE_FLAG_ACTIVE)
 	{
-		ge_cairo_set_color (cr, border2);
+		ge_cairo_set_color (cr, &border2);
 		cairo_stroke (cr);
 	}
 	else
@@ -1440,28 +1628,34 @@ clearlooks_draw_tab (cairo_t *cr,
 				pattern = NULL;
 		}
 
-		cairo_pattern_add_color_stop_rgb (pattern, 0.0,        stripe_border->r, stripe_border->g, stripe_border->b);
-		cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_border->r, stripe_border->g, stripe_border->b);
-		cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, border1->r,       border1->g,       border1->b);
-		cairo_pattern_add_color_stop_rgb (pattern, 1.0,        border2->r,       border2->g,       border2->b);
+		cairo_pattern_add_color_stop_rgb (pattern, 0.0,        stripe_border.r, stripe_border.g, stripe_border.b);
+		cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_border.r, stripe_border.g, stripe_border.b);
+		cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, border1.r,       border1.g,       border1.b);
+		cairo_pattern_add_color_stop_rgb (pattern, 1.0,        border2.r,       border2.g,       border2.b);
 		cairo_set_source (cr, pattern);
 		cairo_stroke (cr);
 		cairo_pattern_destroy (pattern);
 	}
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) fill);
 }
 
 static void
 clearlooks_draw_separator (cairo_t *cr,
-                           const ClearlooksColors     *colors,
-                           const WidgetParameters     *widget,
+			   GtkThemingEngine           *engine,
                            const SeparatorParameters  *separator,
                            int x, int y, int width, int height)
 {
-	CairoColor color = colors->shade[2];
-	CairoColor hilight;
-	ge_shade_color (&colors->bg[0], 1.065, &hilight);
+	CairoColor *bg_color, color, hilight;
+
+	gtk_theming_engine_get (engine, 0,
+				"background-color", &bg_color,
+				NULL);
+
+	clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &color);
+	ge_shade_color (bg_color, 1.065, &hilight);
 
 	cairo_save (cr);
 	cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
@@ -1502,17 +1696,29 @@ clearlooks_draw_separator (cairo_t *cr,
 
 static void
 clearlooks_draw_list_view_header (cairo_t *cr,
-                                  const ClearlooksColors          *colors,
-                                  const WidgetParameters          *params,
+				  GtkThemingEngine                *engine,
                                   const ListViewHeaderParameters  *header,
                                   int x, int y, int width, int height)
 {
-	const CairoColor *border = &colors->shade[4];
+	ClearlooksStyleFunctions *style_functions;
+	ClearlooksStyleConstants *style_constants;
+	CairoColor border, *bg_color;
+	GtkStateFlags state;
 	CairoColor hilight;
+	gboolean is_ltr;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"background-color", &bg_color,
+				NULL);
 
-	ge_shade_color (&colors->bg[params->state_type],
-	                params->style_constants->topleft_highlight_shade, &hilight);
-	hilight.a = params->style_constants->topleft_highlight_alpha;
+	clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &border);
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, &style_constants);
+
+	ge_shade_color (bg_color,
+	                style_constants->topleft_highlight_shade, &hilight);
+	hilight.a = style_constants->topleft_highlight_alpha;
 
 	cairo_translate (cr, x, y);
 	cairo_set_line_width (cr, 1.0);
@@ -1534,37 +1740,44 @@ clearlooks_draw_list_view_header (cairo_t *cr,
 	/* Draw bottom border */
 	cairo_move_to (cr, 0.0, height-0.5);
 	cairo_line_to (cr, width, height-0.5);
-	ge_cairo_set_color (cr, border);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 
+	is_ltr = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_LTR);
+
 	/* Draw resize grip */
-	if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
-	    (!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
+	if ((is_ltr && !(header->order & CL_ORDER_LAST)) ||
+	    (!is_ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
 	{
 		SeparatorParameters separator;
 		separator.horizontal = FALSE;
 
-		if (params->ltr)
-			params->style_functions->draw_separator (cr, colors, params, &separator,
-			                                         width-1.5, 4.0, 2, height-8.0);
+		if (is_ltr)
+			style_functions->draw_separator (cr, engine, &separator,
+							 width-1.5, 4.0, 2, height-8.0);
 		else
-			params->style_functions->draw_separator (cr, colors, params, &separator,
-			                                         1.5, 4.0, 2, height-8.0);
+			style_functions->draw_separator (cr, engine, &separator,
+							 1.5, 4.0, 2, height-8.0);
 	}
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 /* We can't draw transparent things here, since it will be called on the same
  * surface multiple times, when placed on a handlebox_bin or dockitem_bin */
 static void
 clearlooks_draw_toolbar (cairo_t *cr,
-                         const ClearlooksColors          *colors,
-                         const WidgetParameters          *widget,
+			 GtkThemingEngine                *engine,
                          const ToolbarParameters         *toolbar,
                          int x, int y, int width, int height)
 {
-	const CairoColor *fill  = &colors->bg[0];
-	const CairoColor *dark  = &colors->shade[3];
-	CairoColor light;
+	CairoColor *fill;
+	CairoColor dark, light;
+
+	gtk_theming_engine_get (engine, 0,
+				"background-color", &fill,
+				NULL);
+	clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &dark);
 	ge_shade_color (fill, 1.065, &light);
 
 	cairo_set_line_width (cr, 1.0);
@@ -1585,29 +1798,36 @@ clearlooks_draw_toolbar (cairo_t *cr,
 	/* Draw shadow */
 	cairo_move_to       (cr, 0, height-0.5);
 	cairo_line_to       (cr, width-1, height-0.5);
-	ge_cairo_set_color  (cr, dark);
+	ge_cairo_set_color  (cr, &dark);
 	cairo_stroke        (cr);
+
+	gdk_rgba_free ((GdkRGBA *) fill);
 }
 
 static void
 clearlooks_draw_menuitem (cairo_t *cr,
-                          const ClearlooksColors          *colors,
-                          const WidgetParameters          *widget,
+			  GtkThemingEngine *engine,
                           int x, int y, int width, int height)
 {
-	const CairoColor *fill = &colors->spot[1];
-	CairoColor fill_shade;
-	CairoColor border = colors->spot[2];
+	CairoColor fill, fill_shade, border;
 	cairo_pattern_t *pattern;
+	gdouble radius;
+
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &fill);
+	clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
+
+	gtk_theming_engine_get (engine, 0,
+				"border-radius", &radius,
+				NULL);
 
 	ge_shade_color (&border, 1.05, &border);
-	ge_shade_color (fill, 0.85, &fill_shade);
+	ge_shade_color (&fill, 0.85, &fill_shade);
 	cairo_set_line_width (cr, 1.0);
 
-	ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
+	ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, radius, 0); //widget->corners);
 
 	pattern = cairo_pattern_create_linear (x, y, x, y + height);
-	cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
+	cairo_pattern_add_color_stop_rgb (pattern, 0,   fill.r, fill.g, fill.b);
 	cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
 
 	cairo_set_source (cr, pattern);
@@ -1620,23 +1840,28 @@ clearlooks_draw_menuitem (cairo_t *cr,
 
 static void
 clearlooks_draw_menubaritem (cairo_t *cr,
-                          const ClearlooksColors          *colors,
-                          const WidgetParameters          *widget,
-                          int x, int y, int width, int height)
+			     GtkThemingEngine *engine,
+			     int x, int y, int width, int height)
 {
-	const CairoColor *fill = &colors->spot[1];
-	CairoColor fill_shade;
-	CairoColor border = colors->spot[2];
+	CairoColor fill, fill_shade, border;
 	cairo_pattern_t *pattern;
+	gdouble radius;
+
+	clearlooks_lookup_spot (engine, 1, (GdkRGBA *) &fill);
+	clearlooks_lookup_spot (engine, 2, (GdkRGBA *) &border);
+
+	gtk_theming_engine_get (engine, 0,
+				"border-radius", &radius,
+				NULL);
 
 	ge_shade_color (&border, 1.05, &border);
-	ge_shade_color (fill, 0.85, &fill_shade);
+	ge_shade_color (&fill, 0.85, &fill_shade);
 
 	cairo_set_line_width (cr, 1.0);
-	ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
+	ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, radius, 0); //widget->corners);
 
 	pattern = cairo_pattern_create_linear (x, y, x, y + height);
-	cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
+	cairo_pattern_add_color_stop_rgb (pattern, 0,   fill.r, fill.g, fill.b);
 	cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
 
 	cairo_set_source (cr, pattern);
@@ -1649,28 +1874,30 @@ clearlooks_draw_menubaritem (cairo_t *cr,
 
 static void
 clearlooks_draw_selected_cell (cairo_t                  *cr,
-	                       const ClearlooksColors   *colors,
-	                       const WidgetParameters   *params,
+			       GtkThemingEngine         *engine,
 	                       int x, int y, int width, int height)
 {
-	CairoColor upper_color;
+	CairoColor *upper_color;
 	CairoColor lower_color;
 	cairo_pattern_t *pattern;
+	GtkStateFlags state;
 	cairo_save (cr);
 
 	cairo_translate (cr, x, y);
 
-	if (params->focus)
-		upper_color = colors->base[params->state_type];
+	state = gtk_theming_engine_get_state (engine);
+
+	if (state & GTK_STATE_FLAG_FOCUSED)
+		gtk_theming_engine_get (engine, state, "background-color", &upper_color, NULL);
 	else
-		upper_color = colors->base[GTK_STATE_ACTIVE];
+		gtk_theming_engine_get (engine, GTK_STATE_FLAG_ACTIVE, "background-color", &upper_color, NULL);
 
-	ge_shade_color(&upper_color, 0.92, &lower_color);
+	ge_shade_color(upper_color, 0.92, &lower_color);
 
 	pattern = cairo_pattern_create_linear (0, 0, 0, height);
-	cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
-	                                                upper_color.g,
-	                                                upper_color.b);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color->r,
+	                                                upper_color->g,
+	                                                upper_color->b);
 	cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
 	                                                lower_color.g,
 	                                                lower_color.b);
@@ -1682,23 +1909,33 @@ clearlooks_draw_selected_cell (cairo_t                  *cr,
 	cairo_pattern_destroy (pattern);
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) upper_color);
 }
 
 
 static void
 clearlooks_draw_scrollbar_trough (cairo_t *cr,
-                                  const ClearlooksColors           *colors,
-                                  const WidgetParameters           *widget,
+				  GtkThemingEngine *engine,
                                   const ScrollBarParameters        *scrollbar,
                                   int x, int y, int width, int height)
 {
-	const CairoColor *bg     = &colors->shade[2];
-	const CairoColor *border = &colors->shade[5];
-	CairoColor        bg_shade;
+	CairoColor        bg, bg_shade, border;
 	cairo_pattern_t *pattern;
-	double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	GtkStateFlags state;
+	double radius;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				NULL);
 
-	ge_shade_color (bg, 0.95, &bg_shade);
+	clearlooks_lookup_shade (engine, 2, (GdkRGBA *) &bg);
+	clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border);
+
+	ge_shade_color (&bg, 0.95, &bg_shade);
+
+	radius = MIN (radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
 
 	cairo_set_line_width (cr, 1);
 	/* cairo_translate (cr, x, y); */
@@ -1711,16 +1948,16 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
 	/* Draw fill */
 	if (radius > 3.0)
 		ge_cairo_rounded_rectangle (cr, 1, 0, width-2, height,
-		                            radius, widget->corners);
+		                            radius, 0); //widget->corners);
 	else
 		cairo_rectangle (cr, 1, 0, width-2, height);
-	ge_cairo_set_color (cr, bg);
+	ge_cairo_set_color (cr, &bg);
 	cairo_fill (cr);
 
 	/* Draw shadow */
 	pattern = cairo_pattern_create_linear (1, 0, 3, 0);
 	cairo_pattern_add_color_stop_rgb (pattern, 0,   bg_shade.r, bg_shade.g, bg_shade.b);
-	cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg->r,      bg->g,      bg->b);
+	cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg.r,      bg.g,      bg.b);
 	cairo_rectangle (cr, 1, 0, 4, height);
 	cairo_set_source (cr, pattern);
 	cairo_fill (cr);
@@ -1729,28 +1966,41 @@ clearlooks_draw_scrollbar_trough (cairo_t *cr,
 	/* Draw border */
 	if (radius > 3.0)
 		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
-		                            radius, widget->corners);
+		                            radius, 0); //widget->corners);
 	else
 		cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
-	ge_cairo_set_color (cr, border);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 }
 
 static void
 clearlooks_draw_scrollbar_stepper (cairo_t *cr,
-                                   const ClearlooksColors           *colors,
-                                   const WidgetParameters           *widget,
+				   GtkThemingEngine                 *engine,
                                    const ScrollBarParameters        *scrollbar,
                                    const ScrollBarStepperParameters *stepper,
                                    int x, int y, int width, int height)
 {
+	ClearlooksStyleFunctions *style_functions;
 	CairoCorners corners = CR_CORNER_NONE;
-	CairoColor   border;
+	CairoColor   shade, border, *bg_color;
 	CairoColor   s1, s2, s3, s4;
 	cairo_pattern_t *pattern;
-	double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	GtkStateFlags state;
+	double radius;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				"background-color", &bg_color,
+				NULL);
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+	radius = MIN (radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
+	clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &shade);
 
-	ge_shade_color(&colors->shade[6], 1.08, &border);
+	ge_shade_color(&shade, 1.08, &border);
 
 	if (scrollbar->horizontal)
 	{
@@ -1797,10 +2047,10 @@ clearlooks_draw_scrollbar_stepper (cairo_t *cr,
 	else
 		pattern = cairo_pattern_create_linear (0, 0, width, 0);
 
-	ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
-	ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
-	ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
-	ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
+	ge_shade_color (bg_color, SHADE_TOP, &s1);
+	ge_shade_color (bg_color, SHADE_CENTER_TOP, &s2);
+	ge_shade_color (bg_color, SHADE_CENTER_BOTTOM, &s3);
+	ge_shade_color (bg_color, SHADE_BOTTOM, &s4);
 
 	cairo_pattern_add_color_stop_rgb(pattern, 0,   s1.r, s1.g, s1.b);
 	cairo_pattern_add_color_stop_rgb(pattern, 0.3, s2.r, s2.g, s2.b);
@@ -1810,22 +2060,30 @@ clearlooks_draw_scrollbar_stepper (cairo_t *cr,
 	cairo_fill (cr);
 	cairo_pattern_destroy (pattern);
 
-	widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width - 2, height - 2, MAX(radius - 1, 0), corners);
+	style_functions->draw_top_left_highlight (cr, &s2, engine, 1, 1, width - 2, height - 2);
 
 	ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
 	clearlooks_set_border_gradient (cr, &border, 1.1, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
 	cairo_stroke (cr);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
 clearlooks_draw_scrollbar_slider (cairo_t *cr,
-                                   const ClearlooksColors          *colors,
-                                   const WidgetParameters          *widget,
-                                   const ScrollBarParameters       *scrollbar,
-                                   int x, int y, int width, int height)
+				  GtkThemingEngine                *engine,
+				  const ScrollBarParameters       *scrollbar,
+				  int x, int y, int width, int height)
 {
+	ClearlooksStyleConstants *style_constants;
+	GtkStateFlags state;
+
 	cairo_save (cr);
 
+	state = gtk_theming_engine_get_state (engine);
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     NULL, &style_constants);
+
 	if (scrollbar->junction & CL_JUNCTION_BEGIN)
 	{
 		if (scrollbar->horizontal)
@@ -1854,13 +2112,15 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
 
 	if (scrollbar->has_color)
 	{
-		const CairoColor *border  = &colors->shade[7];
+		CairoColor  border;
 		CairoColor  fill    = scrollbar->color;
 		CairoColor  hilight;
 		CairoColor  shade1, shade2, shade3;
 		cairo_pattern_t *pattern;
 
-		if (widget->prelight)
+		clearlooks_lookup_shade (engine, 7, (GdkRGBA *) &border);
+
+		if (state & GTK_STATE_FLAG_PRELIGHT)
 			ge_shade_color (&fill, 1.1, &fill);
 
 		cairo_set_line_width (cr, 1);
@@ -1883,23 +2143,29 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
 		cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
 		ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
 
-		ge_cairo_set_color (cr, border);
+		ge_cairo_set_color (cr, &border);
 		ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
 	}
 	else
 	{
-		const CairoColor *dark  = &colors->shade[4];
-		const CairoColor *light = &colors->shade[0];
-		CairoColor border;
+		CairoColor *bg_color, shade, light, dark, border;
 		CairoColor s1, s2, s3, s4, s5;
 		cairo_pattern_t *pattern;
 		int bar_x, i;
 
-		ge_shade_color (&colors->shade[6], 1.08, &border);
-		ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
-		ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
-		ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
-		ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
+		clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &dark);
+		clearlooks_lookup_shade (engine, 0, (GdkRGBA *) &light);
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &shade);
+
+		gtk_theming_engine_get (engine, state,
+					"background-color", &bg_color,
+					NULL);
+
+		ge_shade_color (&shade, 1.08, &border);
+		ge_shade_color (bg_color, SHADE_TOP, &s1);
+		ge_shade_color (bg_color, SHADE_CENTER_TOP, &s2);
+		ge_shade_color (bg_color, SHADE_CENTER_BOTTOM, &s3);
+		ge_shade_color (bg_color, SHADE_BOTTOM, &s4);
 
 		pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
 		cairo_pattern_add_color_stop_rgb(pattern, 0,   s1.r, s1.g, s1.b);
@@ -1918,8 +2184,8 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
 		cairo_move_to (cr, 1.5, height-1.5);
 		cairo_line_to (cr, 1.5, 1.5);
 		cairo_line_to (cr, width-1.5, 1.5);
-		ge_shade_color (&s2, widget->style_constants->topleft_highlight_shade, &s5);
-		s5.a = widget->style_constants->topleft_highlight_alpha;
+		ge_shade_color (&s2, style_constants->topleft_highlight_shade, &s5);
+		s5.a = style_constants->topleft_highlight_alpha;
 		ge_cairo_set_color (cr, &s5);
 		cairo_stroke(cr);
 
@@ -1933,16 +2199,18 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
 		{
 			cairo_move_to (cr, bar_x + 0.5, 4);
 			cairo_line_to (cr, bar_x + 0.5, height-4);
-			ge_cairo_set_color (cr, dark);
+			ge_cairo_set_color (cr, &dark);
 			cairo_stroke (cr);
 
 			cairo_move_to (cr, bar_x+1.5, 4);
 			cairo_line_to (cr, bar_x+1.5, height-4);
-			ge_cairo_set_color (cr, light);
+			ge_cairo_set_color (cr, &light);
 			cairo_stroke (cr);
 
 			bar_x += 3;
 		}
+
+		gdk_rgba_free ((GdkRGBA *) bg_color);
 	}
 
 	cairo_restore (cr);
@@ -1950,20 +2218,19 @@ clearlooks_draw_scrollbar_slider (cairo_t *cr,
 
 static void
 clearlooks_draw_statusbar (cairo_t *cr,
-                           const ClearlooksColors          *colors,
-                           const WidgetParameters          *widget,
+			   GtkThemingEngine *engine,
                            int x, int y, int width, int height)
 {
-	const CairoColor *dark = &colors->shade[3];
-	CairoColor hilight;
+	CairoColor dark, hilight;
 
-	ge_shade_color (dark, 1.4, &hilight);
+	clearlooks_lookup_shade (engine, 3, (GdkRGBA *) &dark);
+	ge_shade_color (&dark, 1.4, &hilight);
 
 	cairo_set_line_width  (cr, 1);
 	cairo_translate       (cr, x, y+0.5);
 	cairo_move_to         (cr, 0, 0);
 	cairo_line_to         (cr, width, 0);
-	ge_cairo_set_color    (cr, dark);
+	ge_cairo_set_color    (cr, &dark);
 	cairo_stroke          (cr);
 
 	cairo_translate       (cr, 0, 1);
@@ -1975,34 +2242,41 @@ clearlooks_draw_statusbar (cairo_t *cr,
 
 static void
 clearlooks_draw_menu_frame (cairo_t *cr,
-                            const ClearlooksColors          *colors,
-                            const WidgetParameters          *widget,
+			    GtkThemingEngine *engine,
                             int x, int y, int width, int height)
 {
-	const CairoColor *border = &colors->shade[5];
+	CairoColor border;
+
+	clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border);
+
 	cairo_translate      (cr, x, y);
 	cairo_set_line_width (cr, 1);
 
-	ge_cairo_set_color (cr, border);
+	ge_cairo_set_color (cr, &border);
 	ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
 }
 
 static void
 clearlooks_draw_tooltip (cairo_t *cr,
-                         const ClearlooksColors          *colors,
-                         const WidgetParameters          *widget,
+			 GtkThemingEngine *engine,
                          int x, int y, int width, int height)
 {
-	CairoColor border;
+	CairoColor *bg_color, border;
+	GtkStateFlags state;
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"background-color", &bg_color,
+				NULL);
 
-	ge_shade_color (&colors->bg[widget->state_type], 0.6, &border);
+	ge_shade_color (bg_color, 0.6, &border);
 
 	cairo_save (cr);
 
 	cairo_translate      (cr, x, y);
 	cairo_set_line_width (cr, 1);
 
-	ge_cairo_set_color (cr, &colors->bg[widget->state_type]);
+	ge_cairo_set_color (cr, bg_color);
 	cairo_rectangle (cr, 0, 0, width, height);
 	cairo_fill (cr);
 
@@ -2010,54 +2284,74 @@ clearlooks_draw_tooltip (cairo_t *cr,
 	ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
 clearlooks_draw_icon_view_item (cairo_t                  *cr,
-	                        const ClearlooksColors   *colors,
-	                        const WidgetParameters   *params,
+				GtkThemingEngine         *engine,
 	                        int x, int y, int width, int height)
 {
-	CairoColor upper_color;
+	CairoColor *upper_color;
 	CairoColor lower_color;
 	cairo_pattern_t *pattern;
+	GtkStateFlags state;
+	gdouble radius;
+
 	cairo_save (cr);
 
 	cairo_translate (cr, x, y);
 
-	if (params->focus)
-		upper_color = colors->base[params->state_type];
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				NULL);
+
+	if (state & GTK_STATE_FLAG_FOCUSED)
+		gtk_theming_engine_get (engine, state, "background-color", &upper_color, NULL);
 	else
-		upper_color = colors->base[GTK_STATE_ACTIVE];
+		gtk_theming_engine_get (engine, GTK_STATE_FLAG_ACTIVE, "background-color", &upper_color, NULL);
 
-	ge_shade_color(&upper_color, 0.92, &lower_color);
+	ge_shade_color(upper_color, 0.92, &lower_color);
 
 	pattern = cairo_pattern_create_linear (0, 0, 0, height);
-	cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
-	                                                upper_color.g,
-	                                                upper_color.b);
+	cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color->r,
+	                                                upper_color->g,
+	                                                upper_color->b);
 	cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
 	                                                lower_color.g,
 	                                                lower_color.b);
 
 	cairo_set_source (cr, pattern);
-	ge_cairo_rounded_rectangle  (cr, 0, 0, width, height, params->radius, CR_CORNER_ALL);
+	ge_cairo_rounded_rectangle  (cr, 0, 0, width, height, radius, CR_CORNER_ALL);
 	cairo_fill       (cr);
 
 	cairo_pattern_destroy (pattern);
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) upper_color);
 }
 
 static void
 clearlooks_draw_handle (cairo_t *cr,
-                        const ClearlooksColors          *colors,
-                        const WidgetParameters          *params,
+			GtkThemingEngine                *engine,
                         const HandleParameters          *handle,
                         int x, int y, int width, int height)
 {
-	const CairoColor *fill  = &colors->bg[params->state_type];
+	ClearlooksStyleFunctions *style_functions;
+	const CairoColor *fill;
 	int num_bars = 6; /* shut up gcc warnings */
+	GtkStateFlags state;
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"background-color", &fill,
+				NULL);
 
 	cairo_save (cr);
 
@@ -2071,7 +2365,7 @@ clearlooks_draw_handle (cairo_t *cr,
 		break;
 	}
 
-	if (params->prelight)
+	if (state & GTK_STATE_FLAG_PRELIGHT)
 	{
 		cairo_rectangle (cr, x, y, width, height);
 		ge_cairo_set_color (cr, fill);
@@ -2084,31 +2378,32 @@ clearlooks_draw_handle (cairo_t *cr,
 
 	if (handle->horizontal)
 	{
-		params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, num_bars, 2, 0.1);
+		style_functions->draw_gripdots (cr, engine, 0, 0, width, height, num_bars, 2, 0.1);
 	}
 	else
 	{
-		params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, 2, num_bars, 0.1);
+		style_functions->draw_gripdots (cr, engine, 0, 0, width, height, 2, num_bars, 0.1);
 	}
 
 	cairo_restore (cr);
+
+	gdk_rgba_free ((GdkRGBA *) fill);
 }
 
 static void
 clearlooks_draw_resize_grip (cairo_t *cr,
-                             const ClearlooksColors          *colors,
-                             const WidgetParameters          *widget,
+			     GtkThemingEngine                *engine,
                              const ResizeGripParameters      *grip,
                              int x, int y, int width, int height)
 {
-	const CairoColor *dark   = &colors->shade[4];
-	CairoColor hilight;
+	CairoColor dark, hilight;
 	int lx, ly;
 	int x_down;
 	int y_down;
 	int dots;
 
-	ge_shade_color (dark, 1.5, &hilight);
+	clearlooks_lookup_shade (engine, 4, (GdkRGBA *) &dark);
+	ge_shade_color (&dark, 1.5, &hilight);
 
 	/* The number of dots fitting into the area. Just hardcoded to 4 right now. */
 	/* dots = MIN (width - 2, height - 2) / 3; */
@@ -2155,7 +2450,7 @@ clearlooks_draw_resize_grip (cairo_t *cr,
 			cairo_rectangle (cr, mx*3-1, my*3-1, 2, 2);
 			cairo_fill (cr);
 
-			ge_cairo_set_color (cr, dark);
+			ge_cairo_set_color (cr, &dark);
 			cairo_rectangle (cr, mx*3-1, my*3-1, 1, 1);
 			cairo_fill (cr);
 		}
@@ -2166,19 +2461,18 @@ clearlooks_draw_resize_grip (cairo_t *cr,
 
 static void
 clearlooks_draw_radiobutton (cairo_t *cr,
-                             const ClearlooksColors  *colors,
-                             const WidgetParameters  *widget,
+			     GtkThemingEngine         *engine,
                              const CheckboxParameters *checkbox,
                              int x, int y, int width, int height)
 {
-	const CairoColor *border;
-	const CairoColor *dot;
+	CairoColor *bg_color, border, dot;
 	CairoColor shadow;
 	CairoColor highlight;
 	cairo_pattern_t *pt;
 	gboolean inconsistent;
 	gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
 	gdouble w, h, cx, cy, radius;
+	GtkStateFlags state;
 
 	w = (gdouble) width;
 	h = (gdouble) height;
@@ -2186,22 +2480,35 @@ clearlooks_draw_radiobutton (cairo_t *cr,
 	cy = height / 2.0;
 	radius = MIN (width, height) / 2.0;
 
+	state = gtk_theming_engine_get_state (engine);
+
+	gtk_theming_engine_get (engine, state,
+				"background-color", &bg_color,
+				NULL);
+
 	inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
 	draw_bullet |= inconsistent;
 
-	if (widget->disabled)
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
 	{
-		border = &colors->shade[5];
-		dot    = &colors->shade[6];
+		clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border);
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &dot);
 	}
 	else
 	{
-		border = &colors->shade[6];
-		dot    = &colors->text[0];
+		CairoColor *color;
+
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border);
+
+		gtk_theming_engine_get (engine, state,
+					"color", &color,
+					NULL);
+		dot = *color;
+		gdk_rgba_free ((GdkRGBA *) color);
 	}
 
-	ge_shade_color (&widget->parentbg, 0.9, &shadow);
-	ge_shade_color (&widget->parentbg, 1.1, &highlight);
+	ge_shade_color (bg_color, 0.9, &shadow);
+	ge_shade_color (bg_color, 1.1, &highlight);
 
 	pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
 	cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
@@ -2221,13 +2528,13 @@ clearlooks_draw_radiobutton (cairo_t *cr,
 
 	cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
 
-	if (!widget->disabled)
+	if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
 	{
-		ge_cairo_set_color (cr, &colors->base[0]);
+		ge_cairo_set_color (cr, bg_color);
 		cairo_fill_preserve (cr);
 	}
 
-	ge_cairo_set_color (cr, border);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 
 	if (draw_bullet)
@@ -2242,13 +2549,13 @@ clearlooks_draw_radiobutton (cairo_t *cr,
 			cairo_move_to (cr, ceil (cx - radius/3.0 - line_width) + line_width, ceil (cy - line_width) + line_width);
 			cairo_line_to (cr, floor (cx + radius/3.0 + line_width) - line_width, ceil (cy - line_width) + line_width);
 
-			ge_cairo_set_color (cr, dot);
+			ge_cairo_set_color (cr, &dot);
 			cairo_stroke (cr);
 		}
 		else
 		{
 			cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
-			ge_cairo_set_color (cr, dot);
+			ge_cairo_set_color (cr, &dot);
 			cairo_fill (cr);
 
 			cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
@@ -2256,57 +2563,75 @@ clearlooks_draw_radiobutton (cairo_t *cr,
 			cairo_fill (cr);
 		}
 	}
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
 clearlooks_draw_checkbox (cairo_t *cr,
-                          const ClearlooksColors  *colors,
-                          const WidgetParameters  *widget,
+			  GtkThemingEngine         *engine,
                           const CheckboxParameters *checkbox,
                           int x, int y, int width, int height)
 {
-	const CairoColor *border;
-	const CairoColor *dot;
+	CairoColor *bg_color, border, dot;
 	gboolean inconsistent = FALSE;
 	gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
+	GtkStateFlags state;
+	gdouble radius;
 
 	inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
 	draw_bullet |= inconsistent;
 
-	if (widget->disabled)
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &radius,
+				"background-color", &bg_color,
+				NULL);
+
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
 	{
-		border = &colors->shade[5];
-		dot    = &colors->shade[6];
+		clearlooks_lookup_shade (engine, 5, (GdkRGBA *) &border);
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &dot);
 	}
 	else
 	{
-		border = &colors->shade[6];
-		dot    = &colors->text[GTK_STATE_NORMAL];
+		CairoColor *color;
+
+		clearlooks_lookup_shade (engine, 6, (GdkRGBA *) &border);
+
+		gtk_theming_engine_get (engine, state,
+					"color", &color,
+					NULL);
+
+		dot = *color;
+		gdk_rgba_free ((GdkRGBA *) color);
 	}
 
 	cairo_translate (cr, x, y);
 	cairo_set_line_width (cr, 1);
 
+#if 0
 	if (widget->xthickness >= 3 && widget->ythickness >= 3)
 	{
 		widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0, width, height, 1, CR_CORNER_ALL);
 
 		/* Draw the rectangle for the checkbox itself */
-		ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
+		ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (radius > 0)? 1 : 0, CR_CORNER_ALL);
 	}
 	else
+#endif
 	{
 		/* Draw the rectangle for the checkbox itself */
-		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
+		ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (radius > 0)? 1 : 0, CR_CORNER_ALL);
 	}
 
-	if (!widget->disabled)
+	if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
 	{
-		ge_cairo_set_color (cr, &colors->base[0]);
+		ge_cairo_set_color (cr, bg_color);
 		cairo_fill_preserve (cr);
 	}
 
-	ge_cairo_set_color (cr, border);
+	ge_cairo_set_color (cr, &border);
 	cairo_stroke (cr);
 
 	if (draw_bullet)
@@ -2329,9 +2654,11 @@ clearlooks_draw_checkbox (cairo_t *cr,
 
 		}
 
-		ge_cairo_set_color (cr, dot);
+		ge_cairo_set_color (cr, &dot);
 		cairo_stroke (cr);
 	}
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
 
 static void
@@ -2415,21 +2742,28 @@ _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
 
 static void
 clearlooks_draw_arrow (cairo_t *cr,
-                       const ClearlooksColors *colors,
-                       const WidgetParameters *widget,
+		       GtkThemingEngine       *engine,
                        const ArrowParameters  *arrow,
                        int x, int y, int width, int height)
 {
-	const CairoColor *color = &colors->fg[widget->state_type];
+	GtkStateFlags state;
+	CairoColor *color;
 	gdouble tx, ty;
 
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"color", &color,
+				NULL);
 	tx = x + width/2.0;
 	ty = y + height/2.0;
 
-	if (widget->disabled)
+	if (state & GTK_STATE_FLAG_INSENSITIVE)
 	{
+		CairoColor shade;
+
                 cairo_save (cr);
-		_clearlooks_draw_arrow (cr, &colors->shade[0],
+		clearlooks_lookup_shade (engine, 0, (GdkRGBA *) &shade);
+		_clearlooks_draw_arrow (cr, &shade,
 		                        arrow->direction, arrow->type,
 		                        tx+0.5, ty+0.5, width, height);
                 cairo_restore (cr);
@@ -2437,12 +2771,13 @@ clearlooks_draw_arrow (cairo_t *cr,
 
 	_clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
 	                        tx, ty, width, height);
+
+	gdk_rgba_free ((GdkRGBA *) color);
 }
 
 void
 clearlooks_draw_focus (cairo_t *cr,
-                       const ClearlooksColors *colors,
-                       const WidgetParameters *widget,
+		       GtkThemingEngine       *engine,
                        const FocusParameters  *focus,
                        int x, int y, int width, int height)
 {
@@ -2453,11 +2788,17 @@ clearlooks_draw_focus (cairo_t *cr,
 	else if (focus->type == CL_FOCUS_COLOR_WHEEL_DARK)
 		cairo_set_source_rgb (cr, 1., 1., 1.);
 	else
-		cairo_set_source_rgba (cr,
-		                       colors->fg[widget->state_type].r,
-		                       colors->fg[widget->state_type].g,
-		                       colors->fg[widget->state_type].b,
-		                       0.7);
+	{
+		GdkRGBA *color;
+
+		gtk_theming_engine_get (engine,
+					gtk_theming_engine_get_state (engine),
+					"color", &color,
+					NULL);
+		color->alpha = 0.7;
+		gdk_cairo_set_source_rgba (cr, color);
+		gdk_rgba_free (color);
+	}
 
 	cairo_set_line_width (cr, focus->line_width);
 
@@ -2509,6 +2850,75 @@ clearlooks_set_mixed_color (cairo_t          *cr,
 }
 
 void
+clearlooks_lookup_shade (GtkThemingEngine *engine,
+			 guint             shade_number,
+			 GdkRGBA          *color)
+{
+	gdouble shades[] = { 1.15, 0.95, 0.896, 0.82, 0.7, 0.665, 0.475, 0.45, 0.4 };
+	gdouble contrast, shade;
+	GdkRGBA *bg_color;
+
+	if (shade_number >= G_N_ELEMENTS (shades)) {
+		shade_number = G_N_ELEMENTS (shades) - 1;
+	}
+
+	gtk_theming_engine_get (engine, 0,
+				"-clearlooks-contrast", &contrast,
+				"background-color", &bg_color,
+				NULL);
+
+	shade = shades[shade_number];
+
+	/* Lighter to darker */
+	ge_shade_color ((CairoColor *) bg_color,
+			(shade < 1.0) ? (shade / contrast) : (shade * contrast),
+			(CairoColor *) color);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
+}
+
+void
+clearlooks_lookup_spot (GtkThemingEngine *engine,
+			guint             spot_number,
+			GdkRGBA          *color)
+{
+	gdouble spots[] = { 1.25, 1.05, 0.65 };
+	GdkRGBA *bg_color;
+
+	if (spot_number >= G_N_ELEMENTS (spots)) {
+		spot_number = G_N_ELEMENTS (spots) - 1;
+	}
+
+	gtk_theming_engine_get (engine,
+				GTK_STATE_FLAG_ACTIVE,
+				"background-color", &bg_color,
+				NULL);
+
+	/* Lighter to darker */
+	ge_shade_color ((CairoColor *) bg_color, spots[spot_number], (CairoColor *) color);
+
+	gdk_rgba_free ((GdkRGBA *) bg_color);
+}
+
+void
+clearlooks_lookup_functions (ClearlooksEngine          *engine,
+			     ClearlooksStyleFunctions **functions,
+			     ClearlooksStyleConstants **constants)
+{
+	ClearlooksStyle style;
+
+	gtk_theming_engine_get (GTK_THEMING_ENGINE (engine), 0,
+				"-clearlooks-style", &style,
+				NULL);
+
+	if (functions)
+		*functions = &engine->style_functions[style];
+
+	if (constants)
+		*constants = &engine->style_constants[style];
+}
+
+void
 clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
 {
 	g_assert (functions);
diff --git a/src/clearlooks_draw.h b/src/clearlooks_draw.h
index 51eed33..38cca47 100644
--- a/src/clearlooks_draw.h
+++ b/src/clearlooks_draw.h
@@ -25,6 +25,7 @@
 #define CLEARLOOKS_DRAW_H
 
 #include "clearlooks_types.h"
+#include "clearlooks_engine.h"
 
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
@@ -37,10 +38,20 @@ GE_INTERNAL void clearlooks_register_style_gummy (ClearlooksStyleFunctions *func
 GE_INTERNAL void clearlooks_register_style_inverted (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
 GE_INTERNAL void clearlooks_register_style_gnome3 (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants);
 
+void clearlooks_lookup_functions (ClearlooksEngine          *engine,
+				  ClearlooksStyleFunctions **functions,
+				  ClearlooksStyleConstants **constants);
+
+void clearlooks_lookup_shade (GtkThemingEngine *engine,
+			      guint             shade_number,
+			      GdkRGBA          *color);
+void clearlooks_lookup_spot  (GtkThemingEngine *engine,
+			      guint             spot_number,
+			      GdkRGBA          *color);
+
 /* Fallback focus function */
 GE_INTERNAL void clearlooks_draw_focus (cairo_t *cr,
-                                        const ClearlooksColors *colors,
-                                        const WidgetParameters *widget,
+					GtkThemingEngine       *engine,
                                         const FocusParameters  *focus,
                                         int x, int y, int width, int height);
 
diff --git a/src/clearlooks_types.h b/src/clearlooks_types.h
index ec7c024..eae5cdf 100644
--- a/src/clearlooks_types.h
+++ b/src/clearlooks_types.h
@@ -337,65 +337,53 @@ struct _ClearlooksStyleConstants
 struct _ClearlooksStyleFunctions
 {
 	void (*draw_top_left_highlight) (cairo_t *cr,
-	                               const CairoColor *color,
-	                               const WidgetParameters *params,
-                                       int x, int y, int width, int height,
-                                       gdouble radius,
-                                       CairoCorners corners);
+					 const CairoColor *color,
+					 GtkThemingEngine *engine,
+					 int x, int y, int width, int height);
 
 	void (*draw_button)           (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_scale_trough)     (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const SliderParameters *slider,
 	                               int x, int y, int width, int height);
 
 	void (*draw_progressbar_trough) (cairo_t 	*cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
-	                               int x, int y, int width, int height);
+					 GtkThemingEngine *engine,
+					 int x, int y, int width, int height);
 
 	void (*draw_progressbar_fill) (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ProgressBarParameters	*progressbar,
 	                               int x, int y, int width, int height, gint offset);
 
 	void (*draw_slider_button)    (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const SliderParameters *slider,
 	                               int x, int y, int width, int height);
 
 	void (*draw_entry)            (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const FocusParameters  *focus,
 	                               int x, int y, int width, int height);
 
 	void (*draw_entry_progress)   (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const EntryProgressParameters *progress,
 	                               int x, int y, int width, int height);
 
 	void (*draw_spinbutton)       (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_spinbutton_down)  (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_optionmenu)       (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const OptionMenuParameters *optionmenu,
 	                               int x, int y, int width, int height);
 
@@ -405,150 +393,127 @@ struct _ClearlooksStyleFunctions
 	                                double radius, uint8 corners);
 
 	void (*draw_menubar)          (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const MenuBarParameters *menubar,
 	                               int x, int y, int width, int height);
 
 	void (*draw_tab)              (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const TabParameters *tab,
 	                               int x, int y, int width, int height);
 
 	void (*draw_frame)            (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const FrameParameters *frame,
 	                               int x, int y, int width, int height);
 
 	void (*draw_separator)        (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const SeparatorParameters *separator,
 	                               int x, int y, int width, int height);
 
 	void (*draw_menu_item_separator) (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+					  GtkThemingEngine *engine,
 	                               const SeparatorParameters *separator,
 	                               int x, int y, int width, int height);
 
 	void (*draw_list_view_header) (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ListViewHeaderParameters *header,
 	                               int x, int y, int width, int height);
 
 	void (*draw_toolbar)          (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ToolbarParameters *toolbar,
 	                               int x, int y, int width, int height);
 
 	void (*draw_menuitem)         (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_menubaritem)      (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_selected_cell)    (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_scrollbar_stepper) (cairo_t *cr,
-	                                const ClearlooksColors	*colors,
-	                                const WidgetParameters	*widget,
+					GtkThemingEngine *engine,
 	                                const ScrollBarParameters *scrollbar,
 	                                const ScrollBarStepperParameters *stepper,
 	                                int x, int y, int width, int height);
 
 	void (*draw_scrollbar_slider) (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ScrollBarParameters	*scrollbar,
 	                               int x, int y, int width, int height);
 
 	void (*draw_scrollbar_trough) (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ScrollBarParameters	*scrollbar,
 	                               int x, int y, int width, int height);
 
 	void (*draw_statusbar)        (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_menu_frame)       (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_tooltip)          (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_handle)           (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const HandleParameters *handle,
 	                               int x, int y, int width, int height);
 
 	void (*draw_resize_grip)      (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ResizeGripParameters	*grip,
 	                               int x, int y, int width, int height);
 
 	void (*draw_arrow)            (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const ArrowParameters *arrow,
 	                               int x, int y, int width, int height);
 
 	void (*draw_focus)            (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const FocusParameters *focus,
 	                               int x, int y, int width, int height);
 
 	void (*draw_checkbox)         (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const CheckboxParameters	*checkbox,
 	                               int x, int y, int width, int height);
 
 	void (*draw_radiobutton)      (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               const CheckboxParameters	*checkbox,
 	                               int x, int y, int width, int height);
 
 	void (*draw_icon_view_item)   (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	/* Style internal functions */
 	/* XXX: Only used by slider_button, inline it? */
 	void (*draw_shadow)           (cairo_t *cr,
-	                               const ClearlooksColors *colors,
+				       GtkThemingEngine *engine,
 	                               gfloat radius, int width, int height);
 
 	void (*draw_slider)           (cairo_t *cr,
-	                               const ClearlooksColors *colors,
-	                               const WidgetParameters *widget,
+				       GtkThemingEngine *engine,
 	                               int x, int y, int width, int height);
 
 	void (*draw_gripdots)         (cairo_t *cr,
-	                               const ClearlooksColors *colors, int x, int y,
+				       GtkThemingEngine *engine,
+	                               int x, int y,
 	                               int width, int height, int xr, int yr,
 	                               float contrast);
 };



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