Fixes for GCC 4.3.
[ardour.git] / libs / clearlooks / clearlooks_style.c
index 241f14c6e4c1c75fc03434d7e339b7e1ddc7a1e5..48b6647df382449690da0e3fa7d002cc9ea2d07c 100644 (file)
@@ -1,22 +1,38 @@
+/* Clearlooks theme engine
+ * Copyright (C) 2005 Richard Stellingwerff.
+ * Copyright (C) 2007 Benjamin Berg <benjamin@sipsolutions.net>.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
 #include <gtk/gtk.h>
+#include <cairo.h>
+#include <math.h>
+#include <string.h>
 
+#include <ge-support.h>
 #include "clearlooks_style.h"
 #include "clearlooks_rc_style.h"
 #include "clearlooks_draw.h"
-
-#include <math.h>
-#include <string.h>
-
-#include "bits.c"
 #include "support.h"
-//#include "config.h"
 
 /* #define DEBUG 1 */
 
-#define SCALE_SIZE 5
-
 #define DETAIL(xx)   ((detail) && (!strcmp(xx, detail)))
-#define COMPARE_COLORS(a,b) (a.red == b.red && a.green == b.green && a.blue == b.blue)
 
 #define DRAW_ARGS    GtkStyle       *style, \
                      GdkWindow      *window, \
                      gint            width, \
                      gint            height
 
-static GdkGC *realize_color (GtkStyle * style, GdkColor * color);
-static GtkStyleClass *parent_class;
-static GList *progressbars = NULL;
-static gint8 pboffset = 10;
-static int timer_id = 0;
-
-static void cl_progressbar_remove (gpointer data)
-{
-       if (g_list_find (progressbars, data) == NULL)
-               return;
-
-       progressbars = g_list_remove (progressbars, data);
-       g_object_unref (data);
-       
-       if (g_list_first(progressbars) == NULL) {
-               g_source_remove(timer_id);
-               timer_id = 0;
-       }
-}
-
-static void update_progressbar (gpointer data, gpointer user_data)
-{
-       gfloat fraction;
+#ifdef HAVE_ANIMATION
+#include "animation.h"
+#endif
 
-       if (data == NULL)
-               return;
+#define STYLE_FUNCTION(function) (clearlooks_style_class->style_functions[CLEARLOOKS_STYLE (style)->style].function)
 
-       fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (data));
-       
-       /* update only if not filled */
-       if (fraction < 1.0)
-               gtk_widget_queue_resize ((GtkWidget*)data);
-       
-       if (fraction >= 1.0 || GTK_PROGRESS (data)->activity_mode)
-               cl_progressbar_remove (data);
-}
+static ClearlooksStyleClass *clearlooks_style_class;
+static GtkStyleClass *clearlooks_parent_class;
 
-static gboolean timer_func (gpointer data)
+static void
+clearlooks_set_widget_parameters (const GtkWidget      *widget,
+                                  const GtkStyle       *style,
+                                  GtkStateType          state_type,
+                                  WidgetParameters     *params)
 {
-       g_list_foreach (progressbars, update_progressbar, NULL);
-       if (--pboffset < 0) pboffset = 9;
-       return (g_list_first(progressbars) != NULL);
+       params->style_functions = &(clearlooks_style_class->style_functions[CLEARLOOKS_STYLE (style)->style]);
+
+       params->active      = (state_type == GTK_STATE_ACTIVE);
+       params->prelight    = (state_type == GTK_STATE_PRELIGHT);
+       params->disabled    = (state_type == GTK_STATE_INSENSITIVE);                    
+       params->state_type  = (ClearlooksStateType)state_type;
+       params->corners     = CR_CORNER_ALL;
+       params->ltr         = ge_widget_is_ltr ((GtkWidget*)widget);
+       params->focus       = widget && GTK_WIDGET_HAS_FOCUS (widget);
+       params->is_default  = widget && GE_WIDGET_HAS_DEFAULT (widget);
+       params->enable_glow = FALSE;
+       params->radius      = CLEARLOOKS_STYLE (style)->radius;
+
+       if (!params->active && widget && GE_IS_TOGGLE_BUTTON (widget))
+               params->active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+               
+       params->xthickness = style->xthickness;
+       params->ythickness = style->ythickness;
+               
+       /* This is used in GtkEntry to fake transparency. The reason to do this
+        * is that the entry has it's entire background filled with base[STATE].
+        * This is not a very good solution as it will eg. fail if one changes
+        * the background color of a notebook. */
+       params->parentbg = CLEARLOOKS_STYLE (style)->colors.bg[state_type];
+       clearlooks_get_parent_bg (widget, &params->parentbg);
 }
 
-static gboolean cl_progressbar_known(gconstpointer data)
+static void
+clearlooks_style_draw_flat_box (DRAW_ARGS)
 {
-       return (g_list_find (progressbars, data) != NULL);
-}
+       if (detail &&   
+           state_type == GTK_STATE_SELECTED && (
+           !strncmp ("cell_even", detail, 9) ||
+           !strncmp ("cell_odd", detail, 8)))
+       {
+               WidgetParameters params;
+               ClearlooksStyle  *clearlooks_style;
+               ClearlooksColors *colors;
+               cairo_t          *cr;
 
+               CHECK_ARGS
+               SANITIZE_SIZE
 
-static void cl_progressbar_add (gpointer data)
-{
-       if (!GTK_IS_PROGRESS_BAR (data))
-               return;
+               clearlooks_style = CLEARLOOKS_STYLE (style);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               colors = &clearlooks_style->colors;
+               cr = ge_gdk_drawable_to_cairo (window, area);
 
-       progressbars = g_list_append (progressbars, data);
+               /* XXX: We could expose the side details by setting params->corners accordingly
+                *      or adding another option. */
+               STYLE_FUNCTION (draw_selected_cell) (cr, colors, &params, x, y, width, height);
 
-       g_object_ref (data);
-       g_signal_connect ((GObject*)data, "unrealize", G_CALLBACK (cl_progressbar_remove), data);
-       
-       if (timer_id == 0)
-               timer_id = g_timeout_add (100, timer_func, NULL);
-}
+               cairo_destroy (cr);
+       }
+       else if (DETAIL ("tooltip"))
+       {
+               WidgetParameters params;
+               ClearlooksStyle  *clearlooks_style;
+               ClearlooksColors *colors;
+               cairo_t          *cr;
 
-static GdkColor *
-clearlooks_get_spot_color (ClearlooksRcStyle *clearlooks_rc)
-{
-       GtkRcStyle *rc = GTK_RC_STYLE (clearlooks_rc);
-       
-       if (clearlooks_rc->has_spot_color)
-               return &clearlooks_rc->spot_color;
-       else
-               return &rc->base[GTK_STATE_SELECTED];
-}
+               CHECK_ARGS
+               SANITIZE_SIZE
 
-/**************************************************************************/
+               clearlooks_style = CLEARLOOKS_STYLE (style);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               colors = &clearlooks_style->colors;
+               cr = ge_gdk_drawable_to_cairo (window, area);
 
-/* used for optionmenus... */
-static void
-draw_tab (GtkStyle      *style,
-         GdkWindow     *window,
-         GtkStateType   state_type,
-         GtkShadowType  shadow_type,
-         GdkRectangle  *area,
-         GtkWidget     *widget,
-         const gchar   *detail,
-         gint           x,
-         gint           y,
-         gint           width,
-         gint           height)
-{
-#define ARROW_SPACE 2
-#define ARROW_LINE_HEIGHT 2
-#define ARROW_LINE_WIDTH 5
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GtkRequisition indicator_size;
-       GtkBorder indicator_spacing;
-       gint arrow_height;
-       
-       option_menu_get_props (widget, &indicator_size, &indicator_spacing);
-       
-       indicator_size.width += (indicator_size.width % 2) - 1;
-       arrow_height = indicator_size.width / 2 + 2;
-       
-       x += (width - indicator_size.width) / 2;
-       y += height/2;
+               STYLE_FUNCTION (draw_tooltip) (cr, colors, &params, x, y, width, height);
 
-       if (state_type == GTK_STATE_INSENSITIVE)
+               cairo_destroy (cr);
+       }
+       else if ((CLEARLOOKS_STYLE (style)->style == CL_STYLE_GLOSSY || CLEARLOOKS_STYLE (style)->style == CL_STYLE_GUMMY) &&
+                ((DETAIL("checkbutton") || DETAIL("radiobutton")) && state_type == GTK_STATE_PRELIGHT))
        {
-               draw_arrow (window, style->light_gc[state_type], area,
-                           GTK_ARROW_UP, 1+x, 1+y-arrow_height,
-                           indicator_size.width, arrow_height);
-
-               draw_arrow (window, style->light_gc[state_type], area,
-                           GTK_ARROW_DOWN, 1+x, 1+y+1,
-                           indicator_size.width, arrow_height);
+               /* XXX: Don't draw any check/radiobutton bg in GLOSSY or GUMMY mode. */
+       }
+       else
+       {
+               clearlooks_parent_class->draw_flat_box (style, window, state_type,
+                                            shadow_type,
+                                            area, widget, detail,
+                                            x, y, width, height);
        }
-       
-       draw_arrow (window, style->fg_gc[state_type], area,
-                   GTK_ARROW_UP, x, y-arrow_height,
-                   indicator_size.width, arrow_height);
-       
-       draw_arrow (window, style->fg_gc[state_type], area,
-                   GTK_ARROW_DOWN, x, y+1,
-                   indicator_size.width, arrow_height);
 }
 
 static void
-clearlooks_draw_arrow (GtkStyle      *style,
-                       GdkWindow     *window,
-                       GtkStateType   state,
-                       GtkShadowType  shadow,
-                       GdkRectangle  *area,
-                       GtkWidget     *widget,
-                       const gchar   *detail,
-                       GtkArrowType   arrow_type,
-                       gboolean       fill,
-                       gint           x,
-                       gint           y,
-                       gint           width,
-                       gint           height)
+clearlooks_style_draw_shadow (DRAW_ARGS)
 {
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       gint original_width, original_x;
-       GdkGC *gc;
-       
-       sanitize_size (window, &width, &height);
-       
-       if (is_combo_box (widget))
+       ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       cairo_t          *cr     = ge_gdk_drawable_to_cairo (window, area);
+
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       if ((DETAIL ("entry") && !(widget && widget->parent && GE_IS_TREE_VIEW (widget->parent))) ||
+           (DETAIL ("frame") && ge_is_in_combo_box (widget)))
        {
-               width = 7;
-               height = 5;
-               x+=2;
-               y+=4;
-               if (state == GTK_STATE_INSENSITIVE)
-               {
-                       draw_arrow (window, style->light_gc[state], area,
-                                   GTK_ARROW_UP, 1+x, 1+y-height,
-                                   width, height);
+               WidgetParameters params;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+
+               /* Override the entries state type, because we are too lame to handle this via
+                * the focus ring, and GtkEntry doesn't even set the INSENSITIVE state ... */
+               if (state_type == GTK_STATE_NORMAL && widget && GE_IS_ENTRY (widget))
+                       params.state_type = GTK_WIDGET_STATE (widget);
 
-                       draw_arrow (window, style->light_gc[state], area,
-                                   GTK_ARROW_DOWN, 1+x, 1+y+1,
-                                   width, height);
+               if (widget && (ge_is_in_combo_box (widget) || GE_IS_SPIN_BUTTON (widget)))
+               {
+                       width += style->xthickness;
+                       if (!params.ltr)
+                               x -= style->xthickness;
+                       
+                       if (params.ltr)
+                               params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
+                       else
+                               params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
                }
-       
-               draw_arrow (window, style->fg_gc[state], area,
-                           GTK_ARROW_UP, x, y-height,
-                           width, height);
-       
-               draw_arrow (window, style->fg_gc[state], area,
-                           GTK_ARROW_DOWN, x, y+1,
-                           width, height);
                
-               return;
+               STYLE_FUNCTION (draw_entry) (cr, &clearlooks_style->colors, &params,
+                                      x, y, width, height);
        }
-       
-       original_width = width;
-       original_x = x;
-       
-       /* Make spinbutton arrows and arrows in menus
-       * slightly larger to get the right pixels drawn */
-       if (DETAIL ("spinbutton"))
-               height += 1;
-       
-       if (DETAIL("menuitem"))
+       else if (DETAIL ("frame") && widget && GE_IS_STATUSBAR (widget->parent))
        {
-               width = 6;
-               height = 7;
+               WidgetParameters params;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+
+               gtk_style_apply_default_background (style, window, TRUE, state_type,
+                                                   area, x, y, width, height);
+               
+               STYLE_FUNCTION (draw_statusbar) (cr, colors, &params,
+                                          x, y, width, height);
        }
+       else if (DETAIL ("frame"))
+       {
+               WidgetParameters params;
+               FrameParameters  frame;
+               frame.shadow  = shadow_type;
+               frame.gap_x   = -1;                 /* No gap will be drawn */
+               frame.border  = &colors->shade[4];
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners = CR_CORNER_NONE;
        
-       /* Compensate arrow position for "sunken" look */ 
-       if (DETAIL ("spinbutton") && arrow_type == GTK_ARROW_DOWN &&
-           style->xthickness > 2 && style->ythickness > 2)
-                       y -= 1;
-       
-       if (widget && widget->parent && GTK_IS_COMBO (widget->parent->parent))
+               if (widget && !g_str_equal ("XfcePanelWindow", gtk_widget_get_name (gtk_widget_get_toplevel (widget))))
+                       STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame,
+                                              x, y, width, height);
+       }
+       else if (DETAIL ("scrolled_window") || DETAIL ("viewport") || detail == NULL)
        {
-               width -= 2;
-               height -=2;
-               x++;
+               CairoColor *border = (CairoColor*)&colors->shade[5];
+               cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
+               ge_cairo_set_color (cr, border);
+               cairo_set_line_width (cr, 1);
+               cairo_stroke (cr);
        }
-       
-       calculate_arrow_geometry (arrow_type, &x, &y, &width, &height);
-       
-       if (DETAIL ("menuitem"))
-               x = original_x + original_width - width;
-       
-       if (DETAIL ("spinbutton") && (arrow_type == GTK_ARROW_DOWN))
-               y += 1;
-       
-       if (state == GTK_STATE_INSENSITIVE)
-               draw_arrow (window, style->light_gc[state], area, arrow_type, x + 1, y + 1, width, height);
+       else
+       {
+               WidgetParameters params;
+               FrameParameters frame;
 
-       gc = style->fg_gc[state];
+               frame.shadow = shadow_type;
+               frame.gap_x  = -1;
+               frame.border = &colors->shade[5];
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners = CR_CORNER_ALL;
                
-       draw_arrow (window, gc, area, arrow_type, x, y, width, height);
+               STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame, x, y, width, height);
+       }
+       
+       cairo_destroy (cr);
 }
 
