]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkstyle.c
Adapt to uscore-ification of gtktextiterprivate
[~andy/gtk] / gtk / gtkstyle.c
index d2fb0f7150da115b4d8bc4a09d154d0ad20a440a..d86986e525fa365b118ab9c7e291b8eb4b4b7db5 100644 (file)
@@ -2,23 +2,23 @@
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser 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.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser 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.
  */
 
 /*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
@@ -31,7 +31,7 @@
 #include "gtkstyle.h"
 #include "gtkwidget.h"
 #include "gtkthemes.h"
-
+#include "gtkiconfactory.h"
 
 #define LIGHTNESS_MULT  1.3
 #define DARKNESS_MULT   0.7
 #define M_PI_4  0.78539816339744830962
 #endif /* M_PI_4 */
 
-static void         gtk_style_init         (GtkStyle    *style,
-                                            GdkColormap *colormap,
-                                            gint         depth);
-static void         gtk_style_destroy      (GtkStyle    *style);
+static void         gtk_style_realize (GtkStyle    *style,
+                                       GdkColormap *colormap);
+
+static void      gtk_style_real_realize        (GtkStyle     *style);
+static void      gtk_style_real_unrealize      (GtkStyle     *style);
+static void      gtk_style_real_copy           (GtkStyle     *style,
+                                               GtkStyle     *src);
+static void      gtk_style_real_set_background (GtkStyle     *style,
+                                               GdkWindow    *window,
+                                               GtkStateType  state_type);
+static GtkStyle *gtk_style_real_clone          (GtkStyle     *style);
+static void      gtk_style_real_init_from_rc   (GtkStyle     *style,
+                                                GtkRcStyle   *rc_style);
+
+
+static GdkPixbuf *gtk_default_render_icon      (GtkStyle            *style,
+                                                const GtkIconSource *source,
+                                                GtkTextDirection     direction,
+                                                GtkStateType         state,
+                                                const gchar         *size,
+                                                GtkWidget           *widget,
+                                                const gchar         *detail);
 
 static void gtk_default_draw_hline      (GtkStyle        *style,
                                         GdkWindow       *window,
@@ -123,17 +141,6 @@ static void gtk_default_draw_diamond    (GtkStyle        *style,
                                         gint             y,
                                         gint             width,
                                         gint             height);
-static void gtk_default_draw_oval       (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);
 static void gtk_default_draw_string     (GtkStyle        *style,
                                         GdkWindow       *window,
                                         GtkStateType     state_type,
@@ -187,29 +194,6 @@ static void gtk_default_draw_option     (GtkStyle        *style,
                                         gint             y,
                                         gint             width,
                                         gint             height);
-static void gtk_default_draw_cross      (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);
-static void gtk_default_draw_ramp       (GtkStyle        *style,
-                                        GdkWindow       *window,
-                                        GtkStateType     state_type,
-                                        GtkShadowType    shadow_type,
-                                        GdkRectangle    *area,
-                                        GtkWidget       *widget,
-                                        const gchar     *detail,
-                                        GtkArrowType     arrow_type,
-                                        gint             x,
-                                        gint             y,
-                                        gint             width,
-                                        gint             height);
 static void gtk_default_draw_tab        (GtkStyle        *style,
                                         GdkWindow       *window,
                                         GtkStateType     state_type,
@@ -294,38 +278,29 @@ static void gtk_default_draw_handle     (GtkStyle        *style,
                                         gint             width,
                                         gint             height,
                                         GtkOrientation   orientation);
+static void gtk_default_draw_expander   (GtkStyle        *style,
+                                         GdkWindow       *window,
+                                         GtkStateType     state_type,
+                                         GdkRectangle    *area,
+                                         GtkWidget       *widget,
+                                         const gchar     *detail,
+                                         gint             x,
+                                         gint             y,
+                                         gboolean         is_open);
+static void gtk_default_draw_layout     (GtkStyle        *style,
+                                         GdkWindow       *window,
+                                         GtkStateType     state_type,
+                                         GdkRectangle    *area,
+                                         GtkWidget       *widget,
+                                         const gchar     *detail,
+                                         gint             x,
+                                         gint             y,
+                                         PangoLayout     *layout);
 
 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
 
-
-static const GtkStyleClass default_class =
-{
-  2,
-  2,
-  gtk_default_draw_hline,
-  gtk_default_draw_vline,
-  gtk_default_draw_shadow,
-  gtk_default_draw_polygon,
-  gtk_default_draw_arrow,
-  gtk_default_draw_diamond,
-  gtk_default_draw_oval,
-  gtk_default_draw_string,
-  gtk_default_draw_box,
-  gtk_default_draw_flat_box,
-  gtk_default_draw_check,
-  gtk_default_draw_option,
-  gtk_default_draw_cross,
-  gtk_default_draw_ramp,
-  gtk_default_draw_tab,
-  gtk_default_draw_shadow_gap,
-  gtk_default_draw_box_gap,
-  gtk_default_draw_extension,
-  gtk_default_draw_focus,
-  gtk_default_draw_slider,
-  gtk_default_draw_handle
-};
 GdkFont *default_font = NULL;
 
 static GdkColor gtk_default_normal_fg =      { 0,      0,      0,      0 };
@@ -340,87 +315,64 @@ static GdkColor gtk_default_prelight_bg =    { 0, 0xea60, 0xea60, 0xea60 };
 static GdkColor gtk_default_selected_bg =    { 0,      0,      0, 0x9c40 };
 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
 
-GtkStyle*
-gtk_style_copy (GtkStyle *style)
+static gpointer parent_class = NULL;
+
+static void gtk_style_init       (GtkStyle      *style);
+static void gtk_style_class_init (GtkStyleClass *klass);
+static void gtk_style_finalize   (GObject       *object);
+
+GType
+gtk_style_get_type (void)
 {
-  GtkStyle *new_style;
-  guint i;
-  
-  g_return_val_if_fail (style != NULL, NULL);
-  
-  new_style = gtk_style_new ();
-  
-  for (i = 0; i < 5; i++)
-    {
-      new_style->fg[i] = style->fg[i];
-      new_style->bg[i] = style->bg[i];
-      new_style->text[i] = style->text[i];
-      new_style->base[i] = style->base[i];
-      
-      new_style->bg_pixmap[i] = style->bg_pixmap[i];
-    }
-  
-  gdk_font_unref (new_style->font);
-  new_style->font = style->font;
-  gdk_font_ref (new_style->font);
+  static GType object_type = 0;
 
-  if (style->rc_style)
-    {
-      new_style->rc_style = style->rc_style;
-      gtk_rc_style_ref (style->rc_style);
-    }
-  
-  if (style->engine)
+  if (!object_type)
     {
-      new_style->engine = style->engine;
-      gtk_theme_engine_ref (new_style->engine);
-      new_style->engine->duplicate_style (new_style, style);
+      static const GTypeInfo object_info =
+      {
+        sizeof (GtkStyleClass),
+        (GBaseInitFunc) NULL,
+        (GBaseFinalizeFunc) NULL,
+        (GClassInitFunc) gtk_style_class_init,
+        NULL,           /* class_finalize */
+        NULL,           /* class_data */
+        sizeof (GtkStyle),
+        0,              /* n_preallocs */
+        (GInstanceInitFunc) gtk_style_init,
+      };
+      
+      object_type = g_type_register_static (G_TYPE_OBJECT,
+                                            "GtkStyle",
+                                            &object_info, 0);
     }
-
-  return new_style;
-}
-
-static GtkStyle*
-gtk_style_duplicate (GtkStyle *style)
-{
-  GtkStyle *new_style;
-  
-  g_return_val_if_fail (style != NULL, NULL);
-  
-  new_style = gtk_style_copy (style);
-  
-  style->styles = g_slist_append (style->styles, new_style);
-  new_style->styles = style->styles;  
   
-  return new_style;
+  return object_type;
 }
 
-GtkStyle*
-gtk_style_new (void)
+static void
+gtk_style_init (GtkStyle *style)
 {
-  GtkStyle *style;
   gint i;
   
-  style = g_new0 (GtkStyle, 1);
-  
   style->font_desc = pango_font_description_from_string ("Sans 10");
 
   if (!default_font)
     {
       default_font = gdk_font_from_description (style->font_desc);
 
-      if (!default_font)
-       g_error ("Unable to load default font.");
+      if (!default_font) 
+       default_font = gdk_font_load ("fixed");
+
+      if (!default_font) 
+       g_error ("Unable to load \"fixed\" font!");
     }
   
   style->font = default_font;
   gdk_font_ref (style->font);
 
-  style->ref_count = 1;
   style->attach_count = 0;
   style->colormap = NULL;
   style->depth = -1;
-  style->klass = (GtkStyleClass *)&default_class;
   
   style->black.red = 0;
   style->black.green = 0;
@@ -457,9 +409,6 @@ gtk_style_new (void)
   for (i = 0; i < 5; i++)
     style->bg_pixmap[i] = NULL;
   
-  style->engine = NULL;
-  style->engine_data = NULL;
-  
   style->rc_style = NULL;
   
   for (i = 0; i < 5; i++)
@@ -472,6 +421,118 @@ gtk_style_new (void)
       style->text_gc[i] = NULL;
       style->base_gc[i] = NULL;
     }
+
+  style->xthickness = 2;
+  style->ythickness = 2;
+}
+
+static void
+gtk_style_class_init (GtkStyleClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  
+  parent_class = g_type_class_peek_parent (klass);
+
+  object_class->finalize = gtk_style_finalize;
+
+  klass->clone = gtk_style_real_clone;
+  klass->copy = gtk_style_real_copy;
+  klass->init_from_rc = gtk_style_real_init_from_rc;
+  klass->realize = gtk_style_real_realize;
+  klass->unrealize = gtk_style_real_unrealize;
+  klass->set_background = gtk_style_real_set_background;
+  klass->render_icon = gtk_default_render_icon;
+
+  klass->draw_hline = gtk_default_draw_hline;
+  klass->draw_vline = gtk_default_draw_vline;
+  klass->draw_shadow = gtk_default_draw_shadow;
+  klass->draw_polygon = gtk_default_draw_polygon;
+  klass->draw_arrow = gtk_default_draw_arrow;
+  klass->draw_diamond = gtk_default_draw_diamond;
+  klass->draw_string = gtk_default_draw_string;
+  klass->draw_box = gtk_default_draw_box;
+  klass->draw_flat_box = gtk_default_draw_flat_box;
+  klass->draw_check = gtk_default_draw_check;
+  klass->draw_option = gtk_default_draw_option;
+  klass->draw_tab = gtk_default_draw_tab;
+  klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
+  klass->draw_box_gap = gtk_default_draw_box_gap;
+  klass->draw_extension = gtk_default_draw_extension;
+  klass->draw_focus = gtk_default_draw_focus;
+  klass->draw_slider = gtk_default_draw_slider;
+  klass->draw_handle = gtk_default_draw_handle;
+  klass->draw_expander = gtk_default_draw_expander;
+  klass->draw_layout = gtk_default_draw_layout;
+}
+
+static void
+gtk_style_finalize (GObject *object)
+{
+  GtkStyle *style = GTK_STYLE (object);
+
+  g_return_if_fail (style->attach_count == 0);
+  
+  if (style->styles)
+    {
+      if (style->styles->data != style)
+        g_slist_remove (style->styles, style);
+      else
+        {
+          GSList *tmp_list = style->styles->next;
+         
+          while (tmp_list)
+            {
+              ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
+              tmp_list = tmp_list->next;
+            }
+          g_slist_free_1 (style->styles);
+        }
+    }
+  
+  gdk_font_unref (style->font);
+  pango_font_description_free (style->font_desc);
+  
+  if (style->rc_style)
+    gtk_rc_style_unref (style->rc_style);
+  
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+GtkStyle*
+gtk_style_copy (GtkStyle *style)
+{
+  GtkStyle *new_style;
+  
+  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+  
+  new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
+  GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
+
+  return new_style;
+}
+
+static GtkStyle*
+gtk_style_duplicate (GtkStyle *style)
+{
+  GtkStyle *new_style;
+  
+  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+  
+  new_style = gtk_style_copy (style);
+  
+  style->styles = g_slist_append (style->styles, new_style);
+  new_style->styles = style->styles;  
+  
+  return new_style;
+}
+
+GtkStyle*
+gtk_style_new (void)
+{
+  GtkStyle *style;
+  
+  style = g_object_new (GTK_TYPE_STYLE, NULL);
   
   return style;
 }
@@ -516,13 +577,11 @@ gtk_style_attach (GtkStyle  *style,
   GSList *styles;
   GtkStyle *new_style = NULL;
   GdkColormap *colormap;
-  gint depth;
   
-  g_return_val_if_fail (style != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
   g_return_val_if_fail (window != NULL, NULL);
   
   colormap = gdk_window_get_colormap (window);
-  depth = gdk_window_get_visual (window)->depth;
   
   if (!style->styles)
     style->styles = g_slist_append (NULL, style);
@@ -534,11 +593,10 @@ gtk_style_attach (GtkStyle  *style,
       
       if (new_style->attach_count == 0)
         {
-          gtk_style_init (new_style, colormap, depth);
+          gtk_style_realize (new_style, colormap);
           break;
         }
-      else if (new_style->colormap == colormap &&
-               new_style->depth == depth)
+      else if (new_style->colormap == colormap)
         break;
       
       new_style = NULL;
@@ -548,7 +606,7 @@ gtk_style_attach (GtkStyle  *style,
   if (!new_style)
     {
       new_style = gtk_style_duplicate (style);
-      gtk_style_init (new_style, colormap, depth);
+      gtk_style_realize (new_style, colormap);
     }
 
   /* A style gets a refcount from being attached */
@@ -570,29 +628,12 @@ gtk_style_attach (GtkStyle  *style,
 void
 gtk_style_detach (GtkStyle *style)
 {
-  gint i;
-  
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   
   style->attach_count -= 1;
   if (style->attach_count == 0)
     {
-      if (style->engine)
-        style->engine->unrealize_style (style);
-      
-      gtk_gc_release (style->black_gc);
-      gtk_gc_release (style->white_gc);
-      
-      for (i = 0; i < 5; i++)
-        {
-          gtk_gc_release (style->fg_gc[i]);
-          gtk_gc_release (style->bg_gc[i]);
-          gtk_gc_release (style->light_gc[i]);
-          gtk_gc_release (style->dark_gc[i]);
-          gtk_gc_release (style->mid_gc[i]);
-          gtk_gc_release (style->text_gc[i]);
-          gtk_gc_release (style->base_gc[i]);
-        }
+      GTK_STYLE_GET_CLASS (style)->unrealize (style);
       
       gtk_style_unref (style);
     }
@@ -601,157 +642,50 @@ gtk_style_detach (GtkStyle *style)
 GtkStyle*
 gtk_style_ref (GtkStyle *style)
 {
-  g_return_val_if_fail (style != NULL, NULL);
-  g_return_val_if_fail (style->ref_count > 0, NULL);
-  
-  style->ref_count += 1;
-  return style;
+  return (GtkStyle *) g_object_ref (G_OBJECT (style));
 }
 
 void
 gtk_style_unref (GtkStyle *style)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->ref_count > 0);
-  
-  style->ref_count -= 1;
-  if (style->ref_count == 0)
-    gtk_style_destroy (style);
+  g_object_unref (G_OBJECT (style));
 }
 
 static void
-gtk_style_init (GtkStyle    *style,
-                GdkColormap *colormap,
-                gint         depth)
+gtk_style_realize (GtkStyle    *style,
+                   GdkColormap *colormap)
 {
-  GdkGCValues gc_values;
-  GdkGCValuesMask gc_values_mask;
-  gint i;
-  
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   
   style->colormap = colormap;
-  style->depth = depth;
-  
-  for (i = 0; i < 5; i++)
-    {
-      gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
-      gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
-      
-      style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
-      style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
-      style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
-    }
-  
-  gdk_color_black (colormap, &style->black);
-  gdk_color_white (colormap, &style->white);
-  
-  gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
-  if (style->font->type == GDK_FONT_FONT)
-    {
-      gc_values.font = style->font;
-    }
-  else if (style->font->type == GDK_FONT_FONTSET)
-    {
-      gc_values.font = default_font;
-    }
-  
-  gc_values.foreground = style->black;
-  style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-  
-  gc_values.foreground = style->white;
-  style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-  
-  for (i = 0; i < 5; i++)
-    {
-      if (style->rc_style && style->rc_style->bg_pixmap_name[i])
-        style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
-                                                 &style->bg[i],
-                                                 style->rc_style->bg_pixmap_name[i]);
-      
-      if (!gdk_color_alloc (colormap, &style->fg[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->fg[i].red, style->fg[i].green, style->fg[i].blue);
-      if (!gdk_color_alloc (colormap, &style->bg[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->bg[i].red, style->bg[i].green, style->bg[i].blue);
-      if (!gdk_color_alloc (colormap, &style->light[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->light[i].red, style->light[i].green, style->light[i].blue);
-      if (!gdk_color_alloc (colormap, &style->dark[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->dark[i].red, style->dark[i].green, style->dark[i].blue);
-      if (!gdk_color_alloc (colormap, &style->mid[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->mid[i].red, style->mid[i].green, style->mid[i].blue);
-      if (!gdk_color_alloc (colormap, &style->text[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->text[i].red, style->text[i].green, style->text[i].blue);
-      if (!gdk_color_alloc (colormap, &style->base[i]))
-        g_warning ("unable to allocate color: ( %d %d %d )",
-                   style->base[i].red, style->base[i].green, style->base[i].blue);
-      
-      gc_values.foreground = style->fg[i];
-      style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->bg[i];
-      style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->light[i];
-      style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->dark[i];
-      style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->mid[i];
-      style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->text[i];
-      style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-      
-      gc_values.foreground = style->base[i];
-      style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
-    }
-  
-  if (style->engine)
-    style->engine->realize_style (style);
+  style->depth = gdk_colormap_get_visual (colormap)->depth;
+
+  GTK_STYLE_GET_CLASS (style)->realize (style);
 }
 
-static void
-gtk_style_destroy (GtkStyle *style)
+GtkIconSet*
+gtk_style_lookup_icon_set (GtkStyle   *style,
+                           const char *stock_id)
 {
-  g_return_if_fail (style->attach_count == 0);
-  
-  if (style->styles)
-    {
-      if (style->styles->data != style)
-        g_slist_remove (style->styles, style);
-      else
-        {
-          GSList *tmp_list = style->styles->next;
-         
-          while (tmp_list)
-            {
-              ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
-              tmp_list = tmp_list->next;
-            }
-          g_slist_free_1 (style->styles);
-        }
-    }
+  GSList *iter;
+
+  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+  g_return_val_if_fail (stock_id != NULL, NULL);
   
-  if (style->engine)
+  iter = style->icon_factories;
+  while (iter != NULL)
     {
-      style->engine->destroy_style (style);
-      gtk_theme_engine_unref (style->engine);
+      GtkIconSet *icon_set =
+        gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
+                                 stock_id);
+
+      if (icon_set)
+        return icon_set;
+      
+      iter = g_slist_next (iter);
     }
-  
-  gdk_font_unref (style->font);
-  pango_font_description_free (style->font_desc);
-  
-  if (style->rc_style)
-    gtk_rc_style_unref (style->rc_style);
 
-  g_free (style);
+  return gtk_icon_factory_lookup_default (stock_id);
 }
 
 void
@@ -762,11 +696,10 @@ gtk_draw_hline (GtkStyle     *style,
                 gint          x2,
                 gint          y)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_hline != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
   
-  style->klass->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
+  GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
 }
 
 
@@ -778,11 +711,10 @@ gtk_draw_vline (GtkStyle     *style,
                 gint          y2,
                 gint          x)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_vline != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
   
-  style->klass->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
 }
 
 
@@ -796,11 +728,10 @@ gtk_draw_shadow (GtkStyle      *style,
                  gint           width,
                  gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_shadow != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
   
-  style->klass->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -812,11 +743,10 @@ gtk_draw_polygon (GtkStyle      *style,
                   gint           npoints,
                   gboolean       fill)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_polygon != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
   
-  style->klass->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
+  GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
 }
 
 void
@@ -831,11 +761,10 @@ gtk_draw_arrow (GtkStyle      *style,
                 gint           width,
                 gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_arrow != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
   
-  style->klass->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
 }
 
 
@@ -849,31 +778,13 @@ gtk_draw_diamond (GtkStyle      *style,
                   gint           width,
                   gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_diamond != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
   
-  style->klass->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 
-void
-gtk_draw_oval (GtkStyle      *style,
-               GdkWindow     *window,
-               GtkStateType   state_type,
-               GtkShadowType  shadow_type,
-               gint           x,
-               gint           y,
-               gint           width,
-               gint           height)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_oval != NULL);
-  
-  style->klass->draw_oval (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
 void
 gtk_draw_string (GtkStyle      *style,
                  GdkWindow     *window,
@@ -882,11 +793,10 @@ gtk_draw_string (GtkStyle      *style,
                  gint           y,
                  const gchar   *string)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_string != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
   
-  style->klass->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
+  GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
 }
 
 void
@@ -899,11 +809,10 @@ gtk_draw_box (GtkStyle      *style,
               gint           width,
               gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_box != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
   
-  style->klass->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -916,11 +825,10 @@ gtk_draw_flat_box (GtkStyle      *style,
                    gint           width,
                    gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_flat_box != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
   
-  style->klass->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -933,11 +841,10 @@ gtk_draw_check (GtkStyle      *style,
                 gint           width,
                 gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_check != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
   
-  style->klass->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -950,46 +857,10 @@ gtk_draw_option (GtkStyle      *style,
                 gint           width,
                 gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_option != NULL);
-  
-  style->klass->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
-void
-gtk_draw_cross (GtkStyle      *style,
-               GdkWindow     *window,
-               GtkStateType   state_type,
-               GtkShadowType  shadow_type,
-               gint           x,
-               gint           y,
-               gint           width,
-               gint           height)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_cross != NULL);
-  
-  style->klass->draw_cross (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
-}
-
-void
-gtk_draw_ramp (GtkStyle      *style,
-              GdkWindow     *window,
-              GtkStateType   state_type,
-              GtkShadowType  shadow_type,
-              GtkArrowType   arrow_type,
-              gint           x,
-              gint           y,
-              gint           width,
-              gint           height)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_ramp != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
   
-  style->klass->draw_ramp (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -1002,11 +873,10 @@ gtk_draw_tab (GtkStyle      *style,
              gint           width,
              gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_tab != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
   
-  style->klass->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
 void
@@ -1022,11 +892,10 @@ gtk_draw_shadow_gap (GtkStyle       *style,
                      gint            gap_x,
                      gint            gap_width)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_shadow_gap != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
   
-  style->klass->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
+  GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 void
@@ -1042,11 +911,10 @@ gtk_draw_box_gap (GtkStyle       *style,
                   gint            gap_x,
                   gint            gap_width)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_box_gap != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
   
-  style->klass->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
+  GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 void
@@ -1060,11 +928,10 @@ gtk_draw_extension (GtkStyle       *style,
                     gint            height,
                     GtkPositionType gap_side)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_extension != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
   
-  style->klass->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
+  GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
 }
 
 void
@@ -1075,67 +942,306 @@ gtk_draw_focus (GtkStyle      *style,
                gint           width,
                gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_focus != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
+}
+
+void 
+gtk_draw_slider (GtkStyle      *style,
+                GdkWindow     *window,
+                GtkStateType   state_type,
+                GtkShadowType  shadow_type,
+                gint           x,
+                gint           y,
+                gint           width,
+                gint           height,
+                GtkOrientation orientation)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
+}
+
+void 
+gtk_draw_handle (GtkStyle      *style,
+                GdkWindow     *window,
+                GtkStateType   state_type,
+                GtkShadowType  shadow_type,
+                gint           x,
+                gint           y,
+                gint           width,
+                gint           height,
+                GtkOrientation orientation)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
+}
+
+void
+gtk_draw_expander (GtkStyle        *style,
+                   GdkWindow       *window,
+                   GtkStateType     state_type,
+                   gint             x,
+                   gint             y,
+                   gboolean         is_open)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
+                                              NULL, NULL, NULL,
+                                              x, y, is_open);
+}
+
+void
+gtk_draw_layout (GtkStyle        *style,
+                 GdkWindow       *window,
+                 GtkStateType     state_type,
+                 gint             x,
+                 gint             y,
+                 PangoLayout     *layout)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type,
+                                            NULL, NULL, NULL,
+                                            x, y, layout);
+}
+
+void
+gtk_style_set_background (GtkStyle    *style,
+                          GdkWindow   *window,
+                          GtkStateType state_type)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (window != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
+}
+
+/* Default functions */
+static GtkStyle *
+gtk_style_real_clone (GtkStyle *style)
+{
+  return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
+}
+
+static void
+gtk_style_real_copy (GtkStyle *style,
+                    GtkStyle *src)
+{
+  gint i;
+  
+  for (i = 0; i < 5; i++)
+    {
+      style->fg[i] = src->fg[i];
+      style->bg[i] = src->bg[i];
+      style->text[i] = src->text[i];
+      style->base[i] = src->base[i];
+      
+      style->bg_pixmap[i] = src->bg_pixmap[i];
+    }
+
+  if (style->font)
+    gdk_font_unref (style->font);
+  style->font = src->font;
+  if (style->font)
+    gdk_font_ref (style->font);
+
+  if (style->font_desc)
+    pango_font_description_free (style->font_desc);
+  if (src->font_desc)
+    style->font_desc = pango_font_description_copy (src->font_desc);
+  else
+    style->font_desc = NULL;
+  
+  style->xthickness = src->xthickness;
+  style->ythickness = src->ythickness;
+
+  if (style->rc_style)
+    gtk_rc_style_unref (style->rc_style);
+  style->rc_style = src->rc_style;
+  if (src->rc_style)
+    gtk_rc_style_ref (src->rc_style);
+}
+
+static void
+gtk_style_real_init_from_rc (GtkStyle   *style,
+                            GtkRcStyle *rc_style)
+{
+  GdkFont *old_font;
+  gint i;
+
+  if (rc_style->font_desc)
+    {
+      pango_font_description_free (style->font_desc);
+      style->font_desc = pango_font_description_copy (rc_style->font_desc);
+
+      old_font = style->font;
+      style->font = gdk_font_from_description (style->font_desc);
+      if (style->font)
+       gdk_font_unref (old_font);
+      else
+       style->font = old_font;
+    }
+    
+  for (i = 0; i < 5; i++)
+    {
+      if (rc_style->color_flags[i] & GTK_RC_FG)
+       style->fg[i] = rc_style->fg[i];
+      if (rc_style->color_flags[i] & GTK_RC_BG)
+       style->bg[i] = rc_style->bg[i];
+      if (rc_style->color_flags[i] & GTK_RC_TEXT)
+       style->text[i] = rc_style->text[i];
+      if (rc_style->color_flags[i] & GTK_RC_BASE)
+       style->base[i] = rc_style->base[i];
+    }
+
+  if (rc_style->xthickness >= 0)
+    style->xthickness = rc_style->xthickness;
+  if (rc_style->ythickness >= 0)
+    style->ythickness = rc_style->ythickness;
+
+  
+  if (rc_style->icon_factories)
+    {
+      GSList *iter;
+
+      style->icon_factories = g_slist_copy (rc_style->icon_factories);
+      
+      iter = style->icon_factories;
+      while (iter != NULL)
+        {
+          g_object_ref (G_OBJECT (iter->data));
+          
+          iter = g_slist_next (iter);
+        }
+    }
+}
+
+static void
+gtk_style_real_realize (GtkStyle *style)
+{
+  GdkGCValues gc_values;
+  GdkGCValuesMask gc_values_mask;
+  
+  gint i;
+
+  for (i = 0; i < 5; i++)
+    {
+      gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
+      gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
+      
+      style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
+      style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
+      style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
+    }
+  
+  gdk_color_black (style->colormap, &style->black);
+  gdk_color_white (style->colormap, &style->white);
+  
+  gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
+  if (style->font->type == GDK_FONT_FONT)
+    {
+      gc_values.font = style->font;
+    }
+  else if (style->font->type == GDK_FONT_FONTSET)
+    {
+      gc_values.font = default_font;
+    }
+  
+  gc_values.foreground = style->black;
+  style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+  
+  gc_values.foreground = style->white;
+  style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
   
-  style->klass->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
+  for (i = 0; i < 5; i++)
+    {
+      if (style->rc_style && style->rc_style->bg_pixmap_name[i])
+        style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
+                                                 &style->bg[i],
+                                                 style->rc_style->bg_pixmap_name[i]);
+      
+      if (!gdk_color_alloc (style->colormap, &style->fg[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->fg[i].red, style->fg[i].green, style->fg[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->bg[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->bg[i].red, style->bg[i].green, style->bg[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->light[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->light[i].red, style->light[i].green, style->light[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->dark[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->dark[i].red, style->dark[i].green, style->dark[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->mid[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->mid[i].red, style->mid[i].green, style->mid[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->text[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->text[i].red, style->text[i].green, style->text[i].blue);
+      if (!gdk_color_alloc (style->colormap, &style->base[i]))
+        g_warning ("unable to allocate color: ( %d %d %d )",
+                   style->base[i].red, style->base[i].green, style->base[i].blue);
+      
+      gc_values.foreground = style->fg[i];
+      style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->bg[i];
+      style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->light[i];
+      style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->dark[i];
+      style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->mid[i];
+      style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->text[i];
+      style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+      
+      gc_values.foreground = style->base[i];
+      style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
+    }
 }
 
-void 
-gtk_draw_slider (GtkStyle      *style,
-                GdkWindow     *window,
-                GtkStateType   state_type,
-                GtkShadowType  shadow_type,
-                gint           x,
-                gint           y,
-                gint           width,
-                gint           height,
-                GtkOrientation orientation)
+static void
+gtk_style_real_unrealize (GtkStyle *style)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_slider != NULL);
-  
-  style->klass->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
-}
+  int i;
 
-void 
-gtk_draw_handle (GtkStyle      *style,
-                GdkWindow     *window,
-                GtkStateType   state_type,
-                GtkShadowType  shadow_type,
-                gint           x,
-                gint           y,
-                gint           width,
-                gint           height,
-                GtkOrientation orientation)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_handle != NULL);
-  
-  style->klass->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
+  gtk_gc_release (style->black_gc);
+  gtk_gc_release (style->white_gc);
+      
+  for (i = 0; i < 5; i++)
+    {
+      gtk_gc_release (style->fg_gc[i]);
+      gtk_gc_release (style->bg_gc[i]);
+      gtk_gc_release (style->light_gc[i]);
+      gtk_gc_release (style->dark_gc[i]);
+      gtk_gc_release (style->mid_gc[i]);
+      gtk_gc_release (style->text_gc[i]);
+      gtk_gc_release (style->base_gc[i]);
+    }
 }
 
-void
-gtk_style_set_background (GtkStyle    *style,
-                          GdkWindow   *window,
-                          GtkStateType state_type)
+static void
+gtk_style_real_set_background (GtkStyle    *style,
+                              GdkWindow   *window,
+                              GtkStateType state_type)
 {
   GdkPixmap *pixmap;
   gint parent_relative;
   
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-  
-  if (style->engine && style->engine->set_background)
-    {
-      style->engine->set_background (style, window, state_type);
-      
-      return;
-    }
-  
   if (style->bg_pixmap[state_type])
     {
       if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
@@ -1155,6 +1261,27 @@ gtk_style_set_background (GtkStyle    *style,
     gdk_window_set_background (window, &style->bg[state_type]);
 }
 
+GdkPixbuf *
+gtk_style_render_icon (GtkStyle            *style,
+                       const GtkIconSource *source,
+                       GtkTextDirection     direction,
+                       GtkStateType         state,
+                       const gchar         *size,
+                       GtkWidget           *widget,
+                       const gchar         *detail)
+{
+  GdkPixbuf *pixbuf;
+  
+  g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
+  g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
+  
+  pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
+                                                     size, widget, detail);
+
+  g_return_val_if_fail (pixbuf != NULL, NULL);
+
+  return pixbuf;
+}
 
 /* Default functions */
 void
@@ -1189,7 +1316,7 @@ gtk_style_apply_default_background (GtkStyle     *style,
     }
   
   if (!style->bg_pixmap[state_type] ||
-      gdk_window_get_type (window) == GDK_WINDOW_PIXMAP ||
+      GDK_IS_PIXMAP (window) ||
       (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
     {
       GdkGC *gc = style->bg_gc[state_type];
@@ -1221,6 +1348,92 @@ gtk_style_apply_default_background (GtkStyle     *style,
     }
 }
 
+static GdkPixbuf*
+scale_or_ref (GdkPixbuf *src,
+              gint width,
+              gint height)
+{
+  if (width == gdk_pixbuf_get_width (src) &&
+      height == gdk_pixbuf_get_height (src))
+    {
+      gdk_pixbuf_ref (src);
+      return src;
+    }
+  else
+    {
+      return gdk_pixbuf_scale_simple (src,
+                                      width, height,
+                                      GDK_INTERP_BILINEAR);
+    }
+}
+
+static GdkPixbuf *
+gtk_default_render_icon (GtkStyle            *style,
+                          const GtkIconSource *source,
+                          GtkTextDirection     direction,
+                          GtkStateType         state,
+                          const gchar         *size,
+                          GtkWidget           *widget,
+                          const gchar         *detail)
+{
+  gint width = 1;
+  gint height = 1;
+  GdkPixbuf *scaled;
+  GdkPixbuf *stated;
+
+  /* Oddly, style can be NULL in this function, because
+   * GtkIconSet can be used without a style and if so
+   * it uses this function.
+   */
+  
+  g_return_val_if_fail (source->pixbuf != NULL, NULL);
+  
+  if (!gtk_icon_size_lookup (size, &width, &height))
+    {
+      g_warning ("Bad icon size '%s' passed to render_icon", size);
+      return NULL;
+    }
+
+  /* If the size was wildcarded, then scale; otherwise, leave it
+   * alone.
+   */
+  if (source->any_size)
+    scaled = scale_or_ref (source->pixbuf, width, height);
+  else
+    scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (source->pixbuf)));
+
+  /* If the state was wildcarded, then generate a state. */
+  if (source->any_state)
+    {
+      if (state == GTK_STATE_INSENSITIVE)
+        {
+          stated = gdk_pixbuf_copy (scaled);      
+          
+          gdk_pixbuf_saturate_and_pixelate (scaled, stated,
+                                            0.8, TRUE);
+          
+          gdk_pixbuf_unref (scaled);
+        }
+      else if (state == GTK_STATE_PRELIGHT)
+        {
+          stated = gdk_pixbuf_copy (scaled);      
+          
+          gdk_pixbuf_saturate_and_pixelate (scaled, stated,
+                                            1.2, FALSE);
+          
+          gdk_pixbuf_unref (scaled);
+        }
+      else
+        {
+          stated = scaled;
+        }
+    }
+  else
+    stated = scaled;
+  
+  return stated;
+}
+
 static void
 gtk_default_draw_hline (GtkStyle     *style,
                         GdkWindow    *window,
@@ -1236,11 +1449,11 @@ gtk_default_draw_hline (GtkStyle     *style,
   gint thickness_dark;
   gint i;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
-  thickness_light = style->klass->ythickness / 2;
-  thickness_dark = style->klass->ythickness - thickness_light;
+  thickness_light = style->ythickness / 2;
+  thickness_dark = style->ythickness - thickness_light;
   
   if (area)
     {
@@ -1293,11 +1506,11 @@ gtk_default_draw_vline (GtkStyle     *style,
   gint thickness_dark;
   gint i;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
-  thickness_light = style->klass->xthickness / 2;
-  thickness_dark = style->klass->xthickness - thickness_light;
+  thickness_light = style->xthickness / 2;
+  thickness_dark = style->xthickness - thickness_light;
   
   if (area)
     {
@@ -1343,7 +1556,7 @@ gtk_default_draw_shadow (GtkStyle      *style,
   gint thickness_dark;
   gint i;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if ((width == -1) && (height == -1))
@@ -1522,7 +1735,7 @@ gtk_default_draw_polygon (GtkStyle      *style,
   gint yadjust;
   gint i;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   g_return_if_fail (points != NULL);
   
@@ -1656,7 +1869,7 @@ gtk_default_draw_arrow (GtkStyle      *style,
   gint half_height;
   GdkPoint points[3];
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   switch (shadow_type)
@@ -2002,7 +2215,7 @@ gtk_default_draw_diamond (GtkStyle      *style,
   gint half_width;
   gint half_height;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if ((width == -1) && (height == -1))
@@ -2114,25 +2327,6 @@ gtk_default_draw_diamond (GtkStyle      *style,
     }
 }
 
-static void
-gtk_default_draw_oval (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)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
-  g_warning ("gtk_default_draw_oval(): FIXME, this function is currently unimplemented");
-}
-
 static void
 gtk_default_draw_string (GtkStyle      *style,
                          GdkWindow     *window,
@@ -2144,7 +2338,7 @@ gtk_default_draw_string (GtkStyle      *style,
                          gint           y,
                          const gchar   *string)
 {
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (area)
@@ -2178,7 +2372,7 @@ gtk_default_draw_box (GtkStyle      *style,
                      gint           width,
                      gint           height)
 {
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -2189,7 +2383,7 @@ gtk_default_draw_box (GtkStyle      *style,
     gdk_window_get_size (window, NULL, &height);
   
   if (!style->bg_pixmap[state_type] || 
-      gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
+      GDK_IS_PIXMAP (window))
     {
       if (area)
        gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
@@ -2223,7 +2417,7 @@ gtk_default_draw_flat_box (GtkStyle      *style,
 {
   GdkGC *gc1;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -2248,7 +2442,7 @@ gtk_default_draw_flat_box (GtkStyle      *style,
     gc1 = style->bg_gc[state_type];
   
   if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
-      gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
+      GDK_IS_PIXMAP (window))
     {
       if (area)
        gdk_gc_set_clip_rectangle (gc1, area);
@@ -2303,45 +2497,6 @@ gtk_default_draw_option (GtkStyle      *style,
                      detail, x, y, width, height);
 }
 
-static void 
-gtk_default_draw_cross (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)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
-  g_warning ("gtk_default_draw_cross(): FIXME, this function is currently unimplemented");
-}
-
-static void 
-gtk_default_draw_ramp    (GtkStyle      *style,
-                          GdkWindow     *window,
-                          GtkStateType   state_type,
-                          GtkShadowType  shadow_type,
-                          GdkRectangle  *area,
-                          GtkWidget     *widget,
-                          const gchar   *detail,
-                          GtkArrowType   arrow_type,
-                          gint           x,
-                          gint           y,
-                          gint           width,
-                          gint           height)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (window != NULL);
-
-  g_warning ("gtk_default_draw_ramp(): FIXME, this function is currently unimplemented");
-}
-
 static void
 gtk_default_draw_tab (GtkStyle      *style,
                      GdkWindow     *window,
@@ -2355,7 +2510,7 @@ gtk_default_draw_tab (GtkStyle      *style,
                      gint           width,
                      gint           height)
 {
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
@@ -2383,7 +2538,7 @@ gtk_default_draw_shadow_gap (GtkStyle       *style,
   GdkGC *gc3 = NULL;
   GdkGC *gc4 = NULL;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -2604,7 +2759,7 @@ gtk_default_draw_box_gap (GtkStyle       *style,
   GdkGC *gc3 = NULL;
   GdkGC *gc4 = NULL;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   gtk_style_apply_default_background (style, window,
@@ -2828,7 +2983,7 @@ gtk_default_draw_extension (GtkStyle       *style,
   GdkGC *gc3 = NULL;
   GdkGC *gc4 = NULL;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   gtk_style_apply_default_background (style, window,
@@ -2893,10 +3048,10 @@ gtk_default_draw_extension (GtkStyle       *style,
           gtk_style_apply_default_background (style, window,
                                               widget && !GTK_WIDGET_NO_WINDOW (widget),
                                               state_type, area,
-                                              x + style->klass->xthickness, 
+                                              x + style->xthickness, 
                                               y, 
-                                              width - (2 * style->klass->xthickness), 
-                                              height - (style->klass->ythickness));
+                                              width - (2 * style->xthickness), 
+                                              height - (style->ythickness));
           gdk_draw_line (window, gc1,
                          x, y, x, y + height - 2);
           gdk_draw_line (window, gc2,
@@ -2915,10 +3070,10 @@ gtk_default_draw_extension (GtkStyle       *style,
           gtk_style_apply_default_background (style, window,
                                               widget && !GTK_WIDGET_NO_WINDOW (widget),
                                               state_type, area,
-                                              x + style->klass->xthickness, 
-                                              y + style->klass->ythickness, 
-                                              width - (2 * style->klass->xthickness), 
-                                              height - (style->klass->ythickness));
+                                              x + style->xthickness, 
+                                              y + style->ythickness, 
+                                              width - (2 * style->xthickness), 
+                                              height - (style->ythickness));
           gdk_draw_line (window, gc1,
                          x + 1, y, x + width - 2, y);
           gdk_draw_line (window, gc1,
@@ -2938,9 +3093,9 @@ gtk_default_draw_extension (GtkStyle       *style,
                                               widget && !GTK_WIDGET_NO_WINDOW (widget),
                                               state_type, area,
                                               x, 
-                                              y + style->klass->ythickness, 
-                                              width - (style->klass->xthickness), 
-                                              height - (2 * style->klass->ythickness));
+                                              y + style->ythickness, 
+                                              width - (style->xthickness), 
+                                              height - (2 * style->ythickness));
           gdk_draw_line (window, gc1,
                          x, y, x + width - 2, y);
           gdk_draw_line (window, gc2,
@@ -2959,10 +3114,10 @@ gtk_default_draw_extension (GtkStyle       *style,
           gtk_style_apply_default_background (style, window,
                                               widget && !GTK_WIDGET_NO_WINDOW (widget),
                                               state_type, area,
-                                              x + style->klass->xthickness, 
-                                              y + style->klass->ythickness, 
-                                              width - (style->klass->xthickness), 
-                                              height - (2 * style->klass->ythickness));
+                                              x + style->xthickness, 
+                                              y + style->ythickness, 
+                                              width - (style->xthickness), 
+                                              height - (2 * style->ythickness));
           gdk_draw_line (window, gc1,
                          x + 1, y, x + width - 1, y);
           gdk_draw_line (window, gc1,
@@ -3000,7 +3155,7 @@ gtk_default_draw_focus (GtkStyle      *style,
                         gint           width,
                         gint           height)
 {
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -3059,7 +3214,7 @@ gtk_default_draw_slider (GtkStyle      *style,
                          gint           height,
                          GtkOrientation orientation)
 {
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -3074,12 +3229,12 @@ gtk_default_draw_slider (GtkStyle      *style,
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     gtk_paint_vline (style, window, state_type, area, widget, detail, 
-                     style->klass->ythickness, 
-                     height - style->klass->ythickness - 1, width / 2);
+                     style->ythickness, 
+                     height - style->ythickness - 1, width / 2);
   else
     gtk_paint_hline (style, window, state_type, area, widget, detail, 
-                     style->klass->xthickness, 
-                     width - style->klass->xthickness - 1, height / 2);
+                     style->xthickness, 
+                     width - style->xthickness - 1, height / 2);
 }
 
 static void
@@ -3130,7 +3285,7 @@ gtk_default_draw_handle (GtkStyle      *style,
   GdkRectangle dest;
   gint intersect;
   
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   if (width == -1 && height == -1)
@@ -3155,8 +3310,8 @@ gtk_default_draw_handle (GtkStyle      *style,
     }
   else
     {
-      xthick = style->klass->xthickness;
-      ythick = style->klass->ythickness;
+      xthick = style->xthickness;
+      ythick = style->ythickness;
 
       light_gc = style->light_gc[state_type];
       dark_gc = style->dark_gc[state_type];
@@ -3209,6 +3364,97 @@ gtk_default_draw_handle (GtkStyle      *style,
   gdk_gc_set_clip_rectangle (dark_gc, NULL);
 }
 
+static void
+gtk_default_draw_expander (GtkStyle        *style,
+                           GdkWindow       *window,
+                           GtkStateType     state_type,
+                           GdkRectangle    *area,
+                           GtkWidget       *widget,
+                           const gchar     *detail,
+                           gint             x,
+                           gint             y,
+                           gboolean         is_open)
+{
+  /* FIXME replace macro with a style property */
+#define PM_SIZE 8
+  
+  GdkPoint points[3];
+
+  if (area)
+    {
+      gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
+      gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
+    }
+
+  if (is_open)
+    {
+      points[0].x = x;
+      points[0].y = y + (PM_SIZE + 2) / 6;
+      points[1].x = points[0].x + 1 * (PM_SIZE + 2);
+      points[1].y = points[0].y;
+      points[2].x = (points[0].x + 1 * (PM_SIZE + 2) / 2);
+      points[2].y = y + 2 * (PM_SIZE + 2) / 3;
+    }
+  else
+    {
+      points[0].x = x + 1 * ((PM_SIZE + 2) / 6 + 2);
+      points[0].y = y - 1;
+      points[1].x = points[0].x;
+      points[1].y = points[0].y + (PM_SIZE + 2);
+      points[2].x = (points[0].x + 1 * (2 * (PM_SIZE + 2) / 3 - 1));
+      points[2].y = points[0].y + (PM_SIZE + 2) / 2;
+    }
+
+  gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
+                    TRUE, points, 3);
+  gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
+                    FALSE, points, 3);
+  
+
+  if (area)
+    {
+      gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
+      gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
+    }
+  
+#undef PM_SIZE
+}
+
+static void
+gtk_default_draw_layout (GtkStyle        *style,
+                         GdkWindow       *window,
+                         GtkStateType     state_type,
+                         GdkRectangle    *area,
+                         GtkWidget       *widget,
+                         const gchar     *detail,
+                         gint             x,
+                         gint             y,
+                         PangoLayout     *layout)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (window != NULL);
+  
+  if (area)
+    {
+      gdk_gc_set_clip_rectangle (style->white_gc, area);
+      gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
+    }
+
+  /* FIXME this is frickin' ugly with any kind of attributes set on the
+   * text being rendered
+   */
+  if (state_type == GTK_STATE_INSENSITIVE)
+    gdk_draw_layout (window, style->white_gc, x + 1, y + 1, layout);
+
+  gdk_draw_layout (window, style->fg_gc[state_type], x, y, layout);
+
+  if (area)
+    {
+      gdk_gc_set_clip_rectangle (style->white_gc, NULL);
+      gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
+    }
+}
+
 static void
 gtk_style_shade (GdkColor *a,
                  GdkColor *b,
@@ -3404,11 +3650,10 @@ gtk_paint_hline (GtkStyle      *style,
                  gint          x2,
                  gint          y)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_hline != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
   
-  style->klass->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
+  GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
 }
 
 void
@@ -3422,11 +3667,10 @@ gtk_paint_vline (GtkStyle      *style,
                  gint          y2,
                  gint          x)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_vline != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
   
-  style->klass->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
 }
 
 void
@@ -3442,11 +3686,10 @@ gtk_paint_shadow (GtkStyle     *style,
                   gint          width,
                   gint          height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_shadow != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
   
-  style->klass->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3461,11 +3704,10 @@ gtk_paint_polygon (GtkStyle      *style,
                    gint           npoints,
                    gboolean       fill)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_shadow != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
   
-  style->klass->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
+  GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
 }
 
 void
@@ -3483,11 +3725,10 @@ gtk_paint_arrow (GtkStyle      *style,
                  gint           width,
                  gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_arrow != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
   
-  style->klass->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
 }
 
 void
@@ -3503,31 +3744,10 @@ gtk_paint_diamond (GtkStyle      *style,
                    gint        width,
                    gint        height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_diamond != NULL);
-  
-  style->klass->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-
-void
-gtk_paint_oval (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)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_oval != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
   
-  style->klass->draw_oval (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3541,11 +3761,10 @@ gtk_paint_string (GtkStyle      *style,
                   gint           y,
                   const gchar   *string)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_string != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
   
-  style->klass->draw_string (style, window, state_type, area, widget, detail, x, y, string);
+  GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
 }
 
 void
@@ -3561,11 +3780,10 @@ gtk_paint_box (GtkStyle      *style,
                gint           width,
                gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_box != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
   
-  style->klass->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3581,11 +3799,10 @@ gtk_paint_flat_box (GtkStyle      *style,
                     gint           width,
                     gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_flat_box != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
   
-  style->klass->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3601,11 +3818,10 @@ gtk_paint_check (GtkStyle      *style,
                  gint           width,
                  gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_check != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
   
-  style->klass->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3621,52 +3837,10 @@ gtk_paint_option (GtkStyle      *style,
                   gint           width,
                   gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_option != NULL);
-  
-  style->klass->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-
-void
-gtk_paint_cross (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)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_cross != NULL);
-  
-  style->klass->draw_cross (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
-}
-
-void
-gtk_paint_ramp (GtkStyle      *style,
-                GdkWindow     *window,
-                GtkStateType   state_type,
-                GtkShadowType  shadow_type,
-                GdkRectangle  *area,
-                GtkWidget     *widget,
-                const gchar   *detail,
-                GtkArrowType   arrow_type,
-                gint           x,
-                gint           y,
-                gint           width,
-                gint           height)
-{
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_ramp != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
   
-  style->klass->draw_ramp (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3682,11 +3856,10 @@ gtk_paint_tab (GtkStyle      *style,
                gint           width,
                gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_tab != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
   
-  style->klass->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3705,11 +3878,10 @@ gtk_paint_shadow_gap (GtkStyle       *style,
                       gint            gap_x,
                       gint            gap_width)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_shadow_gap != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
   
-  style->klass->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+  GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 
@@ -3729,11 +3901,10 @@ gtk_paint_box_gap (GtkStyle       *style,
                    gint            gap_x,
                    gint            gap_width)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_box_gap != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
   
-  style->klass->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+  GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 void
@@ -3750,11 +3921,10 @@ gtk_paint_extension (GtkStyle       *style,
                      gint            height,
                      GtkPositionType gap_side)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_extension != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
   
-  style->klass->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
+  GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
 }
 
 void
@@ -3768,11 +3938,10 @@ gtk_paint_focus (GtkStyle      *style,
                  gint           width,
                  gint           height)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_focus != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
   
-  style->klass->draw_focus (style, window, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -3789,11 +3958,10 @@ gtk_paint_slider (GtkStyle      *style,
                   gint           height,
                   GtkOrientation orientation)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_slider != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
   
-  style->klass->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+  GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
 }
 
 void
@@ -3810,9 +3978,46 @@ gtk_paint_handle (GtkStyle      *style,
                   gint           height,
                   GtkOrientation orientation)
 {
-  g_return_if_fail (style != NULL);
-  g_return_if_fail (style->klass != NULL);
-  g_return_if_fail (style->klass->draw_handle != NULL);
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+}
+
+void
+gtk_paint_expander (GtkStyle        *style,
+                    GdkWindow       *window,
+                    GtkStateType     state_type,
+                    GdkRectangle    *area,
+                    GtkWidget       *widget,
+                    const gchar     *detail,
+                    gint             x,
+                    gint             y,
+                    gboolean         is_open)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
+  
+  GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
+                                              widget, detail, x, y, is_open);
+}
+
+void
+gtk_paint_layout (GtkStyle        *style,
+                  GdkWindow       *window,
+                  GtkStateType     state_type,
+                  GdkRectangle    *area,
+                  GtkWidget       *widget,
+                  const gchar     *detail,
+                  gint             x,
+                  gint             y,
+                  PangoLayout     *layout)
+{
+  g_return_if_fail (GTK_IS_STYLE (style));
+  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
   
-  style->klass->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+  GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, area,
+                                            widget, detail, x, y, layout);
 }
+
+