]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkstyle.c
Updated Slovenian translation
[~andy/gtk] / gtk / gtkstyle.c
index f3c071d6239e1dc3e967f8bef793d2b7481eb49b..769fe79143b6170783586fab3f42a0cb88f18f4e 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
+#include <gobject/gvaluecollector.h>
 #include "gtkgc.h"
 #include "gtkmarshalers.h"
+#undef GTK_DISABLE_DEPRECATED
+#include "gtkoptionmenu.h"
 #include "gtkrc.h"
 #include "gtkspinbutton.h"
 #include "gtkstyle.h"
@@ -588,7 +591,7 @@ gtk_style_finalize (GObject *object)
   if (style->styles)
     {
       if (style->styles->data != style)
-        g_slist_remove (style->styles, style);
+        style->styles = g_slist_remove (style->styles, style);
       else
         {
           GSList *tmp_list = style->styles->next;
@@ -615,14 +618,22 @@ gtk_style_finalize (GObject *object)
 
   if (style->private_font_desc)
     pango_font_description_free (style->private_font_desc);
-  
+
   if (style->rc_style)
-    gtk_rc_style_unref (style->rc_style);
-  
+    g_object_unref (style->rc_style);
+
   G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object);
 }
 
 
+/**
+ * gtk_style_copy:
+ * @style: a #GtkStyle
+ *
+ * Creates a copy of the passed in #GtkStyle object.
+ *
+ * Returns: a copy of @style
+ */
 GtkStyle*
 gtk_style_copy (GtkStyle *style)
 {
@@ -676,10 +687,6 @@ gtk_style_new (void)
  * gtk_style_attach:
  * @style: a #GtkStyle.
  * @window: a #GdkWindow.
- * @returns: Either @style, or a newly-created #GtkStyle.
- *   If the style is newly created, the style parameter
- *   will be dereferenced, and the new style will have
- *   a reference count belonging to the caller.
  *
  * Attaches a style to a window; this process allocates the
  * colors and creates the GC's for the style - it specializes
@@ -690,7 +697,12 @@ gtk_style_new (void)
  * Since this function may return a new object, you have to use it 
  * in the following way: 
  * <literal>style = gtk_style_attach (style, window)</literal>
- **/
+ *
+ * Returns: Either @style, or a newly-created #GtkStyle.
+ *   If the style is newly created, the style parameter
+ *   will be unref'ed, and the new style will have
+ *   a reference count belonging to the caller.
+ */
 GtkStyle*
 gtk_style_attach (GtkStyle  *style,
                   GdkWindow *window)
@@ -809,8 +821,10 @@ gtk_style_detach (GtkStyle *style)
  * @style: a #GtkStyle.
  * @returns: @style.
  *
- * Deprecated equivalent of g_object_ref().
- **/
+ * Increase the reference count of @style.
+ * 
+ * Deprecated: 2.0: use g_object_ref() instead.
+ */
 GtkStyle*
 gtk_style_ref (GtkStyle *style)
 {
@@ -821,8 +835,10 @@ gtk_style_ref (GtkStyle *style)
  * gtk_style_unref:
  * @style: a #GtkStyle.
  *
- * Deprecated equivalent of g_object_unref().
- **/
+ * Decrease the reference count of @style.
+ * 
+ * Deprecated: 2.0: use g_object_unref() instead.
+ */
 void
 gtk_style_unref (GtkStyle *style)
 {
@@ -839,6 +855,17 @@ gtk_style_realize (GtkStyle    *style,
   g_signal_emit (style, realize_signal, 0);
 }
 
+/**
+ * gtk_style_lookup_icon_set:
+ * @style: a #GtkStyle
+ * @stock_id: an icon name
+ *
+ * Looks up @stock_id in the icon factories associated with @style
+ * and the default icon factory, returning an icon set if found,
+ * otherwise %NULL.
+ *
+ * Return value: icon set of @stock_id
+ */
 GtkIconSet*
 gtk_style_lookup_icon_set (GtkStyle   *style,
                            const char *stock_id)
@@ -921,7 +948,7 @@ gtk_style_lookup_color (GtkStyle   *style,
  * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
  * using the given style and state.
  * 
- * Deprecated: Use gtk_paint_hline() instead.
+ * Deprecated: 2.0: Use gtk_paint_hline() instead.
  **/
 void
 gtk_draw_hline (GtkStyle     *style,
@@ -950,7 +977,7 @@ gtk_draw_hline (GtkStyle     *style,
  * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @window
  * using the given style and state.
  * 
- * Deprecated: Use gtk_paint_vline() instead.
+ * Deprecated: 2.0: Use gtk_paint_vline() instead.
  **/
 void
 gtk_draw_vline (GtkStyle     *style,
@@ -980,7 +1007,7 @@ gtk_draw_vline (GtkStyle     *style,
  * Draws a shadow around the given rectangle in @window 
  * using the given style and state and shadow type.
  * 
- * Deprecated: Use gtk_paint_shadow() instead.
+ * Deprecated: 2.0: Use gtk_paint_shadow() instead.
  */
 void
 gtk_draw_shadow (GtkStyle      *style,
@@ -1010,7 +1037,7 @@ gtk_draw_shadow (GtkStyle      *style,
  * 
  * Draws a polygon on @window with the given parameters.
  *
- * Deprecated: Use gtk_paint_polygon() instead.
+ * Deprecated: 2.0: Use gtk_paint_polygon() instead.
  */ 
 void
 gtk_draw_polygon (GtkStyle      *style,
@@ -1043,7 +1070,7 @@ gtk_draw_polygon (GtkStyle      *style,
  * Draws an arrow in the given rectangle on @window using the given 
  * parameters. @arrow_type determines the direction of the arrow.
  *
- * Deprecated: Use gtk_paint_arrow() instead.
+ * Deprecated: 2.0: Use gtk_paint_arrow() instead.
  */
 void
 gtk_draw_arrow (GtkStyle      *style,
@@ -1077,7 +1104,7 @@ gtk_draw_arrow (GtkStyle      *style,
  * Draws a diamond in the given rectangle on @window using the given
  * parameters.
  *
- * Deprecated: Use gtk_paint_diamond() instead.
+ * Deprecated: 2.0: Use gtk_paint_diamond() instead.
  */
 void
 gtk_draw_diamond (GtkStyle      *style,
@@ -1106,7 +1133,7 @@ gtk_draw_diamond (GtkStyle      *style,
  * 
  * Draws a text string on @window with the given parameters.
  *
- * Deprecated: Use gtk_paint_layout() instead.
+ * Deprecated: 2.0: Use gtk_paint_layout() instead.
  */
 void
 gtk_draw_string (GtkStyle      *style,
@@ -1135,7 +1162,7 @@ gtk_draw_string (GtkStyle      *style,
  * 
  * Draws a box on @window with the given parameters.
  *
- * Deprecated: Use gtk_paint_box() instead.
+ * Deprecated: 2.0: Use gtk_paint_box() instead.
  */
 void
 gtk_draw_box (GtkStyle      *style,
@@ -1166,7 +1193,7 @@ gtk_draw_box (GtkStyle      *style,
  * 
  * Draws a flat box on @window with the given parameters.
  *
- * Deprecated: Use gtk_paint_flat_box() instead.
+ * Deprecated: 2.0: Use gtk_paint_flat_box() instead.
  */
 void
 gtk_draw_flat_box (GtkStyle      *style,
@@ -1198,7 +1225,7 @@ gtk_draw_flat_box (GtkStyle      *style,
  * Draws a check button indicator in the given rectangle on @window with 
  * the given parameters.
  *
- * Deprecated: Use gtk_paint_check() instead.
+ * Deprecated: 2.0: Use gtk_paint_check() instead.
  */
 void
 gtk_draw_check (GtkStyle      *style,
@@ -1230,7 +1257,7 @@ gtk_draw_check (GtkStyle      *style,
  * Draws a radio button indicator in the given rectangle on @window with 
  * the given parameters.
  *
- * Deprecated: Use gtk_paint_option() instead.
+ * Deprecated: 2.0: Use gtk_paint_option() instead.
  */
 void
 gtk_draw_option (GtkStyle      *style,
@@ -1262,7 +1289,7 @@ gtk_draw_option (GtkStyle      *style,
  * Draws an option menu tab (i.e. the up and down pointing arrows)
  * in the given rectangle on @window using the given parameters.
  * 
- * Deprecated: Use gtk_paint_tab() instead.
+ * Deprecated: 2.0: Use gtk_paint_tab() instead.
  */ 
 void
 gtk_draw_tab (GtkStyle      *style,
@@ -1298,7 +1325,7 @@ gtk_draw_tab (GtkStyle      *style,
  * using the given style and state and shadow type, leaving a 
  * gap in one side.
  * 
- * Deprecated: Use gtk_paint_shadow_gap() instead.
+ * Deprecated: 2.0: Use gtk_paint_shadow_gap() instead.
 */
 void
 gtk_draw_shadow_gap (GtkStyle       *style,
@@ -1336,7 +1363,7 @@ gtk_draw_shadow_gap (GtkStyle       *style,
  * Draws a box in @window using the given style and state and shadow type, 
  * leaving a gap in one side.
  * 
- * Deprecated: Use gtk_paint_box_gap() instead.
+ * Deprecated: 2.0: Use gtk_paint_box_gap() instead.
  */
 void
 gtk_draw_box_gap (GtkStyle       *style,
@@ -1371,7 +1398,7 @@ gtk_draw_box_gap (GtkStyle       *style,
  * 
  * Draws an extension, i.e. a notebook tab.
  *
- * Deprecated: Use gtk_paint_extension() instead.
+ * Deprecated: 2.0: Use gtk_paint_extension() instead.
  **/
 void
 gtk_draw_extension (GtkStyle       *style,
@@ -1402,7 +1429,7 @@ gtk_draw_extension (GtkStyle       *style,
  * Draws a focus indicator around the given rectangle on @window using the
  * given style.
  * 
- * Deprecated: Use gtk_paint_focus() instead.
+ * Deprecated: 2.0: Use gtk_paint_focus() instead.
  */
 void
 gtk_draw_focus (GtkStyle      *style,
@@ -1418,6 +1445,21 @@ gtk_draw_focus (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_slider:
+ * @style: a #GtkStyle
+  @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: a shadow
+ * @x: the x origin of the rectangle in which to draw a slider
+ * @y: the y origin of the rectangle in which to draw a slider
+ * @width: the width of the rectangle in which to draw a slider
+ * @height: the height of the rectangle in which to draw a slider
+ * @orientation: the orientation to be used
+ *
+ * Draws a slider in the given rectangle on @window using the
+ * given style and orientation.
+ */
 void 
 gtk_draw_slider (GtkStyle      *style,
                 GdkWindow     *window,
@@ -1449,7 +1491,7 @@ gtk_draw_slider (GtkStyle      *style,
  * 
  * Draws a handle as used in #GtkHandleBox and #GtkPaned.
  * 
- * Deprecated: Use gtk_paint_handle() instead.
+ * Deprecated: 2.0: Use gtk_paint_handle() instead.
  **/
 void 
 gtk_draw_handle (GtkStyle      *style,
@@ -1479,7 +1521,7 @@ gtk_draw_handle (GtkStyle      *style,
  * 
  * Draws an expander as used in #GtkTreeView.
  * 
- * Deprecated: Use gtk_paint_expander() instead.
+ * Deprecated: 2.0: Use gtk_paint_expander() instead.
  **/
 void
 gtk_draw_expander (GtkStyle        *style,
@@ -1497,6 +1539,19 @@ gtk_draw_expander (GtkStyle        *style,
                                               x, y, expander_style);
 }
 
+/**
+ * gtk_draw_layout:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @use_text: whether to use the text or foreground
+ *            graphics context of @style
+ * @x: x origin
+ * @y: y origin
+ * @layout: the layout to draw
+ * 
+ * Draws a layout on @window using the given parameters.
+ */
 void
 gtk_draw_layout (GtkStyle        *style,
                  GdkWindow       *window,
@@ -1528,7 +1583,7 @@ gtk_draw_layout (GtkStyle        *style,
  * Draws a resize grip in the given rectangle on @window using the given
  * parameters. 
  * 
- * Deprecated: Use gtk_paint_resize_grip() instead.
+ * Deprecated: 2.0: Use gtk_paint_resize_grip() instead.
  */
 void
 gtk_draw_resize_grip (GtkStyle     *style,
@@ -1581,6 +1636,8 @@ static void
 gtk_style_real_copy (GtkStyle *style,
                     GtkStyle *src)
 {
+  GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
+  GtkStylePrivate *src_priv = GTK_STYLE_GET_PRIVATE (src);
   gint i;
   
   for (i = 0; i < 5; i++)
@@ -1619,6 +1676,16 @@ gtk_style_real_copy (GtkStyle *style,
   if (src->rc_style)
     g_object_ref (src->rc_style);
 
+  g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
+  g_slist_free (style->icon_factories);
+  style->icon_factories = g_slist_copy (src->icon_factories);
+  g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
+
+  g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
+  g_slist_free (priv->color_hashes);
+  priv->color_hashes = g_slist_copy (src_priv->color_hashes);
+  g_slist_foreach (priv->color_hashes, (GFunc) g_hash_table_ref, NULL);
+
   /* don't copy, just clear cache */
   clear_property_cache (style);
 }
@@ -1673,6 +1740,149 @@ style_property_values_cmp (gconstpointer bsearch_node1,
     return val1->widget_type < val2->widget_type ? -1 : 1;
 }
 
+/**
+ * gtk_style_get_style_property:
+ * @style: a #GtkStyle
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @property_name: the name of the style property to get
+ * @value: a #GValue where the value of the property being
+ *     queried will be stored
+ *
+ * Queries the value of a style property corresponding to a
+ * widget class is in the given style.
+ *
+ * Since: 2.16
+ */
+void 
+gtk_style_get_style_property (GtkStyle     *style,
+                              GType        widget_type,
+                              const gchar *property_name,
+                              GValue      *value)
+{
+  GtkWidgetClass *klass;
+  GParamSpec *pspec;
+  GtkRcPropertyParser parser;
+  const GValue *peek_value;
+
+  klass = g_type_class_peek (widget_type);
+  pspec = gtk_widget_class_find_style_property (klass, property_name);
+
+  if (!pspec)
+    {
+      g_warning ("%s: widget class `%s' has no property named `%s'",
+                 G_STRLOC,
+                 g_type_name (widget_type),
+                 property_name);
+      return;
+    }
+
+  parser = g_param_spec_get_qdata (pspec,
+                                   g_quark_from_static_string ("gtk-rc-property-parser"));
+
+  peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
+
+  if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
+    g_value_copy (peek_value, value);
+  else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
+    g_value_transform (peek_value, value);
+  else
+    g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
+               pspec->name,
+               g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+               G_VALUE_TYPE_NAME (value));
+}
+
+/**
+ * gtk_style_get_valist:
+ * @style: a #GtkStyle
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @first_property_name: the name of the first style property to get
+ * @var_args: a <type>va_list</type> of pairs of property names and
+ *     locations to return the property values, starting with the
+ *     location for @first_property_name.
+ *
+ * Non-vararg variant of gtk_style_get().
+ * Used primarily by language bindings.
+ *
+ * Since: 2.16
+ */
+void 
+gtk_style_get_valist (GtkStyle    *style,
+                      GType        widget_type,
+                      const gchar *first_property_name,
+                      va_list      var_args)
+{
+  const char *property_name;
+  GtkWidgetClass *klass;
+
+  g_return_if_fail (GTK_IS_STYLE (style));
+
+  klass = g_type_class_ref (widget_type);
+
+  property_name = first_property_name;
+  while (property_name)
+    {
+      GParamSpec *pspec;
+      GtkRcPropertyParser parser;
+      const GValue *peek_value;
+      gchar *error;
+
+      pspec = gtk_widget_class_find_style_property (klass, property_name);
+
+      if (!pspec)
+        {
+          g_warning ("%s: widget class `%s' has no property named `%s'",
+                     G_STRLOC,
+                     g_type_name (widget_type),
+                     property_name);
+          break;
+        }
+
+      parser = g_param_spec_get_qdata (pspec,
+                                       g_quark_from_static_string ("gtk-rc-property-parser"));
+
+      peek_value = _gtk_style_peek_property_value (style, widget_type, pspec, parser);
+      G_VALUE_LCOPY (peek_value, var_args, 0, &error);
+      if (error)
+        {
+          g_warning ("%s: %s", G_STRLOC, error);
+          g_free (error);
+          break;
+        }
+
+      property_name = va_arg (var_args, gchar*);
+    }
+
+  g_type_class_unref (klass);
+}
+
+/**
+ * gtk_style_get:
+ * @style: a #GtkStyle
+ * @widget_type: the #GType of a descendant of #GtkWidget
+ * @first_property_name: the name of the first style property to get
+ * @Varargs: pairs of property names and locations to
+ *   return the property values, starting with the location for
+ *   @first_property_name, terminated by %NULL.
+ *
+ * Gets the values of a multiple style properties for @widget_type
+ * from @style.
+ *
+ * Since: 2.16
+ */
+void
+gtk_style_get (GtkStyle    *style,
+               GType        widget_type,
+               const gchar *first_property_name,
+               ...)
+{
+  va_list var_args;
+
+  va_start (var_args, first_property_name);
+  gtk_style_get_valist (style, widget_type, first_property_name, var_args);
+  va_end (var_args);
+}
+
 const GValue*
 _gtk_style_peek_property_value (GtkStyle           *style,
                                GType               widget_type,
@@ -1978,15 +2188,15 @@ gtk_style_render_icon (GtkStyle            *style,
 
 /* Default functions */
 void
-gtk_style_apply_default_background (GtkStyle     *style,
-                                    GdkWindow    *window,
-                                    gboolean      set_bg,
-                                    GtkStateType  state_type, 
-                                    GdkRectangle *area, 
-                                    gint          x, 
-                                    gint          y, 
-                                    gint          width, 
-                                    gint          height)
+gtk_style_apply_default_background (GtkStyle          *style,
+                                    GdkWindow         *window,
+                                    gboolean           set_bg,
+                                    GtkStateType        state_type,
+                                    const GdkRectangle *area,
+                                    gint                x,
+                                    gint                y,
+                                    gint                width,
+                                    gint                height)
 {
   GdkRectangle new_rect, old_rect;
   
@@ -2041,10 +2251,10 @@ gtk_style_apply_default_background (GtkStyle     *style,
     }
 }
 
-static GdkPixbuf*
+static GdkPixbuf *
 scale_or_ref (GdkPixbuf *src,
-              gint width,
-              gint height)
+              gint       width,
+              gint       height)
 {
   if (width == gdk_pixbuf_get_width (src) &&
       height == gdk_pixbuf_get_height (src))
@@ -2458,7 +2668,7 @@ gtk_default_draw_shadow (GtkStyle      *style,
   
   if (shadow_type == GTK_SHADOW_IN)
     {
-      if (detail && (strcmp (detail, "buttondefault") == 0))
+      if (detail && strcmp (detail, "buttondefault") == 0)
        {
          sanitize_size (window, &width, &height);
 
@@ -2473,7 +2683,7 @@ gtk_default_draw_shadow (GtkStyle      *style,
                            x, y, width, height);
          return;
        }
-      if (widget && GTK_IS_SPIN_BUTTON (widget) &&
+      if (GTK_IS_SPIN_BUTTON (widget) &&
          detail && strcmp (detail, "spinbutton") == 0)
        {
          draw_spinbutton_shadow (style, window, state_type, 
@@ -2711,7 +2921,7 @@ gtk_default_draw_shadow (GtkStyle      *style,
     }
 
   if (shadow_type == GTK_SHADOW_IN &&
-      widget && GTK_IS_SPIN_BUTTON (widget) &&
+      GTK_IS_SPIN_BUTTON (widget) &&
       detail && strcmp (detail, "entry") == 0)
     {
       if (get_direction (widget) == GTK_TEXT_DIR_LTR)
@@ -3221,7 +3431,7 @@ option_menu_get_props (GtkWidget      *widget,
   GtkRequisition *tmp_size = NULL;
   GtkBorder *tmp_spacing = NULL;
   
-  if (widget)
+  if (GTK_IS_OPTION_MENU (widget))
     gtk_widget_style_get (widget, 
                          "indicator-size", &tmp_size,
                          "indicator-spacing", &tmp_spacing,
@@ -3230,7 +3440,7 @@ option_menu_get_props (GtkWidget      *widget,
   if (tmp_size)
     {
       *indicator_size = *tmp_size;
-      g_free (tmp_size);
+      gtk_requisition_free (tmp_size);
     }
   else
     *indicator_size = default_option_indicator_size;
@@ -3238,7 +3448,7 @@ option_menu_get_props (GtkWidget      *widget,
   if (tmp_spacing)
     {
       *indicator_spacing = *tmp_spacing;
-      g_free (tmp_spacing);
+      gtk_border_free (tmp_spacing);
     }
   else
     *indicator_spacing = default_option_indicator_spacing;
@@ -3261,7 +3471,7 @@ gtk_default_draw_box (GtkStyle      *style,
   
   sanitize_size (window, &width, &height);
 
-  if (widget && GTK_IS_SPIN_BUTTON (widget) && detail)
+  if (GTK_IS_SPIN_BUTTON (widget) && detail)
     {
       if (strcmp (detail, "spinbutton_up") == 0)
        {
@@ -3368,10 +3578,10 @@ gtk_default_draw_box (GtkStyle      *style,
     }
 }
 
-static GdkGC*
-get_darkened_gc (GdkWindow *window,
-                 GdkColor  *color,
-                 gint       darken_count)
+static GdkGC *
+get_darkened_gc (GdkWindow      *window,
+                 const GdkColor *color,
+                 gint            darken_count)
 {
   GdkColor src = *color;
   GdkColor shaded = *color;
@@ -3421,7 +3631,7 @@ gtk_default_draw_flat_box (GtkStyle      *style,
                   !strcmp ("cell_even_ruled_sorted", detail))
             {
              /* This has to be really broken; alex made me do it. -jrb */
-             if (GTK_WIDGET_HAS_FOCUS (widget))
+             if (widget && GTK_WIDGET_HAS_FOCUS (widget))
                gc1 = style->base_gc[state_type];
              else
                gc1 = style->base_gc[GTK_STATE_ACTIVE];
@@ -3429,7 +3639,7 @@ gtk_default_draw_flat_box (GtkStyle      *style,
          else if (!strcmp ("cell_odd_ruled", detail) ||
                   !strcmp ("cell_odd_ruled_sorted", detail))
            {
-             if (GTK_WIDGET_HAS_FOCUS (widget))
+             if (widget && GTK_WIDGET_HAS_FOCUS (widget))
                freeme = get_darkened_gc (window, &style->base[state_type], 1);
              else
                freeme = get_darkened_gc (window, &style->base[GTK_STATE_ACTIVE], 1);
@@ -3474,7 +3684,7 @@ gtk_default_draw_flat_box (GtkStyle      *style,
             }
          else if (!strcmp ("cell_odd_ruled", detail))
            {
-             GdkColor *color;
+             GdkColor *color = NULL;
 
              gtk_widget_style_get (widget,
                                    "odd-row-color", &color,
@@ -3630,7 +3840,7 @@ gtk_default_draw_check (GtkStyle      *style,
   
   exterior_size = MIN (width, height);
   if (exterior_size % 2 == 0) /* Ensure odd */
-    exterior_size -= -1;
+    exterior_size -= 1;
 
   pad = style->xthickness + MAX (1, (exterior_size - 2 * style->xthickness) / 9);
   interior_size = MAX (1, exterior_size - 2 * pad);
@@ -3753,7 +3963,7 @@ gtk_default_draw_option (GtkStyle      *style,
   
   exterior_size = MIN (width, height);
   if (exterior_size % 2 == 0) /* Ensure odd */
-    exterior_size -= -1;
+    exterior_size -= 1;
   
   x -= (1 + exterior_size - width) / 2;
   y -= (1 + exterior_size - height) / 2;
@@ -4506,7 +4716,7 @@ gtk_default_draw_focus (GtkStyle      *style,
   cairo_t *cr;
   gboolean free_dash_list = FALSE;
   gint line_width = 1;
-  gint8 *dash_list = "\1\1";
+  gint8 *dash_list = (gint8 *) "\1\1";
 
   if (widget)
     {
@@ -4522,15 +4732,15 @@ gtk_default_draw_focus (GtkStyle      *style,
     {
       if (free_dash_list)
        g_free (dash_list);
-      
-      dash_list = "\4\4";
+
+      dash_list = (gint8 *) "\4\4";
       free_dash_list = FALSE;
     }
 
   sanitize_size (window, &width, &height);
 
   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"))
@@ -4542,7 +4752,7 @@ gtk_default_draw_focus (GtkStyle      *style,
 
   if (dash_list[0])
     {
-      gint n_dashes = strlen (dash_list);
+      gint n_dashes = strlen ((const gchar *) dash_list);
       gdouble *dashes = g_new (gdouble, n_dashes);
       gdouble total_length = 0;
       gdouble dash_offset;
@@ -4924,7 +5134,7 @@ get_insensitive_layout (GdkDrawable *drawable,
       gboolean need_stipple = FALSE;
       ByteRange *br;
       
-      run = pango_layout_iter_get_run (iter);
+      run = pango_layout_iter_get_run_readonly (iter);
 
       if (run)
         {
@@ -5389,9 +5599,9 @@ gtk_default_draw_resize_grip (GtkStyle       *style,
 }
 
 void
-_gtk_style_shade (GdkColor *a,
-                  GdkColor *b,
-                  gdouble   k)
+_gtk_style_shade (const GdkColor *a,
+                  GdkColor       *b,
+                  gdouble         k)
 {
   gdouble red;
   gdouble green;
@@ -5590,21 +5800,23 @@ hls_to_rgb (gdouble *h,
  * using the given style and state.
  **/ 
 void 
-gtk_paint_hline (GtkStyle      *style,
-                 GdkWindow     *window,
-                 GtkStateType   state_type,
-                 GdkRectangle  *area,
-                 GtkWidget     *widget,
-                 const gchar   *detail,
-                 gint          x1,
-                 gint          x2,
-                 gint          y)
+gtk_paint_hline (GtkStyle           *style,
+                 GdkWindow          *window,
+                 GtkStateType        state_type,
+                 const GdkRectangle *area,
+                 GtkWidget          *widget,
+                 const gchar        *detail,
+                 gint                x1,
+                 gint                x2,
+                 gint                y)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
+
+  GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type,
+                                           (GdkRectangle *) area, widget, detail,
+                                           x1, x2, y);
 }
 
 /**
@@ -5624,21 +5836,23 @@ gtk_paint_hline (GtkStyle      *style,
  * using the given style and state.
  */
 void
-gtk_paint_vline (GtkStyle      *style,
-                 GdkWindow     *window,
-                 GtkStateType   state_type,
-                 GdkRectangle  *area,
-                 GtkWidget     *widget,
-                 const gchar   *detail,
-                 gint          y1_,
-                 gint          y2_,
-                 gint          x)
+gtk_paint_vline (GtkStyle           *style,
+                 GdkWindow          *window,
+                 GtkStateType        state_type,
+                 const GdkRectangle *area,
+                 GtkWidget          *widget,
+                 const gchar        *detail,
+                 gint                y1_,
+                 gint                y2_,
+                 gint                x)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1_, y2_, x);
+
+  GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type,
+                                           (GdkRectangle *) area, widget, detail,
+                                           y1_, y2_, x);
 }
 
 /**
@@ -5660,23 +5874,25 @@ gtk_paint_vline (GtkStyle      *style,
  * using the given style and state and shadow type.
  */
 void
-gtk_paint_shadow (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)
+gtk_paint_shadow (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  GtkShadowType       shadow_type,
+                  const GdkRectangle *area,
+                  GtkWidget          *widget,
+                  const gchar        *detail,
+                  gint                x,
+                  gint                y,
+                  gint                width,
+                  gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, width, height);
 }
 
 /**
@@ -5690,28 +5906,30 @@ gtk_paint_shadow (GtkStyle     *style,
  * @widget: the widget (may be %NULL)
  * @detail: a style detail (may be %NULL)
  * @points: an array of #GdkPoint<!-- -->s
- * @npoints: length of @points
+ * @n_points: length of @points
  * @fill: %TRUE if the polygon should be filled
  * 
  * Draws a polygon on @window with the given parameters.
  */ 
 void
-gtk_paint_polygon (GtkStyle      *style,
-                   GdkWindow     *window,
-                   GtkStateType   state_type,
-                   GtkShadowType  shadow_type,
-                   GdkRectangle  *area,
-                   GtkWidget     *widget,
-                   const gchar   *detail,
-                   GdkPoint      *points,
-                   gint           npoints,
-                   gboolean       fill)
+gtk_paint_polygon (GtkStyle           *style,
+                   GdkWindow          *window,
+                   GtkStateType        state_type,
+                   GtkShadowType       shadow_type,
+                   const GdkRectangle *area,
+                   GtkWidget          *widget,
+                   const gchar        *detail,
+                   const GdkPoint     *points,
+                   gint                n_points,
+                   gboolean            fill)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                             (GdkRectangle *) area, widget, detail,
+                                             (GdkPoint *) points, n_points, fill);
 }
 
 /**
@@ -5735,25 +5953,27 @@ gtk_paint_polygon (GtkStyle      *style,
  * parameters. @arrow_type determines the direction of the arrow.
  */
 void
-gtk_paint_arrow (GtkStyle      *style,
-                 GdkWindow     *window,
-                 GtkStateType   state_type,
-                 GtkShadowType  shadow_type,
-                 GdkRectangle  *area,
-                 GtkWidget     *widget,
-                 const gchar   *detail,
-                 GtkArrowType   arrow_type,
-                 gboolean       fill,
-                 gint           x,
-                 gint           y,
-                 gint           width,
-                 gint           height)
+gtk_paint_arrow (GtkStyle           *style,
+                 GdkWindow          *window,
+                 GtkStateType        state_type,
+                 GtkShadowType       shadow_type,
+                 const GdkRectangle *area,
+                 GtkWidget          *widget,
+                 const gchar        *detail,
+                 GtkArrowType        arrow_type,
+                 gboolean            fill,
+                 gint                x,
+                 gint                y,
+                 gint                width,
+                 gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                           (GdkRectangle *) area, widget, detail,
+                                           arrow_type, fill, x, y, width, height);
 }
 
 /**
@@ -5775,23 +5995,25 @@ gtk_paint_arrow (GtkStyle      *style,
  * parameters.
  */
 void
-gtk_paint_diamond (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)
+gtk_paint_diamond (GtkStyle           *style,
+                   GdkWindow          *window,
+                   GtkStateType        state_type,
+                   GtkShadowType       shadow_type,
+                   const GdkRectangle *area,
+                   GtkWidget          *widget,
+                   const gchar        *detail,
+                   gint                x,
+                   gint                y,
+                   gint                width,
+                   gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_diamond (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,
+                                             (GdkRectangle *) area, widget, detail,
+                                             x, y, width, height);
 }
 
 /**
@@ -5809,24 +6031,26 @@ gtk_paint_diamond (GtkStyle      *style,
  * 
  * Draws a text string on @window with the given parameters.
  *
- * Deprecated: Use gtk_paint_layout() instead.
+ * Deprecated: 2.0: Use gtk_paint_layout() instead.
  */
 void
-gtk_paint_string (GtkStyle      *style,
-                  GdkWindow     *window,
-                  GtkStateType   state_type,
-                  GdkRectangle  *area,
-                  GtkWidget     *widget,
-                  const gchar   *detail,
-                  gint           x,
-                  gint           y,
-                  const gchar   *string)
+gtk_paint_string (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  const GdkRectangle *area,
+                  GtkWidget          *widget,
+                  const gchar        *detail,
+                  gint                x,
+                  gint                y,
+                  const gchar        *string)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
+
+  GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, string);
 }
 
 /**
@@ -5847,23 +6071,25 @@ gtk_paint_string (GtkStyle      *style,
  * Draws a box on @window with the given parameters.
  */
 void
-gtk_paint_box (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)
+gtk_paint_box (GtkStyle           *style,
+               GdkWindow          *window,
+               GtkStateType        state_type,
+               GtkShadowType       shadow_type,
+               const GdkRectangle *area,
+               GtkWidget          *widget,
+               const gchar        *detail,
+               gint                x,
+               gint                y,
+               gint                width,
+               gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                         (GdkRectangle *) area, widget, detail,
+                                         x, y, width, height);
 }
 
 /**
@@ -5884,23 +6110,25 @@ gtk_paint_box (GtkStyle      *style,
  * Draws a flat box on @window with the given parameters.
  */
 void
-gtk_paint_flat_box (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)
+gtk_paint_flat_box (GtkStyle           *style,
+                    GdkWindow          *window,
+                    GtkStateType        state_type,
+                    GtkShadowType       shadow_type,
+                    const GdkRectangle *area,
+                    GtkWidget          *widget,
+                    const gchar        *detail,
+                    gint                x,
+                    gint                y,
+                    gint                width,
+                    gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                              (GdkRectangle *) area, widget, detail,
+                                              x, y, width, height);
 }
 
 /**
@@ -5922,23 +6150,25 @@ gtk_paint_flat_box (GtkStyle      *style,
  * the given parameters.
  */
 void
-gtk_paint_check (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)
+gtk_paint_check (GtkStyle           *style,
+                 GdkWindow          *window,
+                 GtkStateType        state_type,
+                 GtkShadowType       shadow_type,
+                 const GdkRectangle *area,
+                 GtkWidget          *widget,
+                 const gchar        *detail,
+                 gint                x,
+                 gint                y,
+                 gint                width,
+                 gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                           (GdkRectangle *) area, widget, detail,
+                                           x, y, width, height);
 }
 
 /**
@@ -5960,23 +6190,25 @@ gtk_paint_check (GtkStyle      *style,
  * the given parameters.
  */
 void
-gtk_paint_option (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)
+gtk_paint_option (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  GtkShadowType       shadow_type,
+                  const GdkRectangle *area,
+                  GtkWidget          *widget,
+                  const gchar        *detail,
+                  gint                x,
+                  gint                y,
+                  gint                width,
+                  gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+
+  GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, width, height);
 }
 
 /**
@@ -5998,23 +6230,25 @@ gtk_paint_option (GtkStyle      *style,
  * in the given rectangle on @window using the given parameters.
  */ 
 void
-gtk_paint_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)
+gtk_paint_tab (GtkStyle           *style,
+               GdkWindow          *window,
+               GtkStateType        state_type,
+               GtkShadowType       shadow_type,
+               const GdkRectangle *area,
+               GtkWidget          *widget,
+               const gchar        *detail,
+               gint                x,
+               gint                y,
+               gint                width,
+               gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                         (GdkRectangle *) area, widget, detail,
+                                         x, y, width, height);
 }
 
 /**
@@ -6040,26 +6274,28 @@ gtk_paint_tab (GtkStyle      *style,
  * gap in one side.
 */
 void
-gtk_paint_shadow_gap (GtkStyle       *style,
-                      GdkWindow      *window,
-                      GtkStateType    state_type,
-                      GtkShadowType   shadow_type,
-                      GdkRectangle   *area,
-                      GtkWidget      *widget,
-                      gchar          *detail,
-                      gint            x,
-                      gint            y,
-                      gint            width,
-                      gint            height,
-                      GtkPositionType gap_side,
-                      gint            gap_x,
-                      gint            gap_width)
+gtk_paint_shadow_gap (GtkStyle           *style,
+                      GdkWindow          *window,
+                      GtkStateType        state_type,
+                      GtkShadowType       shadow_type,
+                      const GdkRectangle *area,
+                      GtkWidget          *widget,
+                      const gchar        *detail,
+                      gint                x,
+                      gint                y,
+                      gint                width,
+                      gint                height,
+                      GtkPositionType     gap_side,
+                      gint                gap_x,
+                      gint                gap_width)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  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);
+
+  GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type,
+                                                (GdkRectangle *) area, widget, detail,
+                                                x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 
@@ -6085,26 +6321,28 @@ gtk_paint_shadow_gap (GtkStyle       *style,
  * leaving a gap in one side.
  */
 void
-gtk_paint_box_gap (GtkStyle       *style,
-                   GdkWindow      *window,
-                   GtkStateType    state_type,
-                   GtkShadowType   shadow_type,
-                   GdkRectangle   *area,
-                   GtkWidget      *widget,
-                   gchar          *detail,
-                   gint            x,
-                   gint            y,
-                   gint            width,
-                   gint            height,
-                   GtkPositionType gap_side,
-                   gint            gap_x,
-                   gint            gap_width)
+gtk_paint_box_gap (GtkStyle           *style,
+                   GdkWindow          *window,
+                   GtkStateType        state_type,
+                   GtkShadowType       shadow_type,
+                   const GdkRectangle *area,
+                   GtkWidget          *widget,
+                   const gchar        *detail,
+                   gint                x,
+                   gint                y,
+                   gint                width,
+                   gint                height,
+                   GtkPositionType     gap_side,
+                   gint                gap_x,
+                   gint                gap_width)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  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);
+
+  GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type,
+                                             (GdkRectangle *) area, widget, detail,
+                                             x, y, width, height, gap_side, gap_x, gap_width);
 }
 
 /**
@@ -6126,24 +6364,26 @@ gtk_paint_box_gap (GtkStyle       *style,
  * Draws an extension, i.e. a notebook tab.
  **/
 void
-gtk_paint_extension (GtkStyle       *style,
-                     GdkWindow      *window,
-                     GtkStateType    state_type,
-                     GtkShadowType   shadow_type,
-                     GdkRectangle   *area,
-                     GtkWidget      *widget,
-                     gchar          *detail,
-                     gint            x,
-                     gint            y,
-                     gint            width,
-                     gint            height,
-                     GtkPositionType gap_side)
+gtk_paint_extension (GtkStyle           *style,
+                     GdkWindow          *window,
+                     GtkStateType        state_type,
+                     GtkShadowType       shadow_type,
+                     const GdkRectangle *area,
+                     GtkWidget          *widget,
+                     const gchar        *detail,
+                     gint                x,
+                     gint                y,
+                     gint                width,
+                     gint                height,
+                     GtkPositionType     gap_side)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                               (GdkRectangle *) area, widget, detail,
+                                               x, y, width, height, gap_side);
 }
 
 /**
@@ -6164,22 +6404,24 @@ gtk_paint_extension (GtkStyle       *style,
  * given style.
  */
 void
-gtk_paint_focus (GtkStyle      *style,
-                 GdkWindow     *window,
-                GtkStateType   state_type,
-                 GdkRectangle  *area,
-                 GtkWidget     *widget,
-                 const gchar   *detail,
-                 gint           x,
-                 gint           y,
-                 gint           width,
-                 gint           height)
+gtk_paint_focus (GtkStyle           *style,
+                 GdkWindow          *window,
+                GtkStateType        state_type,
+                 const GdkRectangle *area,
+                 GtkWidget          *widget,
+                 const gchar        *detail,
+                 gint                x,
+                 gint                y,
+                 gint                width,
+                 gint                height)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
+
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type,
+                                           (GdkRectangle *) area, widget, detail,
+                                           x, y, width, height);
 }
 
 /**
@@ -6202,24 +6444,26 @@ gtk_paint_focus (GtkStyle      *style,
  * given style and orientation.
  **/
 void
-gtk_paint_slider (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,
-                  GtkOrientation orientation)
+gtk_paint_slider (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  GtkShadowType       shadow_type,
+                  const GdkRectangle *area,
+                  GtkWidget          *widget,
+                  const gchar        *detail,
+                  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);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->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,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, width, height, orientation);
 }
 
 /**
@@ -6241,24 +6485,26 @@ gtk_paint_slider (GtkStyle      *style,
  * Draws a handle as used in #GtkHandleBox and #GtkPaned.
  **/
 void
-gtk_paint_handle (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,
-                  GtkOrientation orientation)
+gtk_paint_handle (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  GtkShadowType       shadow_type,
+                  const GdkRectangle *area,
+                  GtkWidget          *widget,
+                  const gchar        *detail,
+                  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);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+
+  GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, width, height, orientation);
 }
 
 /**
@@ -6287,22 +6533,23 @@ gtk_paint_handle (GtkStyle      *style,
  * expanded position.
  **/
 void
-gtk_paint_expander (GtkStyle        *style,
-                    GdkWindow       *window,
-                    GtkStateType     state_type,
-                    GdkRectangle    *area,
-                    GtkWidget       *widget,
-                    const gchar     *detail,
-                    gint             x,
-                    gint             y,
-                   GtkExpanderStyle expander_style)
+gtk_paint_expander (GtkStyle           *style,
+                    GdkWindow          *window,
+                    GtkStateType        state_type,
+                    const GdkRectangle *area,
+                    GtkWidget          *widget,
+                    const gchar        *detail,
+                    gint                x,
+                    gint                y,
+                   GtkExpanderStyle    expander_style)
 {
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
-                                              widget, detail, x, y, expander_style);
+
+  GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
+                                              (GdkRectangle *) area, widget, detail,
+                                              x, y, expander_style);
 }
 
 /**
@@ -6323,23 +6570,24 @@ gtk_paint_expander (GtkStyle        *style,
  * Draws a layout on @window using the given parameters.
  **/
 void
-gtk_paint_layout (GtkStyle        *style,
-                  GdkWindow       *window,
-                  GtkStateType     state_type,
-                  gboolean         use_text,
-                  GdkRectangle    *area,
-                  GtkWidget       *widget,
-                  const gchar     *detail,
-                  gint             x,
-                  gint             y,
-                  PangoLayout     *layout)
+gtk_paint_layout (GtkStyle           *style,
+                  GdkWindow          *window,
+                  GtkStateType        state_type,
+                  gboolean            use_text,
+                  const 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);
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
-  
-  GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
-                                            widget, detail, x, y, layout);
+
+  GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
+                                            (GdkRectangle *) area, widget, detail,
+                                            x, y, layout);
 }
 
 /**
@@ -6361,17 +6609,17 @@ gtk_paint_layout (GtkStyle        *style,
  * parameters. 
  */
 void
-gtk_paint_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)
+gtk_paint_resize_grip (GtkStyle           *style,
+                       GdkWindow          *window,
+                       GtkStateType        state_type,
+                       const GdkRectangle *area,
+                       GtkWidget          *widget,
+                       const gchar        *detail,
+                       GdkWindowEdge       edge,
+                       gint                x,
+                       gint                y,
+                       gint                width,
+                       gint                height)
 
 {
   g_return_if_fail (GTK_IS_STYLE (style));
@@ -6379,10 +6627,26 @@ gtk_paint_resize_grip (GtkStyle      *style,
   g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
 
   GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
-                                                 area, widget, detail,
+                                                 (GdkRectangle *) area, widget, detail,
                                                  edge, x, y, width, height);
 }
 
+/**
+ * gtk_border_new:
+ *
+ * Allocates a new #GtkBorder structure and initializes its elements to zero.
+ * 
+ * Returns: a new empty #GtkBorder. The newly allocated #GtkBorder should be 
+ *     freed with gtk_border_free()
+ *
+ * Since: 2.14
+ **/
+GtkBorder *
+gtk_border_new (void)
+{
+  return g_slice_new0 (GtkBorder);
+}
+
 /**
  * gtk_border_copy:
  * @border_: a #GtkBorder.
@@ -6393,7 +6657,9 @@ gtk_paint_resize_grip (GtkStyle      *style,
 GtkBorder *
 gtk_border_copy (const GtkBorder *border)
 {
-  return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
+  g_return_val_if_fail (border != NULL, NULL);
+
+  return g_slice_dup (GtkBorder, border);
 }
 
 /**
@@ -6405,7 +6671,7 @@ gtk_border_copy (const GtkBorder *border)
 void
 gtk_border_free (GtkBorder *border)
 {
-  g_free (border);
+  g_slice_free (GtkBorder, border);
 }
 
 GType
@@ -6558,8 +6824,8 @@ style_unrealize_cursor_gcs (GtkStyle *style)
 }
 
 static GdkGC *
-make_cursor_gc (GtkWidget   *widget,
-               const gchar *property_name,
+make_cursor_gc (GtkWidget      *widget,
+               const gchar    *property_name,
                const GdkColor *fallback)
 {
   GdkGCValues gc_values;
@@ -6618,35 +6884,65 @@ get_insertion_cursor_gc (GtkWidget *widget,
        }
     }
 
+  /* Cursors in text widgets are drawn only in NORMAL state,
+   * so we can use text[GTK_STATE_NORMAL] as text color here */
   if (is_primary)
     {
       if (!cursor_info->primary_gc)
        cursor_info->primary_gc = make_cursor_gc (widget,
                                                  "cursor-color",
-                                                 &widget->style->black);
-       
+                                                 &widget->style->text[GTK_STATE_NORMAL]);
+
       return cursor_info->primary_gc;
     }
   else
     {
-      static const GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 };
-      
       if (!cursor_info->secondary_gc)
        cursor_info->secondary_gc = make_cursor_gc (widget,
                                                    "secondary-cursor-color",
-                                                   &gray);
-       
+                                                   /* text_aa is the average of text and base colors,
+                                                    * in usual black-on-white case it's grey. */
+                                                   &widget->style->text_aa[GTK_STATE_NORMAL]);
+
       return cursor_info->secondary_gc;
     }
 }
 
+GdkGC *
+_gtk_widget_get_cursor_gc (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL);
+  return get_insertion_cursor_gc (widget, TRUE);
+}
+
+void
+_gtk_widget_get_cursor_color (GtkWidget *widget,
+                             GdkColor  *color)
+{
+  GdkColor *style_color;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (color != NULL);
+
+  gtk_widget_style_get (widget, "cursor-color", &style_color, NULL);
+
+  if (style_color)
+    {
+      *color = *style_color;
+      gdk_color_free (style_color);
+    }
+  else
+    *color = widget->style->text[GTK_STATE_NORMAL];
+}
+
 static void
-draw_insertion_cursor (GtkWidget        *widget,
-                      GdkDrawable      *drawable,
-                      GdkGC            *gc,
-                      GdkRectangle     *location,
-                      GtkTextDirection  direction,
-                      gboolean          draw_arrow)
+draw_insertion_cursor (GtkWidget          *widget,
+                      GdkDrawable        *drawable,
+                      GdkGC              *gc,
+                      const GdkRectangle *location,
+                      GtkTextDirection    direction,
+                      gboolean            draw_arrow)
 {
   gint stem_width;
   gint arrow_width;
@@ -6725,13 +7021,13 @@ draw_insertion_cursor (GtkWidget        *widget,
  * Since: 2.4
  **/
 void
-gtk_draw_insertion_cursor (GtkWidget        *widget,
-                          GdkDrawable      *drawable,
-                          GdkRectangle     *area,
-                          GdkRectangle     *location,
-                          gboolean          is_primary,
-                          GtkTextDirection  direction,
-                          gboolean          draw_arrow)
+gtk_draw_insertion_cursor (GtkWidget          *widget,
+                          GdkDrawable        *drawable,
+                          const GdkRectangle *area,
+                          const GdkRectangle *location,
+                          gboolean            is_primary,
+                          GtkTextDirection    direction,
+                          gboolean            draw_arrow)
 {
   GdkGC *gc;