-
-static void
-draw_flat_box (DRAW_ARGS)
+static void 
+clearlooks_style_draw_box_gap (DRAW_ARGS,
+                 GtkPositionType gap_side,
+                 gint            gap_x,
+                 gint            gap_width)
 {
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       cairo_t          *cr;
 
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
+       CHECK_ARGS
+       SANITIZE_SIZE
 
-       sanitize_size (window, &width, &height);
+       cr = ge_gdk_drawable_to_cairo (window, area);
 
-       if (detail &&   
-           clearlooks_style->listviewitemstyle == 1 && 
-           state_type == GTK_STATE_SELECTED && (
-           !strncmp ("cell_even", detail, strlen ("cell_even")) ||
-           !strncmp ("cell_odd", detail, strlen ("cell_odd"))))
+       if (DETAIL ("notebook"))
        {
-               GdkGC    *gc;
-               GdkColor  lower_color;
-               GdkColor *upper_color;
-
-               if (GTK_WIDGET_HAS_FOCUS (widget))
-               {
-                       gc = style->base_gc[state_type];
-                       upper_color = &style->base[state_type];
-               }
-               else
-               {
-                       gc = style->base_gc[GTK_STATE_ACTIVE];
-                       upper_color = &style->base[GTK_STATE_ACTIVE];
-               }
+               WidgetParameters params;
+               FrameParameters  frame;
+               gboolean start, end;
                
-               if (GTK_IS_TREE_VIEW (widget) && 0)
-               {
-                       GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+               frame.shadow    = shadow_type;
+               frame.gap_side  = gap_side;
+               frame.gap_x     = gap_x;
+               frame.gap_width = gap_width;
+               frame.border    = &colors->shade[5];
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
 
-                       if (gtk_tree_selection_count_selected_rows (sel) > 1)
-                       {
-                               parent_class->draw_flat_box (style, window, state_type, shadow_type,
-                                                            area, widget, detail,
-                                                            x, y, width, height);
-                               return;
-                       }
+               clearlooks_get_notebook_tab_position (widget, &start, &end);
+
+               params.corners = CR_CORNER_ALL;
+               switch (gap_side) {
+                       case GTK_POS_LEFT:
+                               if (start)
+                                       params.corners ^= CR_CORNER_TOPLEFT;
+                               if (end)
+                                       params.corners ^= CR_CORNER_BOTTOMLEFT;
+                       break;
+                       case GTK_POS_RIGHT:
+                               if (start)
+                                       params.corners ^= CR_CORNER_TOPRIGHT;
+                               if (end)
+                                       params.corners ^= CR_CORNER_BOTTOMRIGHT;
+                       break;
+                       case GTK_POS_TOP:
+                               if (ge_widget_is_ltr (widget)) {
+                                       if (start)
+                                               params.corners ^= CR_CORNER_TOPLEFT;
+                                       if (end)
+                                               params.corners ^= CR_CORNER_TOPRIGHT;
+                               } else {
+                                       if (start)
+                                               params.corners ^= CR_CORNER_TOPRIGHT;
+                                       if (end)
+                                               params.corners ^= CR_CORNER_TOPLEFT;
+                               }
+                       break;
+                       case GTK_POS_BOTTOM:
+                               if (ge_widget_is_ltr (widget)) {
+                                       if (start)
+                                               params.corners ^= CR_CORNER_BOTTOMLEFT;
+                                       if (end)
+                                               params.corners ^= CR_CORNER_BOTTOMRIGHT;
+                               } else {
+                                       if (start)
+                                               params.corners ^= CR_CORNER_BOTTOMRIGHT;
+                                       if (end)
+                                               params.corners ^= CR_CORNER_BOTTOMLEFT;
+                               }
+                       break;
                }
-               
-               shade (upper_color, &lower_color, 0.8);
 
-               if (area)
-                       gdk_gc_set_clip_rectangle (gc, area);
+               /* Fill the background with bg[NORMAL] */
+               ge_cairo_rounded_rectangle (cr, x, y, width, height, params.radius, params.corners);
+               ge_cairo_set_color (cr, &colors->bg[GTK_STATE_NORMAL]);
+               cairo_fill (cr);
                
-               draw_hgradient (window, gc, style,
-                               x, y, width, height, upper_color, &lower_color);
-
-               if (area)
-                       gdk_gc_set_clip_rectangle (gc, NULL);
+               STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame,
+                                      x, y, width, height);
        }
        else
        {
-               parent_class->draw_flat_box (style, window, state_type,
-                                            shadow_type,
-                                            area, widget, detail,
-                                            x, y, width, height);
+               clearlooks_parent_class->draw_box_gap (style, window, state_type, shadow_type,
+                                                                          area, widget, detail,
+                                                                          x, y, width, height,
+                                                                          gap_side, gap_x, gap_width);
        }
+       
+       cairo_destroy (cr);     
 }
-/**************************************************************************/
 
 static void
-draw_shadow (DRAW_ARGS)
+clearlooks_style_draw_extension (DRAW_ARGS, GtkPositionType gap_side)
 {
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       CLRectangle r;
-       
-       GdkGC *outer_gc = clearlooks_style->shade_gc[4];
-       GdkGC *gc1 = NULL;
-       GdkGC *gc2 = NULL;
-       gint thickness_light;
-       gint thickness_dark;
-       gboolean interior_focus = FALSE;
-
-#if DEBUG
-               printf("draw_shadow: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
-
-       if (widget == NULL)
-       {
-               gdk_draw_rectangle (window, outer_gc, FALSE,
-                                   x, y, width - 1, height - 1);
-               return;
-       }
-
-       if ((width == -1) && (height == -1))
-               gdk_window_get_size (window, &width, &height);
-       else if (width == -1)
-               gdk_window_get_size (window, &width, NULL);
-       else if (height == -1)
-               gdk_window_get_size (window, NULL, &height);
+       ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       cairo_t          *cr;
 
-       cl_rectangle_reset (&r, style);
+       CHECK_ARGS
+       SANITIZE_SIZE
 
-       if (DETAIL ("frame") && widget->parent &&
-           GTK_IS_STATUSBAR (widget->parent))
+       cr = ge_gdk_drawable_to_cairo (window, area);
+       
+       if (DETAIL ("tab"))
        {
-               gtk_style_apply_default_background (style, window,widget && !GTK_WIDGET_NO_WINDOW (widget),
-                                                   state_type, area, x, y, width, height);
-      
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], area);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], area);
-               }
+               WidgetParameters params;
+               TabParameters    tab;
                
-               gdk_draw_line (window, clearlooks_style->shade_gc[3],
-                              x, y, x + width, y);
-               gdk_draw_line (window, clearlooks_style->shade_gc[0],
-                              x, y + 1, x + width, y + 1);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
                
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], NULL);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], NULL);
-               }
-       }
-       else if (detail && !strcmp (detail, "entry"))
-       {
-               if ( widget->parent && (GTK_IS_COMBO_BOX_ENTRY (widget->parent) ||
-                                       GTK_IS_SPIN_BUTTON(widget) ||
-                                       GTK_IS_COMBO (widget->parent)))
-               {
-                       cl_draw_combobox_entry (style, window, GTK_WIDGET_STATE(widget), shadow_type, area, widget, detail, x, y, width, height);
-               }
-               else
+               tab.gap_side = (ClearlooksGapSide)gap_side;
+               
+               switch (gap_side)
                {
-                       cl_draw_entry (style, window, GTK_WIDGET_STATE(widget), shadow_type, area, widget, detail, x, y, width, height);
+                       case CL_GAP_BOTTOM:
+                               params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
+                               break;
+                       case CL_GAP_TOP:
+                               params.corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
+                               break;
+                       case CL_GAP_RIGHT:
+                               params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
+                               break;
+                       case CL_GAP_LEFT:
+                               params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
                }
-       }
-       else if (DETAIL ("viewport") || DETAIL ("scrolled_window"))
-       {
-               gdk_draw_rectangle (window, clearlooks_style->shade_gc[4], FALSE,
-                                   x, y, width - 1, height - 1);
+               
+               STYLE_FUNCTION(draw_tab) (cr, colors, &params, &tab,
+                                    x, y, width, height);
        }
        else
        {
-               if (DETAIL ("menuitem"))
-                       outer_gc = clearlooks_style->spot3_gc;
-               else
-                       outer_gc = clearlooks_style->shade_gc[4];
-
-               if (shadow_type == GTK_SHADOW_IN)
-                       gdk_draw_rectangle (window, outer_gc, FALSE,
-                                           x, y, width - 1, height - 1);
-               else if (shadow_type == GTK_SHADOW_OUT)
-               {
-                       gdk_draw_rectangle (window, outer_gc, FALSE,
-                                           x, y, width - 1, height - 1);
-                       gdk_draw_line (window, style->light_gc[state_type],
-                                      x+1, y+1, x+width-2, y+1);
-                       gdk_draw_line (window, style->light_gc[state_type],
-                                      x+1, y+1, x+1, y+height-2);
-               }
-               else if (shadow_type == GTK_SHADOW_ETCHED_IN)
-               {
-                       GdkGC *a = clearlooks_style->shade_gc[(shadow_type == GTK_SHADOW_ETCHED_IN) ? 0 : 3];
-                       GdkGC *b = clearlooks_style->shade_gc[(shadow_type == GTK_SHADOW_ETCHED_IN) ? 3 : 0];
-       
-                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                     CL_CORNER_NONE, CL_CORNER_NONE);
-
-                       r.bordergc = a;
-                       cl_rectangle_set_clip_rectangle (&r, area);
-                       cl_draw_rectangle (window, widget, style, x+1, y+1, width-1, height-1, &r);
-                       cl_rectangle_reset_clip_rectangle (&r);
-       
-                       r.bordergc = b;
-                       cl_rectangle_set_clip_rectangle (&r, area);
-                       cl_draw_rectangle (window, widget, style, x, y, width-1, height-1, &r); 
-                       cl_rectangle_reset_clip_rectangle (&r);
-               }
-               else if (shadow_type == GTK_SHADOW_ETCHED_IN)
-               {
-                       GdkGC *a = clearlooks_style->shade_gc[(shadow_type == GTK_SHADOW_ETCHED_IN) ? 3 : 0];
-                       GdkGC *b = clearlooks_style->shade_gc[(shadow_type == GTK_SHADOW_ETCHED_IN) ? 0 : 3];
-       
-                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                     CL_CORNER_NONE, CL_CORNER_NONE);
+               clearlooks_parent_class->draw_extension (style, window, state_type, shadow_type, area,
+                                             widget, detail, x, y, width, height,
+                                             gap_side);
 
-                       r.bordergc = a;
-                       cl_rectangle_set_clip_rectangle (&r, area);
-                       cl_draw_rectangle (window, widget, style, x+1, y+1, width-1, height-1, &r);
-                       cl_rectangle_reset_clip_rectangle (&r);
-       
-                       r.bordergc = b;
-                       cl_rectangle_set_clip_rectangle (&r, area);
-                       cl_draw_rectangle (window, widget, style, x, y, width-1, height-1, &r); 
-                       cl_rectangle_reset_clip_rectangle (&r);
-               }               
-               else
-                       parent_class->draw_shadow (style, window, state_type, shadow_type,
-                                                  area, widget, detail,
-                                                  x, y, width, height);
        }
+       
+       cairo_destroy (cr);
 }
 
-#define GDK_RECTANGLE_SET(rect,a,b,c,d) rect.x = a; \
-                                        rect.y = b; \
-                                        rect.width = c; \
-                                        rect.height = d;
-
-
 static void 
-draw_box_gap (DRAW_ARGS,
-             GtkPositionType gap_side,
-             gint            gap_x,
-             gint            gap_width)
+clearlooks_style_draw_handle (DRAW_ARGS, GtkOrientation orientation)
 {
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       CLRectangle r;
+       ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       cairo_t          *cr;
+       gboolean         is_horizontal;
        
-       GdkRegion *area_region = NULL,
-                 *gap_region  = NULL;
-       GdkRectangle light_rect;
-       GdkRectangle dark_rect;
-
-#if DEBUG
-               printf("draw_box_gap: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
+       CHECK_ARGS
+       SANITIZE_SIZE
        
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
+       cr = ge_gdk_drawable_to_cairo (window, area);
+       
+       /* Evil hack to work around broken orientation for toolbars */
+       is_horizontal = (width > height);
        
-       sanitize_size (window, &width, &height);
+       if (DETAIL ("handlebox"))
+       {
+               WidgetParameters params;
+               HandleParameters handle;
 
-       cl_rectangle_reset (&r, style);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               handle.type = CL_HANDLE_TOOLBAR;
+               handle.horizontal = is_horizontal;
+               
+               /* Is this ever true? -Daniel */
+               if (GE_IS_TOOLBAR (widget) && shadow_type != GTK_SHADOW_NONE)
+               {
+                       ToolbarParameters toolbar;
 
-       r.bordergc = clearlooks_style->shade_gc[5];
+                       clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y);
 
-       r.topleft     = style->light_gc[state_type];
-       r.bottomright = clearlooks_style->shade_gc[1];
+                       toolbar.style = clearlooks_style->toolbarstyle;
 
-       if (area)
-               area_region = gdk_region_rectangle (area);
-       else
-       {
-               GdkRectangle tmp = { x, y, width, height };
-               area_region = gdk_region_rectangle (&tmp);
+                       cairo_save (cr);
+                       STYLE_FUNCTION(draw_toolbar) (cr, colors, &params, &toolbar, x, y, width, height);
+                       cairo_restore (cr);
+               }
+               
+               STYLE_FUNCTION(draw_handle) (cr, colors, &params, &handle,
+                                       x, y, width, height);
        }
-       
-       switch (gap_side)
+       else if (DETAIL ("paned"))
        {
-               case GTK_POS_TOP:
-               {
-                       GdkRectangle rect = { x+gap_x+1, y, gap_width-2, 2 };
-                       gap_region = gdk_region_rectangle (&rect);
+               WidgetParameters params;
+               HandleParameters handle;
 
-                       GDK_RECTANGLE_SET (light_rect, x+gap_x+1, y, x+gap_x+1, y+1);
-                       GDK_RECTANGLE_SET (dark_rect, x+gap_x+gap_width-2, y, x+gap_x+gap_width-2, y);
-                               
-                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                     CL_CORNER_ROUND, CL_CORNER_ROUND);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               handle.type = CL_HANDLE_SPLITTER;
+               handle.horizontal = orientation == GTK_ORIENTATION_HORIZONTAL;
+                       
+               STYLE_FUNCTION(draw_handle) (cr, colors, &params, &handle,
+                                       x, y, width, height);
+       }
+       else
+       {
+               WidgetParameters params;
+               HandleParameters handle;
 
-                       break;
-               }
-               case GTK_POS_BOTTOM:
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               handle.type = CL_HANDLE_TOOLBAR;
+               handle.horizontal = is_horizontal;
+               
+               /* Is this ever true? -Daniel */
+               if (GE_IS_TOOLBAR (widget) && shadow_type != GTK_SHADOW_NONE)
                {
-                       GdkRectangle rect = { x+gap_x+1, y+height-2, gap_width-2, 2 };
-                       gap_region = gdk_region_rectangle (&rect);
-                               
-                       GDK_RECTANGLE_SET (light_rect, x+gap_x+1, y+height-2, x+gap_x+1, y+height-1);
-                       GDK_RECTANGLE_SET (dark_rect, x+gap_x+gap_width-2, y+height-2, x+gap_x+gap_width-2, y+height-1);
+                       ToolbarParameters toolbar;
 
-                       cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_ROUND,
-                                                     CL_CORNER_NONE, CL_CORNER_NONE);
+                       clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y);
 
-                       break;
+                       toolbar.style = clearlooks_style->toolbarstyle;
+
+                       cairo_save (cr);
+                       STYLE_FUNCTION(draw_toolbar) (cr, colors, &params, &toolbar, x, y, width, height);
+                       cairo_restore (cr);
                }
-               case GTK_POS_LEFT:
-               {
-                       GdkRectangle rect = { x, y+gap_x+1, 2, gap_width-2 };
-                       gap_region = gdk_region_rectangle (&rect);
-                               
-                       GDK_RECTANGLE_SET (light_rect, x, y+gap_x+1, x+1, y+gap_x+1);
-                       GDK_RECTANGLE_SET (dark_rect, x, y+gap_x+gap_width-2, x, y+gap_x+gap_width-2);
-
-                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_ROUND,
-                                                     CL_CORNER_NONE, CL_CORNER_ROUND);
-                       break;
-               }               
-               case GTK_POS_RIGHT:
-               {
-                       GdkRectangle rect = { x+width-2, y+gap_x+1, 2, gap_width-2 };
-                       gap_region = gdk_region_rectangle (&rect);
-                               
-                       GDK_RECTANGLE_SET (light_rect, x+width-2, y+gap_x+1, x+width-1, y+gap_x+1);
-                       GDK_RECTANGLE_SET (dark_rect, x+width-2, y+gap_x+gap_width-2, x+width-1, y+gap_x+gap_width-2);
-
-                       cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_NONE,
-                                                     CL_CORNER_ROUND, CL_CORNER_NONE);
-                       break;
-               }               
-       }
                
-       gdk_region_subtract (area_region, gap_region);
-               
-       gdk_gc_set_clip_region (r.bordergc,    area_region);
-       gdk_gc_set_clip_region (r.topleft,     area_region);
-       gdk_gc_set_clip_region (r.bottomright, area_region);
-       
-       gdk_region_destroy (area_region);
-       gdk_region_destroy (gap_region);
-       
-       gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE, x, y, width, height);
-
-       cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-
-       cl_draw_shadow (window, widget, style, x, y, width, height, &r); 
+               STYLE_FUNCTION(draw_handle) (cr, colors, &params, &handle,
+                                       x, y, width, height);
+       }
 
-       gdk_gc_set_clip_region (r.bordergc,    NULL);
-       gdk_gc_set_clip_region (r.topleft,     NULL);
-       gdk_gc_set_clip_region (r.bottomright, NULL);
-       
-       /* it's a semi hack */
-       gdk_draw_line (window, style->light_gc[state_type],
-                      light_rect.x, light_rect.y,
-                      light_rect.width, light_rect.height);
-               
-       gdk_draw_line (window, clearlooks_style->shade_gc[1],
-                      dark_rect.x, dark_rect.y,
-                      dark_rect.width, dark_rect.height);
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
-
 static void
-draw_extension (DRAW_ARGS, GtkPositionType gap_side)
+clearlooks_style_draw_box (DRAW_ARGS)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       int              my_state_type = (state_type == GTK_STATE_ACTIVE) ? 2 : 0;
-       CLRectangle      r;
+       const ClearlooksColors *colors;
+       cairo_t *cr;
 
-#if DEBUG
-               printf("draw_extension: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
+       cr     = ge_gdk_drawable_to_cairo (window, area);
+       colors = &clearlooks_style->colors;
 
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
-       
-       sanitize_size (window, &width, &height);
-       
-       if (DETAIL ("tab"))
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       if (DETAIL ("menubar") && !ge_is_panel_widget_item(widget))
        {
-               GdkRectangle new_area;
-               GdkColor tmp_color;
+               WidgetParameters params;
+               MenuBarParameters menubar;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
 
-               cl_rectangle_set_button (&r, style, state_type, FALSE, FALSE,
-                                                               CL_CORNER_ROUND, CL_CORNER_ROUND,
-                                                               CL_CORNER_ROUND, CL_CORNER_ROUND);
+               menubar.style = clearlooks_style->menubarstyle;
+
+               STYLE_FUNCTION(draw_menubar) (cr, colors, &params, &menubar,
+                                        x, y, width, height);
+       }
+       else if (DETAIL ("button") && widget && widget->parent &&
+                  (GE_IS_TREE_VIEW(widget->parent) ||
+                   GE_IS_CLIST (widget->parent) ||
+                   ge_object_is_a (G_OBJECT(widget->parent), "ETree"))) /* ECanvas inside ETree */
+       {
+               WidgetParameters params;
+               ListViewHeaderParameters header;
                
-               if (state_type == GTK_STATE_ACTIVE)
-                       shade (&style->bg[state_type], &tmp_color, 1.08);
-               else
-                       shade (&style->bg[state_type], &tmp_color, 1.05);
+               gint columns, column_index;
+               gboolean resizable = TRUE;
                
-               if (area)
+               /* XXX: This makes unknown treeview header CL_ORDER_MIDDLE, in need for something nicer */
+               columns = 3;
+               column_index = 1;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               
+               params.corners = CR_CORNER_NONE;
+               
+               if (GE_IS_TREE_VIEW (widget->parent))
                {
-                       new_area = *area;
+                       clearlooks_treeview_get_header_index (GTK_TREE_VIEW(widget->parent),
+                                                                                  widget, &column_index, &columns,
+                                                                                  &resizable);
                }
-               else
+               else if (GE_IS_CLIST (widget->parent))
                {
-                       new_area.x = x;
-                       new_area.y = y;
-                       new_area.width = width;
-                       new_area.height = height;
+                       clearlooks_clist_get_header_index (GTK_CLIST(widget->parent),
+                                                                               widget, &column_index, &columns);
                }
                
-               switch (gap_side)
-               {
-                       case GTK_POS_BOTTOM:
-                               height+=2;
-                               new_area.y = y;
-                               new_area.height = height-2;
-                               r.gradient_type = CL_GRADIENT_VERTICAL;
-                               cl_rectangle_set_gradient (&r.fill_gradient, &tmp_color, &style->bg[state_type]);
-                               cl_rectangle_set_gradient (&r.border_gradient,
-                                              &clearlooks_style->border[CL_BORDER_UPPER+my_state_type],
-                                              &clearlooks_style->border[CL_BORDER_LOWER+my_state_type]);
-                               break;
-                       case GTK_POS_TOP:
-                               y-=2;
-                               height+=2;
-                               new_area.y = y+2;
-                               new_area.height = height;
-                               r.gradient_type = CL_GRADIENT_VERTICAL;
-                               cl_rectangle_set_gradient (&r.fill_gradient, &style->bg[state_type], &tmp_color);
-                               cl_rectangle_set_gradient (&r.border_gradient,
-                                              &clearlooks_style->border[CL_BORDER_LOWER+my_state_type],
-                                              &clearlooks_style->border[CL_BORDER_UPPER+my_state_type]);
-                               break;
-                       case GTK_POS_LEFT:
-                               x-=2;
-                               width+=2;
-                               new_area.x = x+2;
-                               new_area.width = width;
-                               r.gradient_type = CL_GRADIENT_HORIZONTAL;
-                               cl_rectangle_set_gradient (&r.fill_gradient, &style->bg[state_type], &tmp_color);
-                               cl_rectangle_set_gradient (&r.border_gradient,
-                                              &clearlooks_style->border[CL_BORDER_LOWER+my_state_type],
-                                              &clearlooks_style->border[CL_BORDER_UPPER+my_state_type]);
-                               break;
-                       case GTK_POS_RIGHT:
-                               width+=2;
-                               new_area.x = x;
-                               new_area.width = width-2;
-                               r.gradient_type = CL_GRADIENT_HORIZONTAL;
-                               cl_rectangle_set_gradient (&r.fill_gradient, &tmp_color, &style->bg[state_type]);
-                               cl_rectangle_set_gradient (&r.border_gradient,
-                                              &clearlooks_style->border[CL_BORDER_UPPER+my_state_type],
-                                              &clearlooks_style->border[CL_BORDER_LOWER+my_state_type]);
-                               break;
-               }
+               header.resizable = resizable;
                
-               r.topleft = style->light_gc[state_type];                
-               r.bottomright = (state_type == GTK_STATE_NORMAL) ? clearlooks_style->shade_gc[1] : NULL;
-
-               cl_rectangle_set_clip_rectangle (&r, &new_area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r);
+               if (column_index == 0)
+                       header.order = params.ltr ? CL_ORDER_FIRST : CL_ORDER_LAST;
+               else if (column_index == columns-1)
+                       header.order = params.ltr ? CL_ORDER_LAST : CL_ORDER_FIRST;
+               else
+                       header.order = CL_ORDER_MIDDLE;
                
-               /* draw the selection stripe */
-               if (state_type != GTK_STATE_ACTIVE) {
-                       cl_rectangle_set_gradient (&r.fill_gradient, NULL, NULL);
-                       r.fillgc = clearlooks_style->spot2_gc;
-                       
-                       switch (gap_side)
-                       {
-                               case GTK_POS_BOTTOM:
-                                       cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_ROUND,
-                                                                     CL_CORNER_NONE, CL_CORNER_NONE);
-                                       cl_rectangle_set_gradient (&r.border_gradient, &clearlooks_style->spot3, &clearlooks_style->spot2);
-                                       r.gradient_type = CL_GRADIENT_VERTICAL;
-
-                                       cl_rectangle_set_clip_rectangle (&r, &new_area);
-                                       cl_draw_rectangle (window, widget, style, x, y, width, 3, &r);
-                                       cl_rectangle_reset_clip_rectangle (&r);
-                                       break;
-                               case GTK_POS_TOP:
-                                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                                     CL_CORNER_ROUND, CL_CORNER_ROUND);
-                                       cl_rectangle_set_gradient (&r.border_gradient, &clearlooks_style->spot2, &clearlooks_style->spot3);
-                                       r.gradient_type = CL_GRADIENT_VERTICAL;
-
-                                       cl_rectangle_set_clip_rectangle (&r, &new_area);
-                                       cl_draw_rectangle (window, widget, style, x, y + height - 3, width, 3, &r);
-                                       cl_rectangle_reset_clip_rectangle (&r);
-                                       break;
-                               case GTK_POS_LEFT:
-                                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_ROUND,
-                                                                     CL_CORNER_NONE, CL_CORNER_ROUND);
-                                       cl_rectangle_set_gradient (&r.border_gradient, &clearlooks_style->spot2, &clearlooks_style->spot3);
-                                       r.gradient_type = CL_GRADIENT_HORIZONTAL;
-
-                                       cl_rectangle_set_clip_rectangle (&r, &new_area);
-                                       cl_draw_rectangle (window, widget, style, x + width - 3, y, 3, height, &r);
-                                       cl_rectangle_reset_clip_rectangle (&r);
-                                       break;
-                               case GTK_POS_RIGHT:
-                                       cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_NONE,
-                                                                     CL_CORNER_ROUND, CL_CORNER_NONE);
-                                       cl_rectangle_set_gradient (&r.border_gradient, &clearlooks_style->spot3, &clearlooks_style->spot2);
-                                       r.gradient_type = CL_GRADIENT_HORIZONTAL;
-                               
-                                       cl_rectangle_set_clip_rectangle (&r, &new_area);
-                                       cl_draw_rectangle (window, widget, style, x, y, 3, height, &r);
-                                       cl_rectangle_reset_clip_rectangle (&r);
-                                       break;
-                       }
-               }
+               gtk_style_apply_default_background (style, window, FALSE, state_type, area, x, y, width, height);
                
-
+               STYLE_FUNCTION(draw_list_view_header) (cr, colors, &params, &header,
+                                                 x, y, width, height);
        }
-       else
+       else if (DETAIL ("button") || DETAIL ("buttondefault"))
        {
-               parent_class->draw_extension (style, window, state_type, shadow_type, area,
-                                             widget, detail, x, y, width, height,
-                                             gap_side);
-       }
-}
-    
-
-/**************************************************************************/
-
-static void 
-draw_handle (DRAW_ARGS, GtkOrientation orientation)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       gint xx, yy;
-       gint xthick, ythick;
-       GdkGC *light_gc, *dark_gc;
-       GdkRectangle rect;
-       GdkRectangle dest;
-       gint intersect;
-       gint h;
-       int i;
-       int n_lines;
-       int offset;
-       
-#if DEBUG
-               printf("draw_handle: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
-
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
-       
-       sanitize_size (window, &width, &height);
-       
-       if (state_type == GTK_STATE_PRELIGHT)
-               gtk_style_apply_default_background (style, window,
-                                         widget && !GTK_WIDGET_NO_WINDOW (widget),
-                                         state_type, area, x, y, width, height);
+               WidgetParameters params;
+               ShadowParameters shadow = { CR_CORNER_ALL, CL_SHADOW_NONE } ;
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
 
-       /* orientation is totally bugged, but this actually works... */
-       orientation = (width > height) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
-
-       if (!strcmp (detail, "paned"))
-       {
-               /* we want to ignore the shadow border in paned widgets */
-               xthick = 0;
-               ythick = 0;
-       }
-       else
-       {
-               xthick = style->xthickness;
-               ythick = style->ythickness;
-       }
-
-       if ( ((DETAIL ("handlebox") && widget && GTK_IS_HANDLE_BOX (widget)) || DETAIL ("dockitem")) &&
-            orientation == GTK_ORIENTATION_VERTICAL )
-       {
-               /* The line in the toolbar */
-       
-               light_gc = style->light_gc[state_type];
-               dark_gc = clearlooks_style->shade_gc[3];
-               
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (light_gc, area);
-                       gdk_gc_set_clip_rectangle (dark_gc, area);
-               }
-     
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (light_gc, NULL);
-                       gdk_gc_set_clip_rectangle (dark_gc, NULL);
-               }
-
-               if (area)
+               if (ge_is_in_combo_box(widget))
                {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], area);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], area);
-               }
-      
-               gdk_draw_line (window, clearlooks_style->shade_gc[0], x, y, x + width, y);
-               gdk_draw_line (window, clearlooks_style->shade_gc[3], x, y + height - 1, x + width, y + height - 1);
+                       if (params.ltr)
+                               params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
+                       else
+                               params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
                        
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], NULL);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], NULL);
-               }
-       }
-       
-       light_gc = clearlooks_style->shade_gc[0];
-       dark_gc = clearlooks_style->shade_gc[4];
-
-       rect.x = x + xthick;
-       rect.y = y + ythick;
-       rect.width = width - (xthick * 2);
-       rect.height = height - (ythick * 2);
-       
-       if (area)
-               intersect = gdk_rectangle_intersect (area, &rect, &dest);
-       else
-       {
-               intersect = TRUE;
-               dest = rect;
-       }
-
-       if (!intersect)
-               return;
-
-       gdk_gc_set_clip_rectangle (light_gc, &dest);
-       gdk_gc_set_clip_rectangle (dark_gc, &dest);
-       
-       n_lines = (!strcmp (detail, "paned")) ? 21 : 11;
+                       shadow.shadow = CL_SHADOW_IN;
 
-       if (orientation == GTK_ORIENTATION_VERTICAL)
-       {       
-               h = width - 2 * xthick;
-               h = MAX (3, h - 6);
-               
-               xx = x + (width - h) / 2;
-               offset = (height - 2*ythick - 2*n_lines)/2 + 1;
-               if (offset < 0)
-                       offset = 0;
-                       
-               for (i = 0, yy = y + ythick + offset; yy <= (y + height - ythick - 1) && i < n_lines; yy += 2, i++)
-               {
-                       gdk_draw_line (window, dark_gc, xx, yy, xx + h, yy);
-                       gdk_draw_line (window, light_gc, xx, yy + 1, xx + h, yy + 1);
+                       if (params.xthickness > 2)
+                       {
+                               if (params.ltr)
+                                       x--;
+                               width++;
+                       }                       
                }
-       }
-       else
-       {
-               h = height - 2 * ythick;
-               h = MAX (3, h - 6);
-               
-               yy = y + (height - h) / 2;
-               offset = (width - 2*xthick - 2*n_lines)/2 + 1;
-               if (offset < 0)
-                       offset = 0;
-               
-               for (i = 0, xx = x + xthick + offset;  i < n_lines; xx += 2, i++)
+               else
                {
-                       gdk_draw_line (window, dark_gc, xx, yy, xx, yy + h);
-                       gdk_draw_line (window, light_gc, xx + 1, yy, xx + 1, yy + h);
-               }
-       }
-
-       gdk_gc_set_clip_rectangle (light_gc, NULL);
-       gdk_gc_set_clip_rectangle (dark_gc, NULL);
-}
-
-/**************************************************************************/
-
-static void
-draw_box (DRAW_ARGS)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       CLRectangle r;
-       gboolean false_size = FALSE;
-
-#ifdef DEBUG
-               printf("draw_box: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
+                       params.corners    = CR_CORNER_ALL;
+                       /* if (!(ge_is_combo_box (widget, FALSE))) */
+                       params.enable_glow = TRUE;
+               }               
        
-       g_return_if_fail (style != NULL);
-       g_return_if_fail (window != NULL);
-
-       if (width == -1 || height == -1)
-               false_size = TRUE;
+               if (GE_IS_TOGGLE_BUTTON (widget) &&
+                   gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+                       params.active = TRUE;
                
-       if ((width == -1) && (height == -1))
-               gdk_window_get_size (window, &width, &height);
-       else if (width == -1)
-               gdk_window_get_size (window, &width, NULL);
-       else if (height == -1)
-               gdk_window_get_size (window, NULL, &height);
-
-       cl_rectangle_reset (&r, style);
-
-       if (widget == NULL)
-               return;
-       
-       /* listview headers */
-       if (widget && DETAIL ("button") && widget->parent &&
-                (GTK_IS_TREE_VIEW(widget->parent) ||
-                 GTK_IS_CLIST (widget->parent) ||
-                         strcmp(G_OBJECT_TYPE_NAME (widget->parent), "ETree") == 0))
-       {
-               cl_draw_treeview_header (style, window, state_type, shadow_type,
-                                        area, widget, detail, x, y, width, height);
+               STYLE_FUNCTION(draw_button) (cr, &clearlooks_style->colors, &params,
+                                            x, y, width, height);
        }
-       else if (detail && (!strcmp (detail, "button") ||
-                               !strcmp (detail, "buttondefault")))
+       else if (DETAIL ("spinbutton_up") || DETAIL ("spinbutton_down"))
        {
-               if (GTK_IS_COMBO_BOX_ENTRY(widget->parent) || GTK_IS_COMBO(widget->parent))
-               {
-                       cl_draw_combobox_button (style, window, state_type, shadow_type,
-                                                area, widget,
-                                            detail, x, y, width, height);
-               }
-               else
-               {
-                       cl_draw_button (style, window, state_type, shadow_type, area, widget,
-                                   detail, x, y, width, height);
-               }
-       }
-       else if (detail && (
-                !strcmp (detail, "spinbutton_up") ||
-                !strcmp (detail, "spinbutton_down") ||
-                !strcmp (detail, "spinbutton")))
-       {               
-               cl_draw_spinbutton (style, window, state_type, shadow_type, area,
-                                   widget, detail, x, y, width, height);
-       }
-       else if (detail && (
-                    !strcmp (detail, "hscale") || !strcmp (detail, "vscale")))
-       {
-               cl_rectangle_set_button (&r, style, state_type,
-                               GTK_WIDGET_HAS_DEFAULT  (widget), GTK_WIDGET_HAS_FOCUS (widget),
-                               CL_CORNER_ROUND, CL_CORNER_ROUND,
-                               CL_CORNER_ROUND, CL_CORNER_ROUND);
-
-               if (!strcmp (detail, "hscale") || !strcmp (detail, "vscale"))
-               {
-                       r.fill_gradient.to = &clearlooks_style->shade[2];
-                       r.bottomright = clearlooks_style->shade_gc[2];
-               }
-               
-               cl_set_corner_sharpness (detail, widget, &r);
-
-               if (!strcmp (detail, "spinbutton_up"))
-               {
-                       r.border_gradient.to = r.border_gradient.from;
-                       height++;
-                       gtk_style_apply_default_background (style, window, FALSE, state_type,
-                                                           area, x, y, width, height);
-               }
-               else if (!strcmp (detail, "spinbutton_down"))
+               if (state_type == GTK_STATE_ACTIVE)
                {
-                       r.border_gradient.to = r.border_gradient.from;
-                       gtk_style_apply_default_background (style, window, FALSE, state_type,
-                                                           area, x, y, width, height);
-               }
-       
-               cl_rectangle_set_clip_rectangle (&r, area);     
-               cl_draw_rectangle (window, widget, style, x+1, y+1, width-2, height-2, &r);
-               cl_draw_shadow (window, widget, style, x+1, y+1, width-2, height-2, &r);
-               cl_rectangle_reset_clip_rectangle (&r);         
-       }
-       else if (DETAIL ("trough") && GTK_IS_PROGRESS_BAR (widget))
-       {
-               GdkPoint points[4] = { {x,y}, {x+width-1,y}, {x,y+height-1}, {x+width-1,y+height-1} };
-               
-               gdk_draw_points (window, style->bg_gc[state_type], points, 4);
-               
-               r.bordergc = clearlooks_style->shade_gc[5];
-               r.fillgc   = clearlooks_style->shade_gc[2];
+                       WidgetParameters params;
+                       clearlooks_set_widget_parameters (widget, style, state_type, &params);
                        
-               cl_rectangle_set_corners (&r, CL_CORNER_NARROW, CL_CORNER_NARROW,
-                                                 CL_CORNER_NARROW, CL_CORNER_NARROW);
-               
-               cl_rectangle_set_clip_rectangle (&r, area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r);
+                       if (style->xthickness == 3)
+                       {
+                               width++;
+                               if (params.ltr)
+                                       x--;
+                       }
+                       
+                       if (DETAIL ("spinbutton_up"))
+                       {
+                               height+=2;
+                               if (params.ltr)
+                                       params.corners = CR_CORNER_TOPRIGHT;
+                               else
+                                       params.corners = CR_CORNER_TOPLEFT;
+                       }
+                       else
+                       {
+                               if (params.ltr)
+                                       params.corners = CR_CORNER_BOTTOMRIGHT;
+                               else
+                                       params.corners = CR_CORNER_BOTTOMLEFT;
+                       }
+                       
+                       STYLE_FUNCTION(draw_spinbutton_down) (cr, &clearlooks_style->colors, &params, x, y, width, height);
+               }
        }
-       else if (DETAIL ("trough") &&
-                    (GTK_IS_VSCALE (widget) || GTK_IS_HSCALE (widget)))
+       else if (DETAIL ("spinbutton"))
        {
-               GdkGC   *inner  = clearlooks_style->shade_gc[3],
-                       *outer  = clearlooks_style->shade_gc[5],
-                           *shadow = clearlooks_style->shade_gc[4];
-               GdkColor upper_color = *clearlooks_get_spot_color (CLEARLOOKS_RC_STYLE (style->rc_style)),
-                                lower_color;
-               
-               GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
+               WidgetParameters params;
                
-               GtkOrientation orientation = GTK_RANGE (widget)->orientation;
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
                
-               gint fill_size = (orientation ? height : width) * 
-                                (1 / ((adjustment->upper - adjustment->lower) / 
-                                     (adjustment->value - adjustment->lower)));
-
-               if (orientation == GTK_ORIENTATION_HORIZONTAL)
-               {
-                       y += (height - SCALE_SIZE) / 2;
-                       height = SCALE_SIZE;
-               }
+               if (params.ltr)
+                       params.corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
                else
-               {
-                       x += (width - SCALE_SIZE) / 2;
-                       width = SCALE_SIZE;
-               }
+                       params.corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
                
-               if (state_type == GTK_STATE_INSENSITIVE)
+               if (style->xthickness == 3)
                {
-                       outer  = clearlooks_style->shade_gc[4];
-                       inner  = clearlooks_style->shade_gc[2];
-                       shadow = clearlooks_style->shade_gc[3];
+                       if (params.ltr)
+                               x--;
+                       width++;
                }
                
-               cl_rectangle_init (&r, inner, outer, CL_CORNER_NONE, CL_CORNER_NONE, 
-                                                    CL_CORNER_NONE, CL_CORNER_NONE );
+               STYLE_FUNCTION(draw_spinbutton) (cr, &clearlooks_style->colors, &params,
+                                           x, y, width, height);
+       }
+       else if (detail && g_str_has_prefix (detail, "trough") && GE_IS_SCALE (widget))
+       {
+               WidgetParameters params;
+               SliderParameters slider;
                
-               r.topleft = shadow;
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners    = CR_CORNER_NONE;
                
-               cl_rectangle_set_clip_rectangle (&r, area);     
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r); 
+               slider.lower = DETAIL ("trough-lower");
+               slider.fill_level = DETAIL ("trough-fill-level") || DETAIL ("trough-fill-level-full");
 
-               /* DRAW FILL */
-               shade (&upper_color, &lower_color, 1.3);
+               slider.horizontal = (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL);
                
-               r.bordergc = clearlooks_style->spot3_gc;
-               r.fillgc   = style->bg_gc[state_type];
-               
-               r.gradient_type = (orientation == GTK_ORIENTATION_HORIZONTAL ) ? CL_GRADIENT_VERTICAL
-                                                                                                                                          : CL_GRADIENT_HORIZONTAL;
+               STYLE_FUNCTION(draw_scale_trough) (cr, &clearlooks_style->colors,
+                                             &params, &slider,
+                                             x, y, width, height);
+       }
+       else if (DETAIL ("trough") && widget && GE_IS_PROGRESS_BAR (widget))
+       {
+               WidgetParameters params;
                
-               cl_rectangle_set_gradient (&r.fill_gradient, &upper_color, &lower_color);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);          
                
-               cl_rectangle_set_clip_rectangle (&r, area);     
-               if (orientation == GTK_ORIENTATION_HORIZONTAL && fill_size > 1)
-               {
-                       if (gtk_range_get_inverted(GTK_RANGE(widget)) != (get_direction(widget) == GTK_TEXT_DIR_RTL))
-                               cl_draw_rectangle (window, widget, style, x+width-fill_size, y, fill_size, height, &r);
-                       else
-                               cl_draw_rectangle (window, widget, style, x, y, fill_size, height, &r);                         
-               }
-               else if (fill_size > 1)
-               {
-                       if (gtk_range_get_inverted (GTK_RANGE (widget)))
-                               cl_draw_rectangle (window, widget, style, x, y+height-fill_size, width, fill_size, &r);
-                       else
-                               cl_draw_rectangle (window, widget, style, x, y, width, fill_size, &r);                  
-               }
-               cl_rectangle_reset_clip_rectangle (&r); 
+               STYLE_FUNCTION(draw_progressbar_trough) (cr, colors, &params, 
+                                                   x, y, width, height);
        }
-       else if (DETAIL ("trough"))
+       else if (DETAIL ("trough") && widget && (GE_IS_VSCROLLBAR (widget) || GE_IS_HSCROLLBAR (widget)))
        {
-               GdkGC *inner  = clearlooks_style->shade_gc[3],
-                     *outer  = clearlooks_style->shade_gc[5];  
+               WidgetParameters params;
+               ScrollBarParameters scrollbar;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners = CR_CORNER_NONE;
+               
+               scrollbar.horizontal = TRUE;
+               scrollbar.junction   = clearlooks_scrollbar_get_junction (widget);
                
-               cl_rectangle_init (&r, inner, outer, CL_CORNER_NONE, CL_CORNER_NONE, 
-                                                    CL_CORNER_NONE, CL_CORNER_NONE );
+               if (GE_IS_RANGE (widget))
+                       scrollbar.horizontal = GTK_RANGE (widget)->orientation == GTK_ORIENTATION_HORIZONTAL;
                
-               if (GTK_RANGE (widget)->orientation == GTK_ORIENTATION_VERTICAL)
+               if (scrollbar.horizontal)
                {
-                       y+=1;
-                       height-=2;
+                       x += 2;
+                       width -= 4;
                }
                else
                {
-                       x+=1;
-                       width-=2;
+                       y += 2;
+                       height -= 4;
                }
                
-               cl_rectangle_set_clip_rectangle (&r, area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r);
+               STYLE_FUNCTION(draw_scrollbar_trough) (cr, colors, &params, &scrollbar,
+                                                 x, y, width, height);
        }
-       else if (detail && (!strcmp (detail, "vscrollbar") ||
-                           !strcmp (detail, "hscrollbar") ||
-                           !strcmp (detail, "stepper")))
+       else if (DETAIL ("bar"))
        {
-               ClScrollButtonType button_type = CL_SCROLLBUTTON_OTHER;
-               gboolean horizontal = TRUE;
+               WidgetParameters      params;
+               ProgressBarParameters progressbar;
+               gdouble               elapsed = 0.0;
 
-               if (GTK_IS_VSCROLLBAR(widget))
-               {
-                       if (y == widget->allocation.y)
-                               button_type = CL_SCROLLBUTTON_BEGIN;
-                       else if (y+height == widget->allocation.y+widget->allocation.height)
-                               button_type = CL_SCROLLBUTTON_END;
-
-                       horizontal = FALSE;
-               }
-               else if (GTK_IS_HSCROLLBAR(widget))
-               {
-                       if (x == widget->allocation.x)
-                               button_type = CL_SCROLLBUTTON_BEGIN;
-                       else if (x+width == widget->allocation.x+widget->allocation.width)
-                               button_type = CL_SCROLLBUTTON_END;
+#ifdef HAVE_ANIMATION
+               if(clearlooks_style->animation && CL_IS_PROGRESS_BAR (widget))
+               {       
+                       gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode;
+                       
+                       if (!activity_mode)
+                               clearlooks_animation_progressbar_add ((gpointer)widget);
                }
 
-               cl_rectangle_set_button (&r, style, state_type, FALSE, FALSE, 0,0,0,0);
-               
-               cl_rectangle_set_gradient (&r.fill_gradient, NULL, NULL);
-               cl_rectangle_set_gradient (&r.fill_gradient, &clearlooks_style->inset_light[state_type],
-                                          &clearlooks_style->inset_dark[state_type]);
-       
-               
-               r.gradient_type = horizontal ? CL_GRADIENT_VERTICAL
-                                            : CL_GRADIENT_HORIZONTAL;
-               
-               r.bottomright = clearlooks_style->shade_gc[1];
-               r.border_gradient.to = r.border_gradient.from;
-               
-               if (button_type == CL_SCROLLBUTTON_OTHER)
-               {
-                       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                     CL_CORNER_NONE, CL_CORNER_NONE);
-               }
-               else if (button_type == CL_SCROLLBUTTON_BEGIN)
+               elapsed = clearlooks_animation_elapsed (widget);
+#endif
+
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+
+               if (widget && GE_IS_PROGRESS_BAR (widget))
                {
-                       if (horizontal)
-                               cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_NONE,
-                                                                                         CL_CORNER_ROUND, CL_CORNER_NONE);
-                       else
-                               cl_rectangle_set_corners (&r, CL_CORNER_ROUND, CL_CORNER_ROUND,
-                                                                                         CL_CORNER_NONE,  CL_CORNER_NONE);
+                       progressbar.orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget));
+                       progressbar.value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget));
+                       progressbar.pulsing = GTK_PROGRESS (widget)->activity_mode;
                }
                else
                {
-                       if (horizontal)
-                               cl_rectangle_set_corners (&r, CL_CORNER_NONE,  CL_CORNER_ROUND,
-                                                                                         CL_CORNER_NONE,  CL_CORNER_ROUND);
-                       else
-                               cl_rectangle_set_corners (&r, CL_CORNER_NONE,  CL_CORNER_NONE,
-                                                                                         CL_CORNER_ROUND, CL_CORNER_ROUND);
+                       progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT;
+                       progressbar.value = 0;
+                       progressbar.pulsing = FALSE;
                }
                
-               cl_rectangle_set_clip_rectangle (&r, area);     
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r); 
+               if (!params.ltr)
+               {
+                       if (progressbar.orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
+                               progressbar.orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
+                       else if (progressbar.orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+                               progressbar.orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
+               }
 
-       }
-       else if (DETAIL ("slider"))
-       {
-               if (DETAIL("slider") && widget && GTK_IS_RANGE (widget))
+               /* Following is a hack to have a larger clip area, the one passed in
+                * does not allow for the shadow. */
+               if (area)
                {
-                       GtkAdjustment *adj = GTK_RANGE (widget)->adjustment;
-                       
-                       if (adj->value <= adj->lower &&
-                               (GTK_RANGE (widget)->has_stepper_a || GTK_RANGE (widget)->has_stepper_b))
+                       GdkRectangle tmp = *area;
+                       if (!progressbar.pulsing)
                        {
-                               if (GTK_IS_VSCROLLBAR (widget))
-                               {
-                                       y-=1;
-                                       height+=1;
-                               }
-                               else if (GTK_IS_HSCROLLBAR (widget))
+                               switch (progressbar.orientation)
                                {
-                                       x-=1;
-                                       width+=1;
+                                       case GTK_PROGRESS_RIGHT_TO_LEFT:
+                                               tmp.x -= 1;
+                                       case GTK_PROGRESS_LEFT_TO_RIGHT:
+                                               tmp.width += 1;
+                                               break;
+                                       case GTK_PROGRESS_BOTTOM_TO_TOP:
+                                               tmp.y -= 1;
+                                       case GTK_PROGRESS_TOP_TO_BOTTOM:
+                                               tmp.height += 1;
+                                               break;
                                }
                        }
-                       if (adj->value >= adj->upper - adj->page_size &&
-                           (GTK_RANGE (widget)->has_stepper_c || GTK_RANGE (widget)->has_stepper_d))
+                       else
                        {
-                               if (GTK_IS_VSCROLLBAR (widget))
-                                       height+=1;
-                               else if (GTK_IS_HSCROLLBAR (widget))
-                                       width+=1;
+                               if (progressbar.orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
+                                   progressbar.orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
+                               {
+                                       tmp.x -= 1;
+                                       tmp.width += 2;
+                               }
+                               else
+                               {
+                                       tmp.y -= 1;
+                                       tmp.height += 2;
+                               }
                        }
-               }
                        
-               cl_rectangle_set_button (&r, style, state_type, FALSE, GTK_WIDGET_HAS_FOCUS (widget),
-                                       CL_CORNER_NONE, CL_CORNER_NONE,
-                                       CL_CORNER_NONE, CL_CORNER_NONE);
-               
-               r.gradient_type = GTK_IS_HSCROLLBAR (widget) ? CL_GRADIENT_VERTICAL
-                                                            : CL_GRADIENT_HORIZONTAL;
-
-               cl_rectangle_set_gradient (&r.fill_gradient, &clearlooks_style->inset_light[state_type],
-                                          &clearlooks_style->inset_dark[state_type]);
-
-               r.bottomright = clearlooks_style->shade_gc[1];
-               r.border_gradient.to = r.border_gradient.from;
+                       cairo_reset_clip (cr);
+                       gdk_cairo_rectangle (cr, &tmp);
+                       cairo_clip (cr);
+               }
                
-               cl_rectangle_set_clip_rectangle (&r, area);     
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r); 
+               STYLE_FUNCTION(draw_progressbar_fill) (cr, colors, &params, &progressbar,
+                                                 x, y, width, height,
+                                                 10 - (int)(elapsed * 10.0) % 10);
        }
-       else if (detail && !strcmp (detail, "optionmenu")) /* supporting deprecated */
+       else if (DETAIL ("optionmenu"))
        {
-               cl_draw_optionmenu(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+               WidgetParameters params;
+               OptionMenuParameters optionmenu;
+               
+               GtkRequisition indicator_size;
+               GtkBorder indicator_spacing;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               
+               params.enable_glow = TRUE;
+
+               ge_option_menu_get_props (widget, &indicator_size, &indicator_spacing);
+               
+               if (ge_widget_is_ltr (widget))
+                       optionmenu.linepos = width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - 1;
+               else
+                       optionmenu.linepos = (indicator_size.width + indicator_spacing.left + indicator_spacing.right) + 1;
+                       
+               STYLE_FUNCTION(draw_optionmenu) (cr, colors, &params, &optionmenu,
+                                                x, y, width, height);          
        }
        else if (DETAIL ("menuitem"))
        {
-               if (clearlooks_style->menuitemstyle == 0)
-               {
-                       cl_draw_menuitem_flat (window, widget, style, area, state_type,
-                                              x, y, width, height, &r);                        
-               }
-               else if (clearlooks_style->menuitemstyle == 1)
+               WidgetParameters params;
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               
+               if (widget && GE_IS_MENU_BAR (widget->parent))
                {
-                       cl_draw_menuitem_gradient (window, widget, style, area, state_type,
-                                                  x, y, width, height, &r);
+                       params.corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
+                       height += 1;
+                       STYLE_FUNCTION(draw_menubaritem) (cr, colors, &params, x, y, width, height);
                }
                else
-               {
-                       cl_draw_menuitem_button (window, widget, style, area, state_type,
-                                                x, y, width, height, &r);
+               {       
+                       params.corners = CR_CORNER_ALL;
+                       STYLE_FUNCTION(draw_menuitem) (cr, colors, &params, x, y, width, height);
                }
        }
-       else if (DETAIL ("menubar") && (clearlooks_style->sunkenmenubar || clearlooks_style->menubarstyle > 0))
+       else if (DETAIL ("hscrollbar") || DETAIL ("vscrollbar")) /* This can't be "stepper" for scrollbars ... */
        {
-               GdkGC *dark = clearlooks_style->shade_gc[2];
-               GdkColor upper_color, lower_color;
-               
-               /* don't draw sunken menubar on gnome panel
-                  IT'S A HACK! HORRIBLE HACK! HIDEOUS HACK!
-                  BUT IT WORKS FOR ME(tm)! */
-               if (widget->parent &&
-                       strcmp(G_OBJECT_TYPE_NAME (widget->parent), "PanelWidget") == 0)
-                       return;
-               
-               shade(&style->bg[state_type], &upper_color, 1.0);
-               shade(&style->bg[state_type], &lower_color, 0.95);
-       
-               cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                             CL_CORNER_NONE, CL_CORNER_NONE);
+               WidgetParameters    params;
+               ScrollBarParameters scrollbar;
+               ScrollBarStepperParameters stepper;
+               GdkRectangle this_rectangle;
                
-               r.fillgc = style->bg_gc[state_type];
-               r.bordergc = clearlooks_style->shade_gc[2];
-               r.gradient_type = CL_GRADIENT_VERTICAL;
+               this_rectangle.x = x;
+               this_rectangle.y = y;
+               this_rectangle.width  = width;
+               this_rectangle.height = height;
                
-               cl_rectangle_set_gradient (&r.border_gradient, &clearlooks_style->shade[2],
-                                                              &clearlooks_style->shade[3]);
-               cl_rectangle_set_gradient (&r.fill_gradient, &upper_color, &lower_color);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners = CR_CORNER_NONE;
                
-               /* make vertical and top borders invisible for style 2 */
-               if (clearlooks_style->menubarstyle == 2) {
-                       x--; width+=2;
-                       y--; height+=1;
-               }
-               
-               cl_rectangle_set_clip_rectangle (&r, area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r);
-       }
-       else if (DETAIL ("menu") && widget->parent &&
-                GDK_IS_WINDOW (widget->parent->window))
-       {       
-               cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                             CL_CORNER_NONE, CL_CORNER_NONE);
-               
-               r.bordergc    = clearlooks_style->border_gc[CL_BORDER_UPPER];
-               r.topleft     = style->light_gc[state_type];
-               r.bottomright = clearlooks_style->shade_gc[1];
-               
-               cl_rectangle_set_clip_rectangle (&r, area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r); 
+               scrollbar.has_color  = FALSE;
+               scrollbar.horizontal = TRUE;
+               scrollbar.junction   = clearlooks_scrollbar_get_junction (widget);
 
-               return;
-       }
-       else if (DETAIL ("bar") && widget && GTK_IS_PROGRESS_BAR (widget))
-       {
-               GdkColor upper_color = *clearlooks_get_spot_color (CLEARLOOKS_RC_STYLE (style->rc_style)),
-                        lower_color,
-                        prev_foreground;
-               gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode;
-               
-#ifdef HAVE_ANIMATION
-               if (!activity_mode && gtk_progress_bar_get_fraction (widget) != 1.0 &&
-                       !cl_progressbar_known((gconstpointer)widget))
-               {
-                       cl_progressbar_add ((gpointer)widget);
+               if (clearlooks_style->colorize_scrollbar || clearlooks_style->has_scrollbar_color) {
+                       scrollbar.has_color = TRUE;
                }
-#endif         
-               cl_progressbar_fill (window, widget, style, style->black_gc,
-                                    x, y, width, height,
-#ifdef HAVE_ANIMATION
-                                    activity_mode ? 0 : pboffset,
-#else
-                                    0,         
-#endif
-                                    area);
-               
-               cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                             CL_CORNER_NONE, CL_CORNER_NONE);
-               
-               r.bordergc = clearlooks_style->spot3_gc;
-               r.topleft = clearlooks_style->spot2_gc;
-               
-               prev_foreground = cl_gc_set_fg_color_shade (clearlooks_style->spot2_gc,
-                                                           style->colormap,
-                                                           &clearlooks_style->spot2,
-                                                           1.2);
 
-               cl_rectangle_set_clip_rectangle (&r, area);
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-               cl_rectangle_reset_clip_rectangle (&r);
+               scrollbar.horizontal = DETAIL ("hscrollbar");
                
-               gdk_gc_set_foreground (clearlooks_style->spot2_gc, &prev_foreground);
-       }
+               stepper.stepper = clearlooks_scrollbar_get_stepper (widget, &this_rectangle);
 
-       else if ( widget && (DETAIL ("menubar") || DETAIL ("toolbar") || DETAIL ("dockitem_bin") || DETAIL ("handlebox_bin")) && shadow_type != GTK_SHADOW_NONE) /* Toolbars and menus */
-       {
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], area);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], area);
-               }
-               
-               gtk_style_apply_default_background (style, window,
-                               widget && !GTK_WIDGET_NO_WINDOW (widget),
-                               state_type, area, x, y, width, height);
-               
-               /* we only want the borders on horizontal toolbars */
-               if ( DETAIL ("menubar") || height < 2*width ) { 
-                       if (!DETAIL ("menubar"))
-                               gdk_draw_line (window, clearlooks_style->shade_gc[0],
-                                              x, y, x + width, y); /* top */
-                                                       
-                       gdk_draw_line (window, clearlooks_style->shade_gc[3],
-                                      x, y + height - 1, x + width, y + height - 1); /* bottom */
-               }
-               
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[0], NULL);
-                       gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[3], NULL);
-               }
+               STYLE_FUNCTION(draw_scrollbar_stepper) (cr, colors, &params, &scrollbar, &stepper,
+                                                       x, y, width, height);
        }
-       else
+       else if (DETAIL ("toolbar") || DETAIL ("handlebox_bin") || DETAIL ("dockitem_bin"))
        {
-               parent_class->draw_box (style, window, state_type, shadow_type, area,
-                                       widget, detail, x, y, width, height);
-       }
-}
-
-/**************************************************************************/
-
-static void
-ensure_check_pixmaps (GtkStyle     *style,
-                      GtkStateType  state,
-                      GdkScreen    *screen,
-                      gboolean      treeview)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       ClearlooksRcStyle *clearlooks_rc = CLEARLOOKS_RC_STYLE (style->rc_style);
-       GdkPixbuf *check, *base, *inconsistent, *composite;
-       GdkColor *spot_color = clearlooks_get_spot_color (clearlooks_rc);
-       
-       if (clearlooks_style->check_pixmap_nonactive[state] != NULL)
-               return;
-       
-       if (state == GTK_STATE_ACTIVE || state == GTK_STATE_SELECTED) {
-               check = generate_bit (check_alpha, &style->text[GTK_STATE_NORMAL], 1.0);
-               inconsistent = generate_bit (check_inconsistent_alpha, &style->text[GTK_STATE_NORMAL], 1.0);
-       } else {
-               check = generate_bit (check_alpha, &style->text[state], 1.0);
-               inconsistent = generate_bit (check_inconsistent_alpha, &style->text[state], 1.0);
-       }
-       
-       if (state == GTK_STATE_ACTIVE && !treeview)
-               base = generate_bit (check_base_alpha, &style->bg[state], 1.0);
-       else
-               base = generate_bit (check_base_alpha, &style->base[GTK_STATE_NORMAL], 1.0);
-       
-       if (treeview)
-               composite = generate_bit (NULL, &clearlooks_style->shade[6], 1.0);
-       else
-               composite = generate_bit (NULL, &clearlooks_style->shade[5], 1.0);
-       
-       gdk_pixbuf_composite (base, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-
-       clearlooks_style->check_pixmap_nonactive[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-       
-       gdk_pixbuf_composite (check, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-
-       clearlooks_style->check_pixmap_active[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-
-       g_object_unref (composite);
+               WidgetParameters  params;
+               ToolbarParameters toolbar;
 
-       composite = generate_bit (NULL, &clearlooks_style->shade[6], 1.0);
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               clearlooks_set_toolbar_parameters (&toolbar, widget, window, x, y);
 
-       gdk_pixbuf_composite (base, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       gdk_pixbuf_composite (inconsistent, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
+               toolbar.style = clearlooks_style->toolbarstyle;
 
-       clearlooks_style->check_pixmap_inconsistent[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-
-       g_object_unref (composite);
-       g_object_unref (base);
-       g_object_unref (check);
-       g_object_unref (inconsistent);
-}
-
-static void
-draw_check (DRAW_ARGS)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GdkGC *gc = style->base_gc[state_type];
-       GdkPixmap *pixmap;
-       gboolean treeview;
-
-       if (DETAIL ("check")) /* Menu item */
+               /* Only draw the shadows on horizontal toolbars */
+               if (shadow_type != GTK_SHADOW_NONE && height < 2*width )
+                       STYLE_FUNCTION(draw_toolbar) (cr, colors, &params, &toolbar, x, y, width, height);
+       }
+       else if (DETAIL ("trough"))
        {
-               parent_class->draw_check (style, window, state_type, shadow_type, area,
-                                       widget, detail, x, y, width, height);
-               return;
+                       
        }
-
-       treeview = widget && GTK_IS_TREE_VIEW(widget);
-       ensure_check_pixmaps (style, state_type, gtk_widget_get_screen (widget), treeview);
-
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, area);
-
-       if (shadow_type == GTK_SHADOW_IN)
-               pixmap = clearlooks_style->check_pixmap_active[state_type];
-       else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
-               pixmap = clearlooks_style->check_pixmap_inconsistent[state_type];
-       else
-               pixmap = clearlooks_style->check_pixmap_nonactive[state_type];
-
-       x += (width - CHECK_SIZE)/2;
-       y += (height - CHECK_SIZE)/2;
-
-       gdk_draw_drawable (window, gc, pixmap, 0, 0, x, y, CHECK_SIZE, CHECK_SIZE);
-       
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, NULL);
-}
-
-/**************************************************************************/
-static void
-draw_slider (DRAW_ARGS, GtkOrientation orientation)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GdkGC *shade_gc = clearlooks_style->shade_gc[4];
-       GdkGC *white_gc = clearlooks_style->shade_gc[0];
-       int x1, y1;
-
-#if DEBUG
-               printf("draw_slider: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
-
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
-
-       sanitize_size (window, &width, &height);
-
-       gtk_paint_box (style, window, state_type, shadow_type,
-                      area, widget, detail, x, y, width, height);
-
-       if ((orientation == GTK_ORIENTATION_VERTICAL && height < 20) ||
-               (orientation == GTK_ORIENTATION_HORIZONTAL && width < 20))
-               return;
-       
-       if (detail && strcmp ("slider", detail) == 0)
+       else if (DETAIL ("menu"))
        {
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (shade_gc, area);
-                       gdk_gc_set_clip_rectangle (white_gc, area);
-               }
-               if (orientation == GTK_ORIENTATION_HORIZONTAL)
-               {
-                       x1 = x + width / 2 - 4;
-                       y1 = y + (height - 6) / 2;
-                       gdk_draw_line (window, shade_gc, x1, y1, x1, y1 + 6);
-                       gdk_draw_line (window, white_gc, x1 + 1, y1, x1 + 1, y1 + 6);
-                       gdk_draw_line (window, shade_gc, x1 + 3, y1, x1 + 3, y1 + 6);
-                       gdk_draw_line (window, white_gc, x1 + 3 + 1, y1, x1 + 3 + 1, y1 + 6);
-                       gdk_draw_line (window, shade_gc, x1 + 3*2, y1, x1 + 3*2, y1 + 6);
-                       gdk_draw_line (window, white_gc, x1 + 3*2 + 1, y1, x1 + 3*2 + 1, y1 + 6);
-               }
-               else
-               {
-                       x1 = x + (width - 6) / 2;
-                       y1 = y + height / 2 - 4;
-                       gdk_draw_line (window, shade_gc, x1 + 6, y1, x1, y1);
-                       gdk_draw_line (window, white_gc, x1 + 6, y1 + 1, x1, y1 + 1);
-                       gdk_draw_line (window, shade_gc, x1 + 6, y1 + 3, x1, y1 + 3);
-                       gdk_draw_line (window, white_gc, x1 + 6, y1 + 3 + 1, x1, y1 + 3 + 1);
-                       gdk_draw_line (window, shade_gc, x1 + 6, y1 + 3*2, x1, y1 + 3*2);
-                       gdk_draw_line (window, white_gc, x1 + 6, y1 + 3*2 + 1, x1, y1 + 3*2 + 1);
-               }
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (shade_gc, NULL);
-                       gdk_gc_set_clip_rectangle (white_gc, NULL);
-               }
+               WidgetParameters params;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               
+               STYLE_FUNCTION(draw_menu_frame) (cr, colors, &params, x, y, width, height);
        }
-       else if (detail && (strcmp ("hscale", detail) == 0 || strcmp ("vscale", detail) == 0))
+       else if (DETAIL ("hseparator") || DETAIL ("vseparator"))
        {
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (shade_gc, area);
-                       gdk_gc_set_clip_rectangle (white_gc, area);
-               }
+               const gchar *new_detail = detail;
+               /* Draw a normal separator, we just use this because it gives more control
+                * over sizing (currently). */
 
-               if (orientation == GTK_ORIENTATION_HORIZONTAL)
-               {
-                       x1 = x + width / 2 - 3;
-                       y1 = y + (height - 7) / 2;
-                       gdk_draw_line (window, shade_gc, x1 + 0, y1 + 5, x1 + 0, y1 + 1);
-                       gdk_draw_line (window, white_gc, x1 + 1, y1 + 5, x1 + 1, y1 + 1);
-                       gdk_draw_line (window, shade_gc, x1 + 3, y1 + 5, x1 + 3, y1 + 1);
-                       gdk_draw_line (window, white_gc, x1 + 4, y1 + 5, x1 + 4, y1 + 1);
-                       gdk_draw_line (window, shade_gc, x1 + 6,  y1 + 5, x1 + 6, y1 + 1);
-                       gdk_draw_line (window, white_gc, x1 + 7,  y1 + 5, x1 + 7, y1 + 1);
-               }
-               else
-               {
-                       x1 = x + (width - 7) / 2;
-                       y1 = y + height / 2 - 3;
-                       gdk_draw_line (window, shade_gc, x1 + 5, y1 + 0, x1 + 1, y1 + 0);
-                       gdk_draw_line (window, white_gc, x1 + 5, y1 + 1, x1 + 1, y1 + 1);
-                       gdk_draw_line (window, shade_gc, x1 + 5, y1 + 3, x1 + 1, y1 + 3);
-                       gdk_draw_line (window, white_gc, x1 + 5, y1 + 4, x1 + 1, y1 + 4);
-                       gdk_draw_line (window, shade_gc, x1 + 5, y1 + 6, x1 + 1, y1 + 6);
-                       gdk_draw_line (window, white_gc, x1 + 5, y1 + 7, x1 + 1, y1 + 7);
-               }
-               if (area)
-               {
-                       gdk_gc_set_clip_rectangle (shade_gc, NULL);
-                       gdk_gc_set_clip_rectangle (white_gc, NULL);
-               }
-       }
-}
+               /* This isn't nice ... but it seems like the best cleanest way to me right now.
+                * It will get slightly nicer in the future hopefully. */
+               if (GE_IS_MENU_ITEM (widget))
+                       new_detail = "menuitem";
 
-/**************************************************************************/
-static void
-ensure_radio_pixmaps (GtkStyle     *style,
-                     GtkStateType  state,
-                     GdkScreen    *screen)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       ClearlooksRcStyle *clearlooks_rc = CLEARLOOKS_RC_STYLE (style->rc_style);
-       GdkPixbuf *dot, *circle, *outline, *inconsistent, *composite;
-       GdkColor *spot_color = clearlooks_get_spot_color (clearlooks_rc);
-       GdkColor *composite_color;
-       
-       if (clearlooks_style->radio_pixmap_nonactive[state] != NULL)
-               return;
-       
-       if (state == GTK_STATE_ACTIVE || state == GTK_STATE_SELECTED) {
-               dot = colorize_bit (dot_intensity, dot_alpha, &style->text[GTK_STATE_NORMAL]);
-               inconsistent = generate_bit (inconsistent_alpha, &style->text[GTK_STATE_NORMAL], 1.0);
-       } else {
-               dot = colorize_bit (dot_intensity, dot_alpha, &style->text[state]);
-               inconsistent = generate_bit (inconsistent_alpha, &style->text[state], 1.0);
-       }
-       
-       outline = generate_bit (outline_alpha, &clearlooks_style->shade[5], 1.0);
-       
-       if (clearlooks_style->radio_pixmap_mask == NULL)
-       {
-               gdk_pixbuf_render_pixmap_and_mask (outline,
-                                                  NULL,
-                                                  &clearlooks_style->radio_pixmap_mask,
-                                                  1);
-       }
-       
-       if (state == GTK_STATE_ACTIVE)
-       {
-               composite_color = &style->bg[GTK_STATE_PRELIGHT];
-               circle = generate_bit (circle_alpha, &style->bg[state], 1.0);
+               if (DETAIL ("hseparator")) {
+                       gtk_paint_hline (style, window, state_type, area, widget, new_detail,
+                                        x, x + width - 1, y + height/2);
+               } else
+                       gtk_paint_vline (style, window, state_type, area, widget, new_detail,
+                                        y, y + height - 1, x + width/2);
        }
        else
        {
-               composite_color = &style->bg[state];
-               circle = generate_bit (circle_alpha, &style->base[GTK_STATE_NORMAL], 1.0);
+               clearlooks_parent_class->draw_box (style, window, state_type, shadow_type, area,
+                                       widget, detail, x, y, width, height);
        }
        
-       composite = generate_bit (NULL, composite_color, 1.0);
-       
-       gdk_pixbuf_composite (outline, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-                                                 
-       gdk_pixbuf_composite (circle, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       
-       clearlooks_style->radio_pixmap_nonactive[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-       
-       gdk_pixbuf_composite (dot, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       
-       clearlooks_style->radio_pixmap_active[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-       
-       g_object_unref (composite);
-       
-       composite = generate_bit (NULL, composite_color,1.0);
-       
-       gdk_pixbuf_composite (outline, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       gdk_pixbuf_composite (circle, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       gdk_pixbuf_composite (inconsistent, composite,
-                             0, 0, RADIO_SIZE, RADIO_SIZE, 0, 0,
-                             1.0, 1.0, GDK_INTERP_NEAREST, 255);
-       
-       clearlooks_style->radio_pixmap_inconsistent[state] =
-               pixbuf_to_pixmap (style, composite, screen);
-       
-       g_object_unref (composite);
-       g_object_unref (circle);
-       g_object_unref (dot);
-       g_object_unref (inconsistent);
-       g_object_unref (outline);
+       cairo_destroy (cr);
 }
 
 static void
-draw_option (DRAW_ARGS)
+clearlooks_style_draw_slider (DRAW_ARGS, GtkOrientation orientation)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GdkGC *gc = style->base_gc[state_type];
-       GdkPixmap *pixmap;
-       
-       if (DETAIL ("option")) /* Menu item */
-       {
-               parent_class->draw_option (style, window, state_type, shadow_type,
-                                          area, widget, detail, x, y, width, height);
-               return;
-       }
-       
-       ensure_radio_pixmaps (style, state_type, gtk_widget_get_screen (widget));
-       
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, area);
-       
-       if (shadow_type == GTK_SHADOW_IN)
-               pixmap = clearlooks_style->radio_pixmap_active[state_type];
-       else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
-               pixmap = clearlooks_style->radio_pixmap_inconsistent[state_type];
-       else
-               pixmap = clearlooks_style->radio_pixmap_nonactive[state_type];
-       
-       x += (width - RADIO_SIZE)/2;
-       y += (height - RADIO_SIZE)/2;
-       
-       gdk_gc_set_clip_mask (gc, clearlooks_style->radio_pixmap_mask);
-       gdk_gc_set_clip_origin (gc, x, y);
-       
-       gdk_draw_drawable (window, gc, pixmap, 0, 0, x, y,
-                          RADIO_SIZE, RADIO_SIZE);
-       
-       gdk_gc_set_clip_origin (gc, 0, 0);
-       gdk_gc_set_clip_mask (gc, NULL);
-       
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, NULL);
-}
-
-/**************************************************************************/
+       const ClearlooksColors *colors;
+       cairo_t *cr;
 
-static void 
-draw_shadow_gap (DRAW_ARGS,
-                 GtkPositionType gap_side,
-                 gint            gap_x,
-                 gint            gap_width)
-{
-       /* I need to improve this function. */
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       CLRectangle r;
-       GdkRegion *area_region = NULL, 
-                 *gap_region  = NULL;
-
-#if DEBUG
-               printf("draw_shadow_gap: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
-
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
-       
-       sanitize_size (window, &width, &height);
+       cr     = ge_gdk_drawable_to_cairo (window, area);
+       colors = &clearlooks_style->colors;
 
-       cl_rectangle_reset (&r, style);
-       cl_rectangle_set_corners (&r, CL_CORNER_NONE, CL_CORNER_NONE,
-                                                                 CL_CORNER_NONE, CL_CORNER_NONE);
+       CHECK_ARGS
+       SANITIZE_SIZE
        
-       if (area)
+       if (DETAIL ("hscale") || DETAIL ("vscale"))
        {
-               area_region = gdk_region_rectangle (area);
-       
-               switch (gap_side)
-               {
-                       case GTK_POS_TOP:
-                       {
-                               GdkRectangle rect = { x+gap_x, y, gap_width, 2 };
-                               gap_region = gdk_region_rectangle (&rect);
-                               break;
-                       }
-                       case GTK_POS_BOTTOM:
-                       {
-                               GdkRectangle rect = { x+gap_x, y+height-2, gap_width, 2 };
-                               gap_region = gdk_region_rectangle (&rect);
-                               break;
-                       }
-                       case GTK_POS_LEFT:
-                       {
-                               GdkRectangle rect = { x, y+gap_x, 2, gap_width };
-                               gap_region = gdk_region_rectangle (&rect);
-                               break;
-                       }               
-                       case GTK_POS_RIGHT:
-                       {
-                               GdkRectangle rect = { x+width-2, y+gap_x, 2, gap_width };
-                               gap_region = gdk_region_rectangle (&rect);
-                               break;
-                       }               
-               }
+               WidgetParameters params;
+               SliderParameters slider;
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               
+               slider.horizontal = (orientation == GTK_ORIENTATION_HORIZONTAL);
+               slider.lower = FALSE;
+               slider.fill_level = FALSE;
+               
+               if (clearlooks_style->style == CL_STYLE_GLOSSY) /* XXX! */
+                       params.corners = CR_CORNER_ALL;
                
-               gdk_region_subtract (area_region, gap_region);
+               STYLE_FUNCTION(draw_slider_button) (cr, &clearlooks_style->colors,
+                                              &params, &slider,
+                                              x, y, width, height);
        }
-       
-       if (shadow_type == GTK_SHADOW_ETCHED_IN ||
-           shadow_type == GTK_SHADOW_ETCHED_OUT)
+       else if (DETAIL ("slider"))
        {
-               GdkGC *a;
-               GdkGC *b;
+               WidgetParameters    params;
+               ScrollBarParameters scrollbar;
 
-               if (shadow_type == GTK_SHADOW_ETCHED_IN)
-               {
-                       a = style->light_gc[state_type];
-                       b = clearlooks_style->shade_gc[3];
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+               params.corners = CR_CORNER_NONE;
+
+               scrollbar.has_color  = FALSE;
+               scrollbar.horizontal = (orientation == GTK_ORIENTATION_HORIZONTAL);
+               scrollbar.junction   = clearlooks_scrollbar_get_junction (widget);
+
+               if (clearlooks_style->colorize_scrollbar) {
+                       scrollbar.color = colors->spot[1];
+                       scrollbar.has_color = TRUE;
                }
-               else
+
+               /* Set scrollbar color */
+               if (clearlooks_style->has_scrollbar_color)
                {
-                       a = clearlooks_style->shade_gc[3];
-                       b = style->light_gc[state_type];
+                       ge_gdk_color_to_cairo (&clearlooks_style->scrollbar_color, &scrollbar.color);
+                       scrollbar.has_color = TRUE;
                }
-               
-               gdk_gc_set_clip_region (a, area_region);                
-               gdk_gc_set_clip_region (b, area_region);                
 
-               r.bordergc = a;
-               cl_draw_rectangle (window, widget, style, x+1, y+1, width-1, height-1, &r);
-
-               r.bordergc = b;
-               cl_draw_rectangle (window, widget, style, x, y, width-1, height-1, &r);
-
-               gdk_gc_set_clip_region (a, NULL);       
-               gdk_gc_set_clip_region (b, NULL);               
+               if ((clearlooks_style->style == CL_STYLE_GLOSSY || clearlooks_style->style == CL_STYLE_GUMMY)
+                       && !scrollbar.has_color)
+                       scrollbar.color = colors->bg[0];
+               
+               STYLE_FUNCTION(draw_scrollbar_slider) (cr, colors, &params, &scrollbar,
+                                                      x, y, width, height);
        }
-       else if (shadow_type == GTK_SHADOW_IN || shadow_type == GTK_SHADOW_OUT)
+       else
        {
-               r.topleft     = (shadow_type == GTK_SHADOW_OUT) ? style->light_gc[state_type] : clearlooks_style->shade_gc[1];
-               r.bottomright = (shadow_type == GTK_SHADOW_OUT) ? clearlooks_style->shade_gc[1] : style->light_gc[state_type];
-               r.bordergc    = clearlooks_style->shade_gc[5];
-               
-               gdk_gc_set_clip_region (r.bordergc,    area_region);            
-               gdk_gc_set_clip_region (r.topleft,     area_region);            
-               gdk_gc_set_clip_region (r.bottomright, area_region);            
-                               
-               cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
-               
-               cl_draw_shadow (window, widget, style, x, y, width, height, &r);
-
-               gdk_gc_set_clip_region (r.bordergc,    NULL);
-               gdk_gc_set_clip_region (r.topleft,     NULL);
-               gdk_gc_set_clip_region (r.bottomright, NULL);
+               clearlooks_parent_class->draw_slider (style, window, state_type, shadow_type, area,
+                                          widget, detail, x, y, width, height, orientation);
        }
 
-       if (area_region)
-               gdk_region_destroy (area_region);
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
 static void
-draw_hline (GtkStyle     *style,
-            GdkWindow    *window,
-            GtkStateType  state_type,
-            GdkRectangle  *area,
-            GtkWidget     *widget,
-            const gchar   *detail,
-            gint          x1,
-            gint          x2,
-            gint          y)
+clearlooks_style_draw_option (DRAW_ARGS)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-
-#if DEBUG
-               printf("draw_hline\n");
-#endif
-
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
+       const ClearlooksColors *colors;
+       WidgetParameters params;
+       CheckboxParameters checkbox;
+       cairo_t *cr;
        
-       if (area)
-               gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[2], area);
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       cr = ge_gdk_drawable_to_cairo (window, area);
+       colors = &clearlooks_style->colors;
        
-       if (detail && !strcmp (detail, "label"))
-       {
-               if (state_type == GTK_STATE_INSENSITIVE)
-                       gdk_draw_line (window, style->light_gc[state_type], x1 + 1, y + 1, x2 + 1, y + 1);
-                       
-               gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
-       }
-       else
-       {
-               gdk_draw_line (window, clearlooks_style->shade_gc[2], x1, y, x2, y);
+       checkbox.shadow_type = shadow_type;
+       checkbox.in_menu = (widget && GTK_IS_MENU(widget->parent));
                
-               /* if (DETAIL ("menuitem")) */
-               gdk_draw_line (window, clearlooks_style->shade_gc[0], x1, y+1, x2, y+1);
-       }
+       clearlooks_set_widget_parameters (widget, style, state_type, &params);
        
-       if (area)
-               gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[2], NULL);
+       STYLE_FUNCTION(draw_radiobutton) (cr, colors, &params, &checkbox, x, y, width, height);
+
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
 static void
-draw_vline (GtkStyle     *style,
-            GdkWindow    *window,
-            GtkStateType  state_type,
-            GdkRectangle  *area,
-            GtkWidget     *widget,
-            const gchar   *detail,
-            gint          y1,
-            gint          y2,
-            gint          x)
+clearlooks_style_draw_check (DRAW_ARGS)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       gint thickness_light;
-       gint thickness_dark;
+       WidgetParameters params;
+       CheckboxParameters checkbox;
+       cairo_t *cr;
 
-#if DEBUG
-               printf("draw_vline\n");
-#endif
+       CHECK_ARGS
+       SANITIZE_SIZE
 
-       g_return_if_fail (GTK_IS_STYLE (style));
-       g_return_if_fail (window != NULL);
+       cr = ge_gdk_drawable_to_cairo (window, area);
        
-       thickness_light = style->xthickness / 2;
-       thickness_dark = style->xthickness - thickness_light;
+       clearlooks_set_widget_parameters (widget, style, state_type, &params);
        
-       if (area)
-               gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[2], area);
+       params.corners = CR_CORNER_ALL;
        
-       gdk_draw_line (window, clearlooks_style->shade_gc[2], x, y1, x, y2 - 1);
-       gdk_draw_line (window, clearlooks_style->shade_gc[0], x+1, y1, x+1, y2 - 1);
+       checkbox.shadow_type = shadow_type;
+       checkbox.in_cell = DETAIL("cellcheck");
+
+       checkbox.in_menu = (widget && widget->parent && GTK_IS_MENU(widget->parent));
+
+       STYLE_FUNCTION(draw_checkbox) (cr, &clearlooks_style->colors, &params, &checkbox,
+                                 x, y, width, height);
        
-       if (area)
-               gdk_gc_set_clip_rectangle (clearlooks_style->shade_gc[2], NULL);
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
 static void
-draw_focus (GtkStyle      *style,
-           GdkWindow     *window,
-           GtkStateType   state_type,
-           GdkRectangle  *area,
-           GtkWidget     *widget,
-           const gchar   *detail,
-           gint           x,
-           gint           y,
-           gint           width,
-           gint           height)
+clearlooks_style_draw_vline (GtkStyle               *style,
+                             GdkWindow              *window,
+                             GtkStateType            state_type,
+                             GdkRectangle           *area,
+                             GtkWidget              *widget,
+                             const gchar            *detail,
+                             gint                    y1,
+                             gint                    y2,
+                             gint                    x)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GdkPoint points[5];
-       GdkGC    *gc;
-       gboolean free_dash_list = FALSE;
-       gint line_width = 1;
-       gchar *dash_list = "\1\1";
-       gint dash_len;
+       const ClearlooksColors *colors;
+       SeparatorParameters separator = { FALSE };
+       cairo_t *cr;
 
-#if DEBUG
-               printf("draw_focus: %s %d %d %d %d\n", detail, x, y, width, height);
-#endif
-       
-       gc = clearlooks_style->shade_gc[6];
-       
-       if (widget)
-       {
-               gtk_widget_style_get (widget,
-                                     "focus-line-width", &line_width,
-                                     "focus-line-pattern", (gchar *)&dash_list,
-                                     NULL);
-       
-               free_dash_list = TRUE;
-       }
+       CHECK_ARGS
+
+       colors = &clearlooks_style->colors;
+
+       cr = ge_gdk_drawable_to_cairo (window, area);
+
+       /* There is no such thing as a vertical menu separator
+        * (and even if, a normal one should be better on menu bars) */
+       STYLE_FUNCTION(draw_separator) (cr, colors, NULL, &separator,
+                                       x, y1, 2, y2-y1+1);
        
-       sanitize_size (window, &width, &height);
+       cairo_destroy (cr);
+}
+
+static void
+clearlooks_style_draw_hline (GtkStyle               *style,
+                             GdkWindow              *window,
+                             GtkStateType            state_type,
+                             GdkRectangle           *area,
+                             GtkWidget              *widget,
+                             const gchar            *detail,
+                             gint                    x1,
+                             gint                    x2,
+                             gint                    y)
+{
+       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+       const ClearlooksColors *colors;
+       cairo_t *cr;
+       SeparatorParameters separator;
+
+       CHECK_ARGS
+
+       colors = &clearlooks_style->colors;
+
+       cr = ge_gdk_drawable_to_cairo (window, area);
        
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, area);
+       separator.horizontal = TRUE;
        
-       gdk_gc_set_line_attributes (gc, line_width,
-                                   dash_list[0] ? GDK_LINE_ON_OFF_DASH : GDK_LINE_SOLID,
-                                   GDK_CAP_BUTT, GDK_JOIN_MITER);
+       if (!DETAIL ("menuitem"))
+               STYLE_FUNCTION(draw_separator) (cr, colors, NULL, &separator,
+                                               x1, y, x2-x1+1, 2);
+       else
+               STYLE_FUNCTION(draw_menu_item_separator) (cr, colors, NULL, &separator,
+                                                          x1, y, x2-x1+1, 2);
        
+       cairo_destroy (cr);
+}
+
+static void 
+clearlooks_style_draw_shadow_gap (DRAW_ARGS,
+                 GtkPositionType gap_side,
+                 gint            gap_x,
+                 gint            gap_width)
+{
+       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+       const ClearlooksColors *colors;
+       cairo_t *cr;
+
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       cr     = ge_gdk_drawable_to_cairo (window, area);
+       colors = &clearlooks_style->colors;
        
-       if (detail && !strcmp (detail, "add-mode"))
+       if (DETAIL ("frame"))
        {
-               if (free_dash_list)
-                       g_free (dash_list);
+               WidgetParameters params;
+               FrameParameters  frame;
                
-               dash_list = "\4\4";
-               free_dash_list = FALSE;
-       }
-       
-       points[0].x = x + line_width / 2;
-       points[0].y = y + line_width / 2;
-       points[1].x = x + width - line_width + line_width / 2;
-       points[1].y = y + line_width / 2;
-       points[2].x = x + width - line_width + line_width / 2;
-       points[2].y = y + height - line_width + line_width / 2;
-       points[3].x = x + line_width / 2;
-       points[3].y = y + height - line_width + line_width / 2;
-       points[4] = points[0];
-       
-       if (!dash_list[0])
-       {
-               gdk_draw_lines (window, gc, points, 5);
+               frame.shadow    = shadow_type;
+               frame.gap_side  = gap_side;
+               frame.gap_x     = gap_x;
+               frame.gap_width = gap_width;
+               frame.border    = &colors->shade[5];
+               
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+
+               params.corners = CR_CORNER_ALL;
+               
+               STYLE_FUNCTION(draw_frame) (cr, colors, &params, &frame,
+                                      x, y, width, height);
        }
        else
        {
-               dash_len = strlen (dash_list);
-               
-               if (dash_list[0])
-                       gdk_gc_set_dashes (gc, 0, dash_list, dash_len);
-               
-               gdk_draw_lines (window, gc, points, 3);
-               
-               points[2].x += 1;
-               
-               if (dash_list[0])
-               {
-                       gint dash_pixels = 0;
-                       gint i;
-               
-                       /* Adjust the dash offset for the bottom and left so we
-                       * match up at the upper left.
-                       */
-                       for (i = 0; i < dash_len; i++)
-                               dash_pixels += dash_list[i];
-                       
-                       if (dash_len % 2 == 1)
-                               dash_pixels *= 2;
-               
-                       gdk_gc_set_dashes (gc,
-                                                       dash_pixels - (width + height - 2 * line_width) % dash_pixels,
-                                                       dash_list, dash_len);
-               }
-               
-               gdk_draw_lines (window, gc, points + 2, 3);
+               clearlooks_parent_class->draw_shadow_gap (style, window, state_type, shadow_type, area,
+                                                                          widget, detail, x, y, width, height,
+                                                                          gap_side, gap_x, gap_width);
        }
        
-       gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
-       
-       if (area)
-               gdk_gc_set_clip_rectangle (gc, NULL);
-       
-       if (free_dash_list)
-               g_free (dash_list);
+       cairo_destroy (cr);
 }
 
 static void
-draw_layout(GtkStyle * style,
-            GdkWindow * window,
-            GtkStateType state_type,
-            gboolean use_text,
-            GdkRectangle * area,
-            GtkWidget * widget,
-            const gchar * detail, gint x, gint y, PangoLayout * layout)
+clearlooks_style_draw_resize_grip (GtkStyle       *style,
+                  GdkWindow      *window,
+                  GtkStateType    state_type,
+                  GdkRectangle   *area,
+                  GtkWidget      *widget,
+                  const gchar    *detail,
+                  GdkWindowEdge   edge,
+                  gint            x,
+                  gint            y,
+                  gint            width,
+                  gint            height)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       
-       g_return_if_fail(GTK_IS_STYLE (style));
-       g_return_if_fail(window != NULL);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       cairo_t *cr;
+       WidgetParameters params;
+       ResizeGripParameters grip;
+
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       grip.edge = (ClearlooksWindowEdge)edge;
+
+       g_return_if_fail (window != NULL);
+
+       cr = ge_gdk_drawable_to_cairo (window, area);
 
-       parent_class->draw_layout(style, window, state_type, use_text,
-                                 area, widget, detail, x, y, layout);
+       clearlooks_set_widget_parameters (widget, style, state_type, &params);  
 
+       STYLE_FUNCTION(draw_resize_grip) (cr, colors, &params, &grip,
+                                    x, y, width, height);
+
+       cairo_destroy (cr);
+}
+
+static void
+clearlooks_style_draw_tab (DRAW_ARGS)
+{
+       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       WidgetParameters params;
+       ArrowParameters  arrow;          
+       cairo_t *cr;
+
+       CHECK_ARGS
+       SANITIZE_SIZE
        
+       cr = ge_gdk_drawable_to_cairo (window, area);
+
+       clearlooks_set_widget_parameters (widget, style, state_type, &params);
+       arrow.type      = CL_ARROW_COMBO;
+       arrow.direction = CL_DIRECTION_DOWN;     
+
+       STYLE_FUNCTION(draw_arrow) (cr, colors, &params, &arrow, x, y, width, height);
+
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
 static void
-draw_resize_grip (GtkStyle       *style,
-                 GdkWindow      *window,
-                 GtkStateType    state_type,
-                 GdkRectangle   *area,
-                 GtkWidget      *widget,
-                 const gchar    *detail,
-                 GdkWindowEdge   edge,
-                 gint            x,
-                 gint            y,
-                 gint            width,
-                 gint            height)
+clearlooks_style_draw_arrow (GtkStyle  *style,
+                       GdkWindow     *window,
+                       GtkStateType   state_type,
+                       GtkShadowType  shadow,
+                       GdkRectangle  *area,
+                       GtkWidget     *widget,
+                       const gchar   *detail,
+                       GtkArrowType   arrow_type,
+                       gboolean       fill,
+                       gint           x,
+                       gint           y,
+                       gint           width,
+                       gint           height)
 {
-  ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-  g_return_if_fail (GTK_IS_STYLE (style));
-  g_return_if_fail (window != NULL);
-  
-  if (area)
-    {
-      gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
-      gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
-      gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
-    }
-
-  switch (edge)
-    {
-    case GDK_WINDOW_EDGE_NORTH_WEST:
-      /* make it square */
-      if (width < height)
-       {
-         height = width;
-       }
-      else if (height < width)
-       {
-         width = height;
-       }
-      break;
-    case GDK_WINDOW_EDGE_NORTH:
-      if (width < height)
-       {
-         height = width;
-       }
-      break;
-    case GDK_WINDOW_EDGE_NORTH_EAST:
-      /* make it square, aligning to top right */
-      if (width < height)
-       {
-         height = width;
-       }
-      else if (height < width)
-       {
-         x += (width - height);
-         width = height;
-       }
-      break;
-    case GDK_WINDOW_EDGE_WEST:
-      if (height < width)
-       {
-          width = height;
-       }
-      break;
-    case GDK_WINDOW_EDGE_EAST:
-      /* aligning to right */
-      if (height < width)
-       {
-         x += (width - height);
-         width = height;
-       }
-      break;
-    case GDK_WINDOW_EDGE_SOUTH_WEST:
-      /* make it square, aligning to bottom left */
-      if (width < height)
-       {
-         y += (height - width);
-         height = width;
-       }
-      else if (height < width)
-       {
-         width = height;
-       }
-      break;
-    case GDK_WINDOW_EDGE_SOUTH:
-      /* align to bottom */
-      if (width < height)
-       {
-         y += (height - width);
-         height = width;
+       ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
+       ClearlooksColors *colors = &clearlooks_style->colors;
+       WidgetParameters params;
+       ArrowParameters  arrow;
+       cairo_t *cr = ge_gdk_drawable_to_cairo (window, area);
+
+       CHECK_ARGS
+       SANITIZE_SIZE
+
+       if (arrow_type == GTK_ARROW_NONE) {
+               cairo_destroy (cr);
+               return;
        }
-      break;
-    case GDK_WINDOW_EDGE_SOUTH_EAST:
-      /* make it square, aligning to bottom right */
-      if (width < height)
+
+       clearlooks_set_widget_parameters (widget, style, state_type, &params);
+       arrow.type = CL_ARROW_NORMAL;
+       arrow.direction = (ClearlooksDirection)arrow_type;
+       
+       if (ge_is_combo_box (widget, FALSE) && !ge_is_combo_box_entry (widget))
        {
-         y += (height - width);
-         height = width;
+               arrow.type = CL_ARROW_COMBO;
        }
-      else if (height < width)
+       
+       /* I have no idea why, but the arrow of GtkCombo is larger than in other places.
+        * Subtracting 3 seems to fix this. */
+       if (widget && widget->parent && GE_IS_COMBO (widget->parent->parent))
        {
-         x += (width - height);
-         width = height;
+               if (params.ltr)
+                       x += 1;
+               else
+                       x += 2;
+               width -= 3;
        }
-      break;
-    default:
-      g_assert_not_reached ();
-    }
-
-  /* Clear background */
-  gtk_style_apply_default_background (style, window, FALSE,
-                                     state_type, area,
-                                     x, y, width, height);   
-
-  switch (edge)
-    {
-    case GDK_WINDOW_EDGE_WEST:
-    case GDK_WINDOW_EDGE_EAST:
-      {
-       gint xi;
-
-       xi = x;
-
-       while (xi < x + width)
-         {
-           gdk_draw_line (window,
-                          style->light_gc[state_type],
-                          xi, y,
-                          xi, y + height);
-
-           xi++;
-           gdk_draw_line (window,
-                          clearlooks_style->shade_gc[4],
-                          xi, y,
-                          xi, y + height);
-
-           xi += 2;
-         }
-      }
-      break;
-    case GDK_WINDOW_EDGE_NORTH:
-    case GDK_WINDOW_EDGE_SOUTH:
-      {
-       gint yi;
-
-       yi = y;
-
-       while (yi < y + height)
-         {
-           gdk_draw_line (window,
-                          style->light_gc[state_type],
-                          x, yi,
-                          x + width, yi);
-
-           yi++;
-           gdk_draw_line (window,
-                          clearlooks_style->shade_gc[4],
-                          x, yi,
-                          x + width, yi);
-
-           yi+= 2;
-         }
-      }
-      break;
-    case GDK_WINDOW_EDGE_NORTH_WEST:
-      {
-       gint xi, yi;
-
-       xi = x + width;
-       yi = y + height;
-
-       while (xi > x + 3)
-         {
-           gdk_draw_line (window,
-                          clearlooks_style->shade_gc[4],
-                          xi, y,
-                          x, yi);
-
-           --xi;
-           --yi;
-
-           gdk_draw_line (window,
-                          style->light_gc[state_type],
-                          xi, y,
-                          x, yi);
-
-           xi -= 3;
-           yi -= 3;
-           
-         }
-      }
-      break;
-    case GDK_WINDOW_EDGE_NORTH_EAST:
-      {
-        gint xi, yi;
-
-        xi = x;
-        yi = y + height;
-
-        while (xi < (x + width - 3))
-          {
-            gdk_draw_line (window,
-                           style->light_gc[state_type],
-                           xi, y,
-                           x + width, yi);                           
-
-            ++xi;
-            --yi;
-            
-            gdk_draw_line (window,
-                           clearlooks_style->shade_gc[4],
-                           xi, y,
-                           x + width, yi);
-
-            xi += 3;
-            yi -= 3;
-          }
-      }
-      break;
-    case GDK_WINDOW_EDGE_SOUTH_WEST:
-      {
-       gint xi, yi;
-
-       xi = x + width;
-       yi = y;
-
-       while (xi > x + 3)
-         {
-           gdk_draw_line (window,
-                          clearlooks_style->shade_gc[4],
-                          x, yi,
-                          xi, y + height);
-
-           --xi;
-           ++yi;
-
-           gdk_draw_line (window,
-                          style->light_gc[state_type],
-                          x, yi,
-                          xi, y + height);
-
-           xi -= 3;
-           yi += 3;
-           
-         }
-      }
-      break;
-      
-    case GDK_WINDOW_EDGE_SOUTH_EAST:
-      {
-        gint xi, yi;
-
-        xi = x;
-        yi = y;
-
-        while (xi < (x + width - 3))
-          {
-            gdk_draw_line (window,
-                           style->light_gc[state_type],
-                           xi, y + height,
-                           x + width, yi);                           
-
-            ++xi;
-            ++yi;
-            
-            gdk_draw_line (window,
-                           clearlooks_style->shade_gc[4],
-                           xi, y + height,
-                           x + width, yi);                           
-            
-            xi += 3;
-            yi += 3;
-          }
-      }
-      break;
-    default:
-      g_assert_not_reached ();
-      break;
-    }
-  
-  if (area)
-    {
-      gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
-      gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
-      gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
-    }
+       
+       STYLE_FUNCTION(draw_arrow) (cr, colors, &params, &arrow, x, y, width, height);
+       
+       cairo_destroy (cr);
 }
 
-/**************************************************************************/
-
 static void
 clearlooks_style_init_from_rc (GtkStyle * style,
                               GtkRcStyle * rc_style)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       GdkColor *spot_color;
-       double shades[] = {1.065, 0.93, 0.896, 0.85, 0.768, 0.665, 0.4, 0.205};
-       int i;
-       double contrast;
-       
-       parent_class->init_from_rc (style, rc_style);
-       
-       contrast = CLEARLOOKS_RC_STYLE (rc_style)->contrast;
        
-       clearlooks_style->sunkenmenubar = CLEARLOOKS_RC_STYLE (rc_style)->sunkenmenubar;
-       clearlooks_style->progressbarstyle = CLEARLOOKS_RC_STYLE (rc_style)->progressbarstyle;
-       clearlooks_style->menubarstyle = CLEARLOOKS_RC_STYLE (rc_style)->menubarstyle;
-       clearlooks_style->menuitemstyle = CLEARLOOKS_RC_STYLE (rc_style)->menuitemstyle;
-       clearlooks_style->listviewitemstyle = CLEARLOOKS_RC_STYLE (rc_style)->listviewitemstyle;
+       clearlooks_parent_class->init_from_rc (style, rc_style);
        
-       /* Lighter to darker */
-       for (i = 0; i < 8; i++)
-       {
-               shade (&style->bg[GTK_STATE_NORMAL], &clearlooks_style->shade[i],
-                      (shades[i]-0.7) * contrast + 0.7);
-       }
-               
-       spot_color = clearlooks_get_spot_color (CLEARLOOKS_RC_STYLE (rc_style));
+       g_assert ((CLEARLOOKS_RC_STYLE (rc_style)->style >= 0) && (CLEARLOOKS_RC_STYLE (rc_style)->style < CL_NUM_STYLES));
+       clearlooks_style->style         = CLEARLOOKS_RC_STYLE (rc_style)->style;
        
-       clearlooks_style->spot_color = *spot_color;
-       shade (&clearlooks_style->spot_color, &clearlooks_style->spot1, 1.42);
-       shade (&clearlooks_style->spot_color, &clearlooks_style->spot2, 1.05);
-       shade (&clearlooks_style->spot_color, &clearlooks_style->spot3, 0.65);
-
-       shade (&style->bg[GTK_STATE_NORMAL], &clearlooks_style->border[CL_BORDER_UPPER],        0.5);
-       shade (&style->bg[GTK_STATE_NORMAL], &clearlooks_style->border[CL_BORDER_LOWER],        0.62);
-       shade (&style->bg[GTK_STATE_ACTIVE], &clearlooks_style->border[CL_BORDER_UPPER_ACTIVE], 0.5);
-       shade (&style->bg[GTK_STATE_ACTIVE], &clearlooks_style->border[CL_BORDER_LOWER_ACTIVE], 0.55);
-}
+       clearlooks_style->menubarstyle      = CLEARLOOKS_RC_STYLE (rc_style)->menubarstyle;
+       clearlooks_style->toolbarstyle      = CLEARLOOKS_RC_STYLE (rc_style)->toolbarstyle;
+       clearlooks_style->has_scrollbar_color = CLEARLOOKS_RC_STYLE (rc_style)->flags & CL_FLAG_SCROLLBAR_COLOR;
+       clearlooks_style->colorize_scrollbar = CLEARLOOKS_RC_STYLE (rc_style)->colorize_scrollbar;
+       clearlooks_style->animation         = CLEARLOOKS_RC_STYLE (rc_style)->animation;
+       clearlooks_style->radius            = CLAMP (CLEARLOOKS_RC_STYLE (rc_style)->radius, 0.0, 10.0);
 
-static GdkGC *
-realize_color (GtkStyle * style,
-              GdkColor * color)
-{
-       GdkGCValues gc_values;
-       
-       gdk_colormap_alloc_color (style->colormap, color, FALSE, TRUE);
-       
-       gc_values.foreground = *color;
-       
-       return gtk_gc_get (style->depth, style->colormap, &gc_values, GDK_GC_FOREGROUND);
+       if (clearlooks_style->has_scrollbar_color)
+               clearlooks_style->scrollbar_color = CLEARLOOKS_RC_STYLE (rc_style)->scrollbar_color;
 }
 
 static void
 clearlooks_style_realize (GtkStyle * style)
 {
        ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+       double shades[] = {1.15, 0.95, 0.896, 0.82, 0.7, 0.665, 0.475, 0.45, 0.4};
+       CairoColor spot_color;
+       CairoColor bg_normal;
+       double contrast;
        int i;
        
-       parent_class->realize (style);
+       clearlooks_parent_class->realize (style);
+
+       contrast = CLEARLOOKS_RC_STYLE (style->rc_style)->contrast;
        
-       for (i = 0; i < 8; i++)
-               clearlooks_style->shade_gc[i] = realize_color (style, &clearlooks_style->shade[i]);
+       /* Lighter to darker */
+       ge_gdk_color_to_cairo (&style->bg[GTK_STATE_NORMAL], &bg_normal);
 
-       for (i=0; i < CL_BORDER_COUNT; i++)
-               clearlooks_style->border_gc[i] = realize_color (style, &clearlooks_style->border[i]);
+       for (i = 0; i < 9; i++)
+       {
+               ge_shade_color(&bg_normal, (shades[i]-0.7) * contrast + 0.7, &clearlooks_style->colors.shade[i]);
+       }
                
-       clearlooks_style->spot1_gc = realize_color (style, &clearlooks_style->spot1);
-       clearlooks_style->spot2_gc = realize_color (style, &clearlooks_style->spot2);
-       clearlooks_style->spot3_gc = realize_color (style, &clearlooks_style->spot3);
-
-       /* set light inset color */
+       ge_gdk_color_to_cairo (&style->bg[GTK_STATE_SELECTED], &spot_color);
+       
+       ge_shade_color(&spot_color, 1.42, &clearlooks_style->colors.spot[0]);
+       ge_shade_color(&spot_color, 1.05, &clearlooks_style->colors.spot[1]);
+       ge_shade_color(&spot_color, 0.65, &clearlooks_style->colors.spot[2]);
+       
        for (i=0; i<5; i++)
        {
-               shade (&style->bg[i], &clearlooks_style->inset_dark[i], 0.93);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->inset_dark[i]);
+               ge_gdk_color_to_cairo (&style->fg[i], &clearlooks_style->colors.fg[i]);
+               ge_gdk_color_to_cairo (&style->bg[i], &clearlooks_style->colors.bg[i]);
+               ge_gdk_color_to_cairo (&style->base[i], &clearlooks_style->colors.base[i]);
+               ge_gdk_color_to_cairo (&style->text[i], &clearlooks_style->colors.text[i]);
+       }
+}
 
-               shade (&style->bg[i], &clearlooks_style->inset_light[i], 1.055);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->inset_light[i]);
+static void
+clearlooks_style_draw_focus (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
+            GdkRectangle *area, GtkWidget *widget, const gchar *detail,
+            gint x, gint y, gint width, gint height)
+{
+       cairo_t *cr;
+       gboolean free_dash_list = FALSE;
+       gint line_width = 1;
+       gint8 *dash_list = (gint8 *)"\1\1";
 
-               shade (&style->bg[i], &clearlooks_style->listview_bg[i], 1.015);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->listview_bg[i]);
+       if (widget)
+       {
+               gtk_widget_style_get (widget,
+                                     "focus-line-width", &line_width,
+                                     "focus-line-pattern",
+                                     (gchar *) & dash_list, NULL);
 
-               /* CREATE GRADIENT FOR BUTTONS */               
-               shade (&style->bg[i], &clearlooks_style->button_g1[i], 1.055);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->button_g1[i]);
-               
-               shade (&style->bg[i], &clearlooks_style->button_g2[i], 1.005);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->button_g2[i]);
+               free_dash_list = TRUE;
+       }
 
-               shade (&style->bg[i], &clearlooks_style->button_g3[i], 0.98);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->button_g3[i]);
+       if (detail && !strcmp (detail, "add-mode"))
+       {
+               if (free_dash_list)
+                       g_free (dash_list);
 
-               shade (&style->bg[i], &clearlooks_style->button_g4[i], 0.91);
-               gdk_rgb_find_color (style->colormap, &clearlooks_style->button_g4[i]);
+               dash_list = (gint8 *)"\4\4";
+               free_dash_list = FALSE;
        }
 
-}
+       CHECK_ARGS
+       SANITIZE_SIZE
 
-static void
-clearlooks_style_unrealize (GtkStyle * style)
-{
-       ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
-       int i;
-       
-       /* We don't free the colors, because we don't know if
-       * gtk_gc_release() actually freed the GC. FIXME - need
-       * a way of ref'ing colors explicitely so GtkGC can
-       * handle things properly.
-       */
-       for (i=0; i < 8; i++)
-               gtk_gc_release (clearlooks_style->shade_gc[i]);
-       
-       gtk_gc_release (clearlooks_style->spot1_gc);
-       gtk_gc_release (clearlooks_style->spot2_gc);
-       gtk_gc_release (clearlooks_style->spot3_gc);
-       
-       for (i = 0; i < 5; i++)
+       cr = gdk_cairo_create (window);
+
+       if (detail && !strcmp (detail, "colorwheel_light"))
+               cairo_set_source_rgb (cr, 0., 0., 0.);
+       else if (detail && !strcmp (detail, "colorwheel_dark"))
+               cairo_set_source_rgb (cr, 1., 1., 1.);
+       else
+               ge_cairo_set_gdk_color_with_alpha (cr, &style->fg[state_type],
+                                                      0.7);
+
+       cairo_set_line_width (cr, line_width);
+
+       if (dash_list[0])
        {
-               if (clearlooks_style->radio_pixmap_nonactive[i] != NULL)
-               {
-                       g_object_unref (clearlooks_style->radio_pixmap_nonactive[i]);
-                       clearlooks_style->radio_pixmap_nonactive[i] = NULL;
-                       g_object_unref (clearlooks_style->radio_pixmap_active[i]);
-                       clearlooks_style->radio_pixmap_active[i] = NULL;
-                       g_object_unref (clearlooks_style->radio_pixmap_inconsistent[i]);
-                       clearlooks_style->radio_pixmap_inconsistent[i] = NULL;
-               }
-               
-               if (clearlooks_style->check_pixmap_nonactive[i] != NULL)
+               gint n_dashes = strlen ((gchar *)dash_list);
+               gdouble *dashes = g_new (gdouble, n_dashes);
+               gdouble total_length = 0;
+               gdouble dash_offset;
+               gint i;
+
+               for (i = 0; i < n_dashes; i++)
                {
-                       g_object_unref (clearlooks_style->check_pixmap_nonactive[i]);
-                       clearlooks_style->check_pixmap_nonactive[i] = NULL;
-                       g_object_unref (clearlooks_style->check_pixmap_active[i]);
-                       clearlooks_style->check_pixmap_active[i] = NULL;
-                       g_object_unref (clearlooks_style->check_pixmap_inconsistent[i]);
-                       clearlooks_style->check_pixmap_inconsistent[i] = NULL;
+                       dashes[i] = dash_list[i];
+                       total_length += dash_list[i];
                }
+
+               /* The dash offset here aligns the pattern to integer pixels
+                * by starting the dash at the right side of the left border
+                * Negative dash offsets in cairo don't work
+                * (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
+                */
+               dash_offset = -line_width / 2.;
+               while (dash_offset < 0)
+                       dash_offset += total_length;
+
+               cairo_set_dash (cr, dashes, n_dashes, dash_offset);
+               g_free (dashes);
        }
-       
-       if (clearlooks_style->radio_pixmap_mask != NULL)
-               g_object_unref (clearlooks_style->radio_pixmap_mask);
-               
-       clearlooks_style->radio_pixmap_mask = NULL;
 
-       while (progressbars = g_list_first (progressbars))
-               cl_progressbar_remove (progressbars->data);
-       
-       if (timer_id != 0)
+       if (area)
        {
-               g_source_remove(timer_id);
-               timer_id = 0;           
+               gdk_cairo_rectangle (cr, area);
+               cairo_clip (cr);
        }
-       
-       parent_class->unrealize (style);
+
+       cairo_rectangle (cr,
+                        x + line_width / 2.,
+                        y + line_width / 2.,
+                        width - line_width, height - line_width);
+       cairo_stroke (cr);
+       cairo_destroy (cr);
+
+       if (free_dash_list)
+               g_free (dash_list);
+}
+
+static void
+clearlooks_style_copy (GtkStyle * style, GtkStyle * src)
+{
+       ClearlooksStyle * cl_style = CLEARLOOKS_STYLE (style);
+       ClearlooksStyle * cl_src = CLEARLOOKS_STYLE (src);
+       
+       cl_style->colors              = cl_src->colors;
+       cl_style->menubarstyle        = cl_src->menubarstyle;
+       cl_style->toolbarstyle        = cl_src->toolbarstyle;
+       cl_style->scrollbar_color     = cl_src->scrollbar_color;
+       cl_style->has_scrollbar_color = cl_src->has_scrollbar_color;
+       cl_style->colorize_scrollbar  = cl_src->colorize_scrollbar;
+       cl_style->animation           = cl_src->animation;
+       cl_style->radius              = cl_src->radius;
+       cl_style->style               = cl_src->style;
+       
+       clearlooks_parent_class->copy (style, src);
+}
+
+static void
+clearlooks_style_unrealize (GtkStyle * style)
+{
+       clearlooks_parent_class->unrealize (style);
 }
 
 static GdkPixbuf *
@@ -2504,19 +1446,67 @@ scale_or_ref (GdkPixbuf *src,
                return g_object_ref (src);
        } else {
                return gdk_pixbuf_scale_simple (src,
-                                               width, height,
-                                               GDK_INTERP_BILINEAR);
+                                        width, height,
+                                        GDK_INTERP_BILINEAR);
+       }
+}
+
+static void
+clearlooks_style_draw_layout (GtkStyle * style,
+            GdkWindow * window,
+            GtkStateType state_type,
+            gboolean use_text,
+            GdkRectangle * area,
+            GtkWidget * widget,
+            const gchar * detail, gint x, gint y, PangoLayout * layout)
+{
+       GdkGC *gc;
+
+       g_return_if_fail (GTK_IS_STYLE (style));
+       g_return_if_fail (window != NULL);
+
+       gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
+
+       if (area)
+               gdk_gc_set_clip_rectangle (gc, area);
+
+       if (state_type == GTK_STATE_INSENSITIVE) {
+               ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
+               ClearlooksColors *colors = &clearlooks_style->colors;
+
+               WidgetParameters params;
+               GdkColor etched;
+               CairoColor temp;
+
+               clearlooks_set_widget_parameters (widget, style, state_type, &params);
+
+               if (GTK_WIDGET_NO_WINDOW (widget))
+                       ge_shade_color (&params.parentbg, 1.2, &temp);
+               else
+                       ge_shade_color (&colors->bg[widget->state], 1.2, &temp);
+               
+               etched.red = (int) (temp.r * 65535);
+               etched.green = (int) (temp.g * 65535);
+               etched.blue = (int) (temp.b * 65535);
+
+               gdk_draw_layout_with_colors (window, gc, x + 1, y + 1, layout, &etched, NULL);
+               gdk_draw_layout (window, gc, x, y, layout);
        }
+       else
+               gdk_draw_layout (window, gc, x, y, layout);
+
+       if (area)
+               gdk_gc_set_clip_rectangle (gc, NULL);
 }
 
 static GdkPixbuf *
-render_icon (GtkStyle            *style,
-            const GtkIconSource *source,
-            GtkTextDirection     direction,
-            GtkStateType         state,
-            GtkIconSize          size,
-            GtkWidget           *widget,
-            const char          *detail)
+clearlooks_style_draw_render_icon (GtkStyle            *style,
+             const GtkIconSource *source,
+             GtkTextDirection     direction,
+             GtkStateType         state,
+             GtkIconSize          size,
+             GtkWidget           *widget,
+             const char          *detail)
 {
        int width = 1;
        int height = 1;
@@ -2565,16 +1555,6 @@ render_icon (GtkStyle            *style,
        if (gtk_icon_source_get_state_wildcarded (source)) {
                if (state == GTK_STATE_INSENSITIVE) {
                        stated = set_transparency (scaled, 0.3);
-#if 0
-                       stated =
-                               gdk_pixbuf_composite_color_simple (scaled,
-                                                                  gdk_pixbuf_get_width (scaled),
-                                                                  gdk_pixbuf_get_height (scaled),
-                                                                  GDK_INTERP_BILINEAR, 128,
-                                                                  gdk_pixbuf_get_width (scaled),
-                                                                  style->bg[state].pixel,
-                                                                  style->bg[state].pixel);
-#endif
                        gdk_pixbuf_saturate_and_pixelate (stated, stated,
                                                          0.1, FALSE);
                        
@@ -2606,29 +1586,39 @@ clearlooks_style_class_init (ClearlooksStyleClass * klass)
 {
        GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
        
-       parent_class = g_type_class_peek_parent (klass);
-
-       style_class->realize = clearlooks_style_realize;
-       style_class->unrealize = clearlooks_style_unrealize;
-       style_class->init_from_rc = clearlooks_style_init_from_rc;
-       style_class->draw_focus = draw_focus;
-       style_class->draw_resize_grip = draw_resize_grip;
-       style_class->draw_handle = draw_handle;
-       style_class->draw_vline = draw_vline;
-       style_class->draw_hline = draw_hline;
-       style_class->draw_slider = draw_slider;
-       style_class->draw_shadow_gap = draw_shadow_gap;
-       style_class->draw_arrow = clearlooks_draw_arrow;
-       style_class->draw_check = draw_check;
-       style_class->draw_tab = draw_tab;
-       style_class->draw_box = draw_box;
-       style_class->draw_shadow = draw_shadow;
-       style_class->draw_box_gap = draw_box_gap;
-       style_class->draw_extension = draw_extension;
-       style_class->draw_option = draw_option;
-       style_class->draw_layout = draw_layout; 
-       style_class->render_icon = render_icon;
-       style_class->draw_flat_box = draw_flat_box;
+       clearlooks_style_class = CLEARLOOKS_STYLE_CLASS (klass);
+       clearlooks_parent_class = g_type_class_peek_parent (klass);
+
+       style_class->copy             = clearlooks_style_copy;
+       style_class->realize          = clearlooks_style_realize;
+       style_class->unrealize        = clearlooks_style_unrealize;
+       style_class->init_from_rc     = clearlooks_style_init_from_rc;
+       style_class->draw_handle      = clearlooks_style_draw_handle;
+       style_class->draw_slider      = clearlooks_style_draw_slider;
+       style_class->draw_shadow_gap  = clearlooks_style_draw_shadow_gap;
+       style_class->draw_focus       = clearlooks_style_draw_focus;
+       style_class->draw_box         = clearlooks_style_draw_box;
+       style_class->draw_shadow      = clearlooks_style_draw_shadow;
+       style_class->draw_box_gap     = clearlooks_style_draw_box_gap;
+       style_class->draw_extension   = clearlooks_style_draw_extension;
+       style_class->draw_option      = clearlooks_style_draw_option;
+       style_class->draw_check       = clearlooks_style_draw_check;
+       style_class->draw_flat_box    = clearlooks_style_draw_flat_box;
+       style_class->draw_vline       = clearlooks_style_draw_vline;
+       style_class->draw_hline       = clearlooks_style_draw_hline;
+       style_class->draw_resize_grip = clearlooks_style_draw_resize_grip;
+       style_class->draw_tab         = clearlooks_style_draw_tab;
+       style_class->draw_arrow       = clearlooks_style_draw_arrow;
+       style_class->draw_layout      = clearlooks_style_draw_layout;
+       style_class->render_icon      = clearlooks_style_draw_render_icon;
+
+       clearlooks_register_style_classic (&clearlooks_style_class->style_functions[CL_STYLE_CLASSIC]);
+       clearlooks_style_class->style_functions[CL_STYLE_GLOSSY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
+       clearlooks_register_style_glossy (&clearlooks_style_class->style_functions[CL_STYLE_GLOSSY]);
+       clearlooks_style_class->style_functions[CL_STYLE_INVERTED] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
+       clearlooks_register_style_inverted (&clearlooks_style_class->style_functions[CL_STYLE_INVERTED]);
+       clearlooks_style_class->style_functions[CL_STYLE_GUMMY] = clearlooks_style_class->style_functions[CL_STYLE_CLASSIC];
+       clearlooks_register_style_gummy (&clearlooks_style_class->style_functions[CL_STYLE_GUMMY]);
 }
 
 GType clearlooks_type_style = 0;