]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkstyle.c
Sanity check default font family name and size.
[~andy/gtk] / gtk / gtkstyle.c
index acda09a80a20091a5055c5b162e6e7ae6158ee8f..eca446b3d038e7b15ad094d2a414bc8a61ebd8ad 100644 (file)
@@ -239,6 +239,7 @@ static void gtk_default_draw_extension  (GtkStyle        *style,
                                         GtkPositionType  gap_side);
 static void gtk_default_draw_focus      (GtkStyle        *style,
                                         GdkWindow       *window,
+                                        GtkStateType     state_type,
                                         GdkRectangle    *area,
                                         GtkWidget       *widget,
                                         const gchar     *detail,
@@ -329,53 +330,86 @@ typedef enum {
   CHECK_LIGHT,
   CHECK_MID,
   CHECK_TEXT,
+  CHECK_INCONSISTENT_AA,
+  CHECK_INCONSISTENT_TEXT,
   RADIO_BASE,
   RADIO_BLACK,
   RADIO_DARK,
   RADIO_LIGHT,
   RADIO_MID,
-  RADIO_TEXT
+  RADIO_TEXT,
+  RADIO_INCONSISTENT_AA,
+  RADIO_INCONSISTENT_TEXT
 } IndicatorPart;
 
-static char check_aa_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
- 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static char check_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00};
+/*
+ * Extracted from check-13.png, width=13, height=13
+ */
 static char check_black_bits[] = {
- 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};
 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00};
 static char check_dark_bits[] = {
- 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};
-static char check_light_bits[] = {
- 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f};
+  0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+  0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00};
 static char check_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
- 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00};
+  0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+  0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00,0x00,0x00};
+static char check_light_bits[] = {
+  0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
+  0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f,0x00,0x00};
 static char check_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0xd8,
- 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-static char radio_base_bits[] = {
- 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
- 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00};
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0x58,
+  0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_aa_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
+  0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_base_bits[] = {
+  0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
+  0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0x00};
+
+/*
+ * Extracted from check-13-inconsistent-ssp.png, width=13, height=13
+ */
+static char check_inconsistent_text_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0xf8,
+  0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char check_inconsistent_aa_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+/*
+ * Extracted from radio-13-ssp.png, width=13, height=13
+ */
 static char radio_black_bits[] = {
0x00,0x00,0xf0,0x01,0x08,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
 0x00,0x00,0xf0,0x01,0x0c,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
 static char radio_dark_bits[] = {
- 0xf0,0x01,0x08,0x02,0x04,0x04,0x02,0x04,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
- 0x00,0x01,0x00,0x02,0x00,0x0c,0x00,0x00,0x00,0x00,0x00};
-static char radio_light_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
- 0x10,0x00,0x10,0x00,0x08,0x00,0x04,0x08,0x02,0xf0,0x01};
+  0xf0,0x00,0x0c,0x02,0x02,0x04,0x02,0x04,0x01,0x08,0x01,0x08,0x01,0x08,0x01,
+  0x08,0x00,0x04,0x02,0x04,0x0c,0x03,0xf0,0x00,0x00,0x00,0x00,0x00};
 static char radio_mid_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
- 0x08,0x00,0x08,0x00,0x04,0x00,0x02,0xf0,0x01,0x00,0x00};
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_light_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
+  0x10,0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x03,0xf0,0x00,0x00,0x00};
 static char radio_text_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
- 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
+  0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_aa_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_base_bits[] = {
+  0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
+  0x07,0xfc,0x03,0xf8,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+/*
+ * Extracted from radio-13-inconsistent-ssp.png, width=13, height=13
+ */
+static char radio_inconsistent_text_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+static char radio_inconsistent_aa_bits[] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x03,0x00,0x00,0xf8,
+  0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
 
 static struct {
   char      *bits;
@@ -388,12 +422,16 @@ static struct {
   { check_light_bits, NULL },
   { check_mid_bits, NULL },
   { check_text_bits, NULL },
+  { check_inconsistent_aa_bits, NULL },
+  { check_inconsistent_text_bits, NULL },
   { radio_base_bits, NULL },
   { radio_black_bits, NULL },
   { radio_dark_bits, NULL },
   { radio_light_bits, NULL },
   { radio_mid_bits, NULL },
-  { radio_text_bits, NULL }
+  { radio_text_bits, NULL },
+  { radio_inconsistent_aa_bits, NULL },
+  { radio_inconsistent_text_bits, NULL },
 };
 
 /* --- variables --- */
@@ -447,9 +485,21 @@ static void
 gtk_style_init (GtkStyle *style)
 {
   gint i;
-  
-  style->font_desc = pango_font_description_from_string ("Sans 10");
+  const gchar *font_name = _gtk_rc_context_get_default_font_name (gtk_settings_get_default ());
+
+  style->font_desc = pango_font_description_from_string (font_name);
 
+  if (!pango_font_description_get_family (style->font_desc))
+    {
+      g_warning ("Default font does not have a family set");
+      pango_font_description_set_family (style->font_desc, "Sans");
+    }
+  if (pango_font_description_get_size (style->font_desc) <= 0)
+    {
+      g_warning ("Default font does not have a positive size");
+      pango_font_description_set_size (style->font_desc, 10 * PANGO_SCALE);
+    }
+  
   style->attach_count = 0;
   style->colormap = NULL;
   style->depth = -1;
@@ -641,6 +691,12 @@ gtk_style_duplicate (GtkStyle *style)
   return new_style;
 }
 
+/**
+ * gtk_style_new:
+ * @returns: a new #GtkStyle.
+ *
+ * Creates a new #GtkStyle.
+ **/
 GtkStyle*
 gtk_style_new (void)
 {
@@ -651,23 +707,22 @@ gtk_style_new (void)
   return style;
 }
 
-/*************************************************************
+/**
  * gtk_style_attach:
- *     Attach a style to a window; this process allocates the
- *     colors and creates the GC's for the style - it specializes
- *     it to a particular visual and colormap. The process
- *     may involve the creation of a new style if the style
- *     has already been attached to a window with a different
- *     style and colormap.
- *   arguments:
- *     style:
- *     window: 
- *   results:
- *     Either the style parameter, or a newly created style.
- *     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.
+ * @style: a #GtkStyle.
+ * @window: a #GtkWindow.
+ * @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
+ * it to a particular visual and colormap. The process may 
+ * involve the creation of a new style if the style has already 
+ * been attached to a window with a different style and colormap.
+ **/
+ /*
  * FIXME: The sequence - 
  *    create a style => s1
  *    attach s1 to v1, c1 => s1
@@ -682,8 +737,7 @@ gtk_style_new (void)
  * passes through the linked list when attaching (one to check for 
  * matching styles, one to look for empty unattached styles - but 
  * it will almost never be longer than 2 elements.
- *************************************************************/
-
+ */
 GtkStyle*
 gtk_style_attach (GtkStyle  *style,
                   GdkWindow *window)
@@ -756,12 +810,25 @@ gtk_style_detach (GtkStyle *style)
     }
 }
 
+/**
+ * gtk_style_ref:
+ * @style: a #GtkStyle.
+ * @returns: @style.
+ *
+ * Deprecated equivalent of g_object_ref().
+ **/
 GtkStyle*
 gtk_style_ref (GtkStyle *style)
 {
   return (GtkStyle *) g_object_ref (G_OBJECT (style));
 }
 
+/**
+ * gtk_style_unref:
+ * @style: a #GtkStyle.
+ *
+ * Deprecated equivalent of g_object_unref().
+ **/
 void
 gtk_style_unref (GtkStyle *style)
 {
@@ -804,6 +871,20 @@ gtk_style_lookup_icon_set (GtkStyle   *style,
   return gtk_icon_factory_lookup_default (stock_id);
 }
 
+/**
+ * gtk_draw_hline:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @x1: the starting x coordinate
+ * @x2: the ending x coordinate
+ * @y: the y coordinate
+ * 
+ * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
+ * using the given style and state.
+ * 
+ * This function is deprecated, use gtk_paint_hline() instead.
+ **/
 void
 gtk_draw_hline (GtkStyle     *style,
                 GdkWindow    *window,
@@ -819,6 +900,20 @@ gtk_draw_hline (GtkStyle     *style,
 }
 
 
+/**
+ * gtk_draw_vline:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @y1: the starting y coordinate
+ * @y2: the ending y coordinate
+ * @x: the x coordinate
+ * 
+ * Draws a vertical line from (@x, @y1) to (@x, @y2) in @window
+ * using the given style and state.
+ * 
+ * This function is deprecated, use gtk_paint_vline() instead.
+ **/
 void
 gtk_draw_vline (GtkStyle     *style,
                 GdkWindow    *window,
@@ -833,7 +928,22 @@ gtk_draw_vline (GtkStyle     *style,
   GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
 }
 
-
+/**
+ * gtk_draw_shadow:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: type of shadow to draw
+ * @x: x origin of the rectangle
+ * @y: y origin of the rectangle
+ * @width: width of the rectangle 
+ * @height: width of the rectangle 
+ *
+ * Draws a shadow around the given rectangle in @window 
+ * using the given style and state and shadow type.
+ * 
+ * This function is deprecated, use gtk_paint_shadow() instead.
+ */
 void
 gtk_draw_shadow (GtkStyle      *style,
                  GdkWindow     *window,
@@ -850,6 +960,20 @@ gtk_draw_shadow (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_polygon:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: type of shadow to draw
+ * @points: an array of #GdkPoint<!>s
+ * @npoints: length of @points
+ * @fill: %TRUE if the polygon should be filled
+ * 
+ * Draws a polygon on @window with the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_polygon() instead.
+ */ 
 void
 gtk_draw_polygon (GtkStyle      *style,
                   GdkWindow     *window,
@@ -865,6 +989,24 @@ gtk_draw_polygon (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
 }
 
+/**
+ * gtk_draw_arrow:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @arrow_type: the type of arrow to draw
+ * @fill: %TRUE if the arrow tip should be filled
+ * @x: x origin of the rectangle to draw the arrow in
+ * @y: y origin of the rectangle to draw the arrow in
+ * @width: width of the rectangle to draw the arrow in
+ * @height: height of the rectangle to draw the arrow in
+ * 
+ * Draws an arrow in the given rectangle on @window using the given 
+ * parameters. @arrow_type determines the direction of the arrow.
+ *
+ * This function is deprecated, use gtk_paint_arrow() instead.
+ */
 void
 gtk_draw_arrow (GtkStyle      *style,
                 GdkWindow     *window,
@@ -883,7 +1025,21 @@ gtk_draw_arrow (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
 }
 
-
+/**
+ * gtk_draw_diamond:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the rectangle to draw the diamond in
+ * @y: y origin of the rectangle to draw the diamond in
+ * @width: width of the rectangle to draw the diamond in
+ * @height: height of the rectangle to draw the diamond in
+ *
+ * Draws a diamond in the given rectangle on @window using the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_diamond() instead.
+ */
 void
 gtk_draw_diamond (GtkStyle      *style,
                   GdkWindow     *window,
@@ -900,7 +1056,19 @@ gtk_draw_diamond (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
-
+/**
+ * gtk_draw_string:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @x: x origin
+ * @y: y origin
+ * @string: the string to draw
+ * 
+ * Draws a text string on @window with the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_layout() instead.
+ */
 void
 gtk_draw_string (GtkStyle      *style,
                  GdkWindow     *window,
@@ -915,6 +1083,21 @@ gtk_draw_string (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
 }
 
+/**
+ * gtk_draw_box:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the box
+ * @y: y origin of the box
+ * @width: the width of the box
+ * @height: the height of the box
+ * 
+ * Draws a box on @window with the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_box() instead.
+ */
 void
 gtk_draw_box (GtkStyle      *style,
               GdkWindow     *window,
@@ -931,6 +1114,21 @@ gtk_draw_box (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_flat_box:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the box
+ * @y: y origin of the box
+ * @width: the width of the box
+ * @height: the height of the box
+ * 
+ * Draws a flat box on @window with the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_flat_box() instead.
+ */
 void
 gtk_draw_flat_box (GtkStyle      *style,
                    GdkWindow     *window,
@@ -947,6 +1145,22 @@ gtk_draw_flat_box (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_check:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the rectangle to draw the check in
+ * @y: y origin of the rectangle to draw the check in
+ * @width: the width of the rectangle to draw the check in
+ * @height: the height of the rectangle to draw the check in
+ * 
+ * Draws a check button indicator in the given rectangle on @window with 
+ * the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_check() instead.
+ */
 void
 gtk_draw_check (GtkStyle      *style,
                 GdkWindow     *window,
@@ -963,6 +1177,22 @@ gtk_draw_check (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_option:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the rectangle to draw the option in
+ * @y: y origin of the rectangle to draw the option in
+ * @width: the width of the rectangle to draw the option in
+ * @height: the height of the rectangle to draw the option in
+ *
+ * Draws a radio button indicator in the given rectangle on @window with 
+ * the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_option() instead.
+ */
 void
 gtk_draw_option (GtkStyle      *style,
                 GdkWindow     *window,
@@ -979,6 +1209,22 @@ gtk_draw_option (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
 }
 
+/**
+ * gtk_draw_tab:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @shadow_type: the type of shadow to draw
+ * @x: x origin of the rectangle to draw the tab in
+ * @y: y origin of the rectangle to draw the tab in
+ * @width: the width of the rectangle to draw the tab in
+ * @height: the height of the rectangle to draw the tab in
+ *
+ * Draws an option menu tab (i.e. the up and down pointing arrows)
+ * in the given rectangle on @window using the given parameters.
+ * 
+ * This function is deprecated, use gtk_paint_tab() instead.
+ */ 
 void
 gtk_draw_tab (GtkStyle      *style,
              GdkWindow     *window,
@@ -1050,6 +1296,20 @@ gtk_draw_extension (GtkStyle       *style,
   GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
 }
 
+/**
+ * gtk_draw_focus:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @x: the x origin of the rectangle around which to draw a focus indicator
+ * @y: the y origin of the rectangle around which to draw a focus indicator
+ * @width: the width of the rectangle around which to draw a focus indicator
+ * @height: the height of the rectangle around which to draw a focus indicator
+ *
+ * Draws a focus indicator around the given rectangle on @window using the
+ * given style.
+ * 
+ * This function is deprecated, use gtk_paint_focus() instead.
+ */
 void
 gtk_draw_focus (GtkStyle      *style,
                GdkWindow     *window,
@@ -1061,7 +1321,7 @@ gtk_draw_focus (GtkStyle      *style,
   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);
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL, x, y, width, height);
 }
 
 void 
@@ -1131,6 +1391,23 @@ gtk_draw_layout (GtkStyle        *style,
                                             x, y, layout);
 }
 
+/**
+ * gtk_draw_resize_grip:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @edge: the edge in which to draw the resize grip, currently only
+ *    %GTK_WINDOW_EDGE_SOUTH_EAST is implemented
+ * @x: the x origin of the rectangle in which to draw the resize grip
+ * @y: the y origin of the rectangle in which to draw the resize grip
+ * @width: the width of the rectangle in which to draw the resize grip
+ * @height: the height of the rectangle in which to draw the resize grip
+ *
+ * Draws a resize grip in the given rectangle on @window using the given
+ * parameters. 
+ * 
+ * This function is deprecated, use gtk_paint_resize_grip() instead.
+ */
 void
 gtk_draw_resize_grip (GtkStyle     *style,
                       GdkWindow    *window,
@@ -1151,6 +1428,15 @@ gtk_draw_resize_grip (GtkStyle     *style,
 }
 
 
+/**
+ * gtk_style_set_background:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * 
+ * Sets the background of @window to the background color or pixmap
+ * specified by @style for the given state.
+ */
 void
 gtk_style_set_background (GtkStyle    *style,
                           GdkWindow   *window,
@@ -1221,10 +1507,7 @@ gtk_style_real_init_from_rc (GtkStyle   *style,
   clear_property_cache (style);
 
   if (rc_style->font_desc)
-    {
-      pango_font_description_free (style->font_desc);
-      style->font_desc = pango_font_description_copy (rc_style->font_desc);
-    }
+    pango_font_description_merge (style->font_desc, rc_style->font_desc, TRUE);
     
   for (i = 0; i < 5; i++)
     {
@@ -1354,7 +1637,7 @@ _gtk_style_peek_property_value (GtkStyle           *style,
   return &pcache->value;
 }
 
-GdkPixmap *
+static GdkPixmap *
 load_bg_image (GdkColormap *colormap,
               GdkColor    *bg_color,
               const gchar *filename)
@@ -1520,6 +1803,22 @@ gtk_style_real_set_background (GtkStyle    *style,
     gdk_window_set_background (window, &style->bg[state_type]);
 }
 
+/**
+ * gtk_style_render_icon:
+ * @style: a #GtkStyle
+ * @source: the #GtkIconSource specifying the icon to render
+ * @direction: a text direction
+ * @state: a state
+ * @size: the size to render the icon at. A size of (GtkIconSize)-1
+ *        means render at the size of the source and don't scale.
+ * @widget: the widget 
+ * @detail: a style detail
+ * @returns: a newly-created #GdkPixbuf containing the rendered icon
+ *
+ * Renders the icon specified by @source at the given @size 
+ * according to the given parameters and returns the result in a 
+ * pixbuf.
+ */
 GdkPixbuf *
 gtk_style_render_icon (GtkStyle            *style,
                        const GtkIconSource *source,
@@ -1650,16 +1949,16 @@ gtk_default_render_icon (GtkStyle            *style,
 
   g_return_val_if_fail (base_pixbuf != NULL, NULL);
   
-  if (!gtk_icon_size_lookup (size, &width, &height))
+  if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup (size, &width, &height))
     {
       g_warning (G_STRLOC ": invalid icon size `%d'", size);
       return NULL;
     }
 
-  /* If the size was wildcarded, then scale; otherwise, leave it
-   * alone.
+  /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
+   * leave it alone.
    */
-  if (gtk_icon_source_get_size_wildcarded (source))
+  if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source))
     scaled = scale_or_ref (base_pixbuf, width, height);
   else
     scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
@@ -1696,24 +1995,17 @@ gtk_default_render_icon (GtkStyle            *style,
   return stated;
 }
 
-static gboolean
+static void
 sanitize_size (GdkWindow *window,
               gint      *width,
               gint      *height)
 {
-  gboolean set_bg = FALSE;
-
   if ((*width == -1) && (*height == -1))
-    {
-      set_bg = GDK_IS_WINDOW (window);
-      gdk_window_get_size (window, width, height);
-    }
+    gdk_window_get_size (window, width, height);
   else if (*width == -1)
     gdk_window_get_size (window, width, NULL);
   else if (*height == -1)
     gdk_window_get_size (window, NULL, height);
-
-  return set_bg;
 }
 
 static void
@@ -1847,7 +2139,7 @@ gtk_default_draw_vline (GtkStyle     *style,
 }
 
 
-void
+static void
 draw_thin_shadow (GtkStyle      *style,
                  GdkWindow     *window,
                  GtkStateType   state,
@@ -1887,7 +2179,7 @@ draw_thin_shadow (GtkStyle      *style,
     }
 }
 
-void
+static void
 draw_spin_entry_shadow (GtkStyle      *style,
                        GdkWindow     *window,
                        GtkStateType   state,
@@ -1955,19 +2247,18 @@ draw_spin_entry_shadow (GtkStyle      *style,
 }
 
 static void
-draw_spinbutton_shadow (GtkStyle      *style,
-                       GdkWindow     *window,
-                       GtkStateType   state,
-                       GdkRectangle  *area,
-                       gint           x,
-                       gint           y,
-                       gint           width,
-                       gint           height)
+draw_spinbutton_shadow (GtkStyle        *style,
+                       GdkWindow       *window,
+                       GtkStateType     state,
+                       GtkTextDirection direction,
+                       GdkRectangle    *area,
+                       gint             x,
+                       gint             y,
+                       gint             width,
+                       gint             height)
 {
-  gint y_middle = y + height / 2;
-
   sanitize_size (window, &width, &height);
-  
+
   if (area)
     {
       gdk_gc_set_clip_rectangle (style->black_gc, area);
@@ -1975,33 +2266,42 @@ draw_spinbutton_shadow (GtkStyle      *style,
       gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
       gdk_gc_set_clip_rectangle (style->light_gc[state], area);
     }
-  
-  gdk_draw_line (window, style->black_gc,
-                x, y + 2, x, y + height - 3);
-  gdk_draw_line (window, style->black_gc,
-                x, y + 1, x + width - 2, y + 1);
-  gdk_draw_line (window, style->black_gc,
-                x + width - 2, y + 2, x + width - 2, y + height - 3);
-  
-  gdk_draw_line (window, style->bg_gc[state],
-                x, y + height - 2, x + width - 2, y + height - 2);
 
-  gdk_draw_line (window, style->dark_gc[state],
-                x, y, x + width - 1, y);
-  gdk_draw_line (window, style->dark_gc[state],
-                x + 1, y_middle - 1, x + width - 3, y_middle - 1);
-  gdk_draw_line (window, style->dark_gc[state],
-                x + 1, y + height - 3, x + width - 3, y + height - 3);
-
-  gdk_draw_line (window, style->light_gc[state],
-                x + 1, y + 2, x + width - 3, y + 2);
-  gdk_draw_line (window, style->light_gc[state],
-                x + 1, y_middle, x + width - 3, y_middle);
-  gdk_draw_line (window, style->light_gc[state],
-                x + width - 1, y + 1, x + width - 1, y + height - 1);
-  gdk_draw_line (window, style->light_gc[state],
-                x, y + height - 1, x + width - 2, y + height - 1);
-      
+  if (direction == GTK_TEXT_DIR_LTR)
+    {
+      gdk_draw_line (window, style->dark_gc[state],
+                    x, y, x + width - 1, y);
+      gdk_draw_line (window, style->black_gc,
+                    x, y + 1, x + width - 2, y + 1);
+      gdk_draw_line (window, style->black_gc,
+                    x + width - 2, y + 2, x + width - 2, y + height - 3);
+      gdk_draw_line (window, style->light_gc[state],
+                    x + width - 1, y + 1, x + width - 1, y + height - 2);
+      gdk_draw_line (window, style->light_gc[state],
+                    x, y + height - 1, x + width - 1, y + height - 1);
+      gdk_draw_line (window, style->bg_gc[state],
+                    x, y + height - 2, x + width - 2, y + height - 2);
+      gdk_draw_line (window, style->black_gc,
+                    x, y + 2, x, y + height - 3);
+    }
+  else
+    {
+      gdk_draw_line (window, style->dark_gc[state],
+                    x, y, x + width - 1, y);
+      gdk_draw_line (window, style->dark_gc[state],
+                    x, y + 1, x, y + height - 1);
+      gdk_draw_line (window, style->black_gc,
+                    x + 1, y + 1, x + width - 1, y + 1);
+      gdk_draw_line (window, style->black_gc,
+                    x + 1, y + 2, x + 1, y + height - 2);
+      gdk_draw_line (window, style->black_gc,
+                    x + width - 1, y + 2, x + width - 1, y + height - 3);
+      gdk_draw_line (window, style->light_gc[state],
+                    x + 1, y + height - 1, x + width - 1, y + height - 1);
+      gdk_draw_line (window, style->bg_gc[state],
+                    x + 2, y + height - 2, x + width - 1, y + height - 2);
+    }
+  
   if (area)
     {
       gdk_gc_set_clip_rectangle (style->black_gc, NULL);
@@ -2050,18 +2350,12 @@ gtk_default_draw_shadow (GtkStyle      *style,
                            x, y, width, height);
          return;
        }
-      else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
-              detail && strcmp (detail, "entry") == 0)
-       {
-         draw_spin_entry_shadow (style, window, state_type, area,
-                                 x, y, width, height);
-         return;
-       }
-      else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
-              detail && strcmp (detail, "spinbutton") == 0)
+      if (widget && GTK_IS_SPIN_BUTTON (widget) &&
+         detail && strcmp (detail, "spinbutton") == 0)
        {
          draw_spinbutton_shadow (style, window, state_type,
-                                 area, x, y, width, height);
+                                 gtk_widget_get_direction (widget), area, x, y, width, height);
+         
          return;
        }
     }
@@ -2286,6 +2580,52 @@ gtk_default_draw_shadow (GtkStyle      *style,
       
       break;
     }
+
+  if (shadow_type == GTK_SHADOW_IN &&
+      widget && GTK_IS_SPIN_BUTTON (widget) &&
+      detail && strcmp (detail, "entry") == 0)
+    {
+      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+       {
+         gdk_draw_line (window,
+                        style->base_gc[state_type],
+                        x + width - 1, y + 2,
+                        x + width - 1, y + height - 3);
+         gdk_draw_line (window,
+                        style->base_gc[state_type],
+                        x + width - 2, y + 2,
+                        x + width - 2, y + height - 3);
+         gdk_draw_point (window,
+                         style->black_gc,
+                         x + width - 1, y + 1);
+         gdk_draw_point (window,
+                         style->bg_gc[state_type],
+                         x + width - 1, y + height - 2);
+       }
+      else
+       {
+         gdk_draw_line (window,
+                        style->base_gc[state_type],
+                        x, y + 2,
+                        x, y + height - 3);
+         gdk_draw_line (window,
+                        style->base_gc[state_type],
+                        x + 1, y + 2,
+                        x + 1, y + height - 3);
+         gdk_draw_point (window,
+                         style->black_gc,
+                         x, y + 1);
+         gdk_draw_line (window,
+                        style->bg_gc[state_type],
+                        x, y + height - 2,
+                        x + 1, y + height - 2);
+         gdk_draw_point (window,
+                         style->light_gc[state_type],
+                         x, y + height - 1);
+       }
+    }
+
+
   if (area)
     {
       gdk_gc_set_clip_rectangle (gc1, NULL);
@@ -2558,15 +2898,31 @@ gtk_default_draw_arrow (GtkStyle      *style,
   
   if (detail && strcmp (detail, "spinbutton") == 0)
     {
-      x += (width - 7) / 2;
+      int hpad, vpad;
+      int my_height = height;
+      int my_width = width;
+      int vpad_add = 0;
 
-      if (arrow_type == GTK_ARROW_UP)
-       y += (height - 4) / 2;
-      else
-       y += (1 + height - 4) / 2;
+      if (my_height > my_width)
+       {
+         vpad_add = (my_height - my_width) / 2;
+         my_height = my_width;
+       }
+
+      hpad = my_width / 4;
+
+      if (hpad < 4)
+       hpad = 4;
+
+      vpad = 2 * hpad - 1;
+
+      x += hpad / 2;
+      y += vpad / 2;
+
+      y += vpad_add;
 
       draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
-                  x, y, 7, 4);
+                  x, y, my_width - hpad, my_height - vpad);
     }
   else if (detail && strcmp (detail, "vscrollbar") == 0)
     {
@@ -2575,10 +2931,9 @@ gtk_default_draw_arrow (GtkStyle      *style,
       
       x += (width - 7) / 2;
       y += (height - 5) / 2;
-
+      
       draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
                   x, y, 7, 5);
-      
     }
   else if (detail && strcmp (detail, "hscrollbar") == 0)
     {
@@ -2825,10 +3180,41 @@ gtk_default_draw_box (GtkStyle      *style,
                      gint           width,
                      gint           height)
 {
+  gboolean is_spinbutton_box = FALSE;
+  
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
   
   sanitize_size (window, &width, &height);
+
+  if (widget && GTK_IS_SPIN_BUTTON (widget) && detail)
+    {
+      if (strcmp (detail, "spinbutton_up") == 0)
+       {
+         y += 2;
+         width -= 3;
+         height -= 2;
+
+         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+           x += 2;
+         else
+           x += 1;
+
+         is_spinbutton_box = TRUE;
+       }
+      else if (strcmp (detail, "spinbutton_down") == 0)
+       {
+         width -= 3;
+         height -= 2;
+
+         if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+           x += 2;
+         else
+           x += 1;
+
+         is_spinbutton_box = TRUE;
+       }
+    }
   
   if (!style->bg_pixmap[state_type] || 
       GDK_IS_PIXMAP (window))
@@ -2845,7 +3231,35 @@ gtk_default_draw_box (GtkStyle      *style,
     gtk_style_apply_default_background (style, window,
                                         widget && !GTK_WIDGET_NO_WINDOW (widget),
                                         state_type, area, x, y, width, height);
-  
+
+  if (is_spinbutton_box)
+    {
+      GdkGC *upper_gc;
+      GdkGC *lower_gc;
+      
+      lower_gc = style->dark_gc[state_type];
+      if (shadow_type == GTK_SHADOW_OUT)
+       upper_gc = style->light_gc[state_type];
+      else
+       upper_gc = style->dark_gc[state_type];
+
+      if (area)
+       {
+         gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
+         gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
+       }
+      
+      gdk_draw_line (window, upper_gc, x, y, x + width - 1, y);
+      gdk_draw_line (window, lower_gc, x, y + height - 1, x + width - 1, y + height - 1);
+
+      if (area)
+       {
+         gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
+         gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
+       }
+      return;
+    }
+
   gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
                     x, y, width, height);
 
@@ -3043,20 +3457,35 @@ gtk_default_draw_check (GtkStyle      *style,
              draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
              draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
            }
+         else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+           {
+             draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
+             draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+           }
        }
       else
        {
+         GdkGC *base_gc = style->base_gc[state_type];
+
+         if (state_type == GTK_STATE_ACTIVE)
+           base_gc = style->bg_gc[state_type];
+         
+         draw_part (window, base_gc, area, x, y, CHECK_BASE);
          draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
          draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
          draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
          draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
-         draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
          
          if (shadow_type == GTK_SHADOW_IN)
            {
              draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
              draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
            }
+         else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+           {
+             draw_part (window, style->text_gc[state_type], area, x, y, CHECK_INCONSISTENT_TEXT);
+             draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+           }
        }
     }
 
@@ -3105,18 +3534,37 @@ gtk_default_draw_option (GtkStyle      *style,
       if (strcmp (detail, "option") == 0)      /* Menu item */
        {
          if (shadow_type == GTK_SHADOW_IN)
-           draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
+           {
+             draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
+           }
+         else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+           {
+             draw_part (window, style->black_gc, area, x, y, CHECK_INCONSISTENT_TEXT);
+             draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_INCONSISTENT_AA);
+           }
        }
       else
        {
+         GdkGC *base_gc = style->base_gc[state_type];
+
+         if (state_type == GTK_STATE_ACTIVE)
+           base_gc = style->bg_gc[state_type];
+
+         draw_part (window, base_gc, area, x, y, RADIO_BASE);
          draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
          draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
          draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
          draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
-         draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
          
          if (shadow_type == GTK_SHADOW_IN)
-           draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
+           {
+             draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
+           }
+         else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */
+           {
+             draw_part (window, style->text_aa_gc[state_type], area, x, y, RADIO_INCONSISTENT_AA);
+             draw_part (window, style->text_gc[state_type], area, x, y, RADIO_INCONSISTENT_TEXT);
+           }
        }
     }
 }
@@ -3248,7 +3696,7 @@ gtk_default_draw_shadow_gap (GtkStyle       *style,
               gdk_draw_line (window, gc1,
                              x + gap_x + gap_width, y, x + width - 2, y);
               gdk_draw_line (window, gc2,
-                             x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
+                             x + gap_x + gap_width, y + 1, x + width - 3, y + 1);
               gdk_draw_line (window, gc2,
                              x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
             }
@@ -3763,6 +4211,7 @@ gtk_default_draw_extension (GtkStyle       *style,
 static void 
 gtk_default_draw_focus (GtkStyle      *style,
                        GdkWindow     *window,
+                       GtkStateType   state_type,
                        GdkRectangle  *area,
                        GtkWidget     *widget,
                        const gchar   *detail,
@@ -3772,34 +4221,128 @@ gtk_default_draw_focus (GtkStyle      *style,
                        gint           height)
 {
   GdkPoint points[5];
-  
+  GdkGC    *gc;
+  gboolean free_dash_list = FALSE;
+  gint line_width = 1;
+  gchar *dash_list = "\1\1";
+  gint dash_len;
+
+  gc = style->fg_gc[state_type];
+
+  if (widget)
+    {
+      gtk_widget_style_get (widget,
+                           "focus-line-width", &line_width,
+                           "focus-line-pattern", (gchar *)&dash_list,
+                           NULL);
+
+      free_dash_list = TRUE;
+  }
+
   sanitize_size (window, &width, &height);
   
   if (area)
-    gdk_gc_set_clip_rectangle (style->black_gc, area);
+    gdk_gc_set_clip_rectangle (gc, area);
+
+  gdk_gc_set_line_attributes (gc, line_width,
+                             dash_list[0] ? GDK_LINE_ON_OFF_DASH : GDK_LINE_SOLID,
+                             GDK_CAP_BUTT, GDK_JOIN_MITER);
 
-  gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
 
   if (detail && !strcmp (detail, "add-mode"))
-    gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
-  else
-    gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
-
-  points[0].x = x;
-  points[0].y = y;
-  points[1].x = x + width;
-  points[1].y = y;
-  points[2].x = x + width;
-  points[2].y = y + height;
-  points[3].x = x;
-  points[3].y = y + height;
+    {
+      if (free_dash_list)
+       g_free (dash_list);
+      
+      dash_list = "\4\4";
+      free_dash_list = FALSE;
+    }
+
+  points[0].x = x + line_width / 2;
+  points[0].y = y + line_width / 2;
+  points[1].x = x + width - line_width + line_width / 2;
+  points[1].y = y + line_width / 2;
+  points[2].x = x + width - line_width + line_width / 2;
+  points[2].y = y + height - line_width + line_width / 2;
+  points[3].x = x + line_width / 2;
+  points[3].y = y + height - line_width + line_width / 2;
   points[4] = points[0];
-  
-  gdk_draw_polygon (window, style->black_gc, FALSE, points, 4);
-  gdk_gc_set_line_attributes (style->black_gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
+
+  if (!dash_list[0])
+    {
+      gdk_draw_lines (window, gc, points, 5);
+    }
+  else
+    {
+      /* We go through all the pain below because the X rasterization
+       * rules don't really work right for dashed lines if you
+       * want continuity in segments that go between top/right
+       * and left/bottom. For instance, a top left corner
+       * with a 1-1 dash is drawn as:
+       *
+       *  X X X 
+       *  X
+       *
+       *  X
+       *
+       * This is because pixels on the top and left boundaries
+       * of polygons are drawn, but not on the bottom and right.
+       * So, if you have a line going up that turns the corner
+       * and goes right, there is a one pixel shift in the pattern.
+       *
+       * So, to fix this, we drawn the top and right in one call,
+       * then the left and bottom in another call, fixing up
+       * the dash offset for the second call ourselves to get
+       * continuity at the upper left.
+       *
+       * It's not perfect since we really should have a join at
+       * the upper left and lower right instead of two intersecting
+       * lines but that's only really apparent for no-dashes,
+       * which (for this reason) are done as one polygon and
+       * don't to through this code path.
+       */
+      
+      dash_len = strlen (dash_list);
+      
+      if (dash_list[0])
+       gdk_gc_set_dashes (gc, 0, dash_list, dash_len);
+      
+      gdk_draw_lines (window, gc, points, 3);
+      
+      /* We draw this line one farther over than it is "supposed" to
+       * because of another rasterization problem ... if two 1 pixel
+       * unjoined lines meet at the lower right, there will be a missing
+       * pixel.
+       */
+      points[2].x += 1;
+      
+      if (dash_list[0])
+       {
+         gint dash_pixels = 0;
+         gint i;
+         
+         /* Adjust the dash offset for the bottom and left so we
+          * match up at the upper left.
+          */
+         for (i = 0; i < dash_len; i++)
+           dash_pixels += dash_list[i];
+      
+         if (dash_len % 2 == 1)
+           dash_pixels *= 2;
+         
+         gdk_gc_set_dashes (gc, dash_pixels - (width + height - 2 * line_width) % dash_pixels, dash_list, dash_len);
+       }
+      
+      gdk_draw_lines (window, gc, points + 2, 3);
+    }
+
+  gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
 
   if (area)
-    gdk_gc_set_clip_rectangle (style->black_gc, NULL);
+    gdk_gc_set_clip_rectangle (gc, NULL);
+
+  if (free_dash_list)
+    g_free (dash_list);
 }
 
 static void 
@@ -3935,17 +4478,12 @@ gtk_default_draw_handle (GtkStyle      *style,
 
   if (!strcmp (detail, "paned"))
     {
-      gint window_width;
-      gint window_height;
-
-      gdk_window_get_size (window, &window_width, &window_height);
-
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
-       for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
-         draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
+       for (xx = x + width/2 - 15; xx <= x + width/2 + 15; xx += 5)
+         draw_dot (window, light_gc, dark_gc, xx, y + height/2 - 1, 3);
       else
-       for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
-         draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
+       for (yy = y + height/2 - 15; yy <= y + height/2 + 15; yy += 5)
+         draw_dot (window, light_gc, dark_gc, x + width/2 - 1, yy, 3);
     }
   else
     {
@@ -3998,6 +4536,18 @@ apply_affine_on_point (double affine[6], GdkPoint *point)
   point->y = y;
 }
 
+static void
+gtk_style_draw_polygon_with_gc (GdkWindow *window, GdkGC *gc, gint line_width,
+                               gboolean do_fill, GdkPoint *points, gint n_points)
+{
+  gdk_gc_set_line_attributes (gc, line_width,
+                             GDK_LINE_SOLID,
+                             GDK_CAP_BUTT, GDK_JOIN_MITER);
+
+  gdk_draw_polygon (window, gc, do_fill, points, n_points);
+  gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
+}
+
 static void
 gtk_default_draw_expander (GtkStyle        *style,
                            GdkWindow       *window,
@@ -4012,12 +4562,14 @@ gtk_default_draw_expander (GtkStyle        *style,
   gint expander_size;
   GdkPoint points[3];
   gint i;
+  gint line_width;
   gdouble affine[6];
   gint degrees = 0;
-  
+
   gtk_widget_style_get (widget,
                        "expander_size", &expander_size,
                        NULL);
+  line_width = MAX (1, expander_size/7);
 
   if (area)
     {
@@ -4025,23 +4577,24 @@ gtk_default_draw_expander (GtkStyle        *style,
       gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
     }
 
-  points[0].x = 0;
-  points[0].y = 0;
-  points[1].x = expander_size / 2;
-  points[1].y =  expander_size / 2;
-  points[2].x = 0;
-  points[2].y = expander_size;
+  expander_size -= (line_width * 2 - 2);
+  points[0].x = line_width / 2;
+  points[0].y = line_width / 2;
+  points[1].x = expander_size / 2 + line_width / 2;
+  points[1].y = expander_size / 2 + line_width / 2;
+  points[2].x = line_width / 2;
+  points[2].y = expander_size + line_width / 2;
 
   switch (expander_style)
     {
     case GTK_EXPANDER_COLLAPSED:
-      degrees = 0;
+      degrees = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 180 : 0;
       break;
     case GTK_EXPANDER_SEMI_COLLAPSED:
-      degrees = 30;
+      degrees = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 150 : 30;
       break;
     case GTK_EXPANDER_SEMI_EXPANDED:
-      degrees = 60;
+      degrees = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 120 : 60;
       break;
     case GTK_EXPANDER_EXPANDED:
       degrees = 90;
@@ -4049,7 +4602,7 @@ gtk_default_draw_expander (GtkStyle        *style,
     default:
       g_assert_not_reached ();
     }
-  
+
   create_expander_affine (affine, degrees, expander_size, x, y);
 
   for (i = 0; i < 3; i++)
@@ -4057,22 +4610,22 @@ gtk_default_draw_expander (GtkStyle        *style,
 
   if (state_type == GTK_STATE_PRELIGHT)
     {
-      gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
-                       TRUE, points, 3);
+      gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
+                                     1, TRUE, points, 3);
     }
   else if (state_type == GTK_STATE_ACTIVE)
     {
-      gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
-                       TRUE, points, 3);
-      gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
-                       FALSE, points, 3);
+      gtk_style_draw_polygon_with_gc (window, style->light_gc[GTK_STATE_ACTIVE],
+                                     1, TRUE, points, 3);
+      gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
+                                     line_width, FALSE, points, 3);
     }
   else
     {
-      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);
+      gtk_style_draw_polygon_with_gc (window, style->base_gc[GTK_STATE_NORMAL],
+                                     1, TRUE, points, 3);
+      gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
+                                     line_width, FALSE, points, 3);
     }
   if (area)
     {
@@ -4307,11 +4860,10 @@ gtk_default_draw_resize_grip (GtkStyle       *style,
     }
 
   /* Clear background */
-  gdk_draw_rectangle (window,
-                      style->bg_gc[state_type],
-                      TRUE,
-                      x, y, width, height);
-  
+  gtk_style_apply_default_background (style, window, FALSE,
+                                     state_type, area,
+                                     x, y, width, height);   
+
   switch (edge)
     {
     case GDK_WINDOW_EDGE_SOUTH_EAST:
@@ -4546,6 +5098,22 @@ hls_to_rgb (gdouble *h,
     }
 }
 
+
+/**
+ * gtk_paint_hline:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @area: rectangle to which the output is clipped
+ * @widget:
+ * @detail: 
+ * @x1: the starting x coordinate
+ * @x2: the ending x coordinate
+ * @y: the y coordinate
+ * 
+ * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
+ * using the given style and state.
+ **/ 
 void 
 gtk_paint_hline (GtkStyle      *style,
                  GdkWindow     *window,
@@ -4563,6 +5131,21 @@ gtk_paint_hline (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
 }
 
+/**
+ * gtk_paint_vline:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @area: rectangle to which the output is clipped
+ * @widget:
+ * @detail: 
+ * @y1: the starting y coordinate
+ * @y2: the ending y coordinate
+ * @x: the x coordinate
+ * 
+ * Draws a vertical line from (@x, @y1) to (@x, @y1) in @window
+ * using the given style and state.
+ */
 void
 gtk_paint_vline (GtkStyle      *style,
                  GdkWindow     *window,
@@ -4657,6 +5240,22 @@ gtk_paint_diamond (GtkStyle      *style,
   GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
 }
 
+/**
+ * gtk_paint_string:
+ * @style: a #GtkStyle
+ * @window: a #GdkWindow
+ * @state_type: a state
+ * @area: clip rectangle
+ * @widget: the widget
+ * @detail: a style detail
+ * @x: x origin
+ * @y: y origin
+ * @string: the string to draw
+ * 
+ * Draws a text string on @window with the given parameters.
+ *
+ * This function is deprecated, use gtk_paint_layout() instead.
+ */
 void
 gtk_paint_string (GtkStyle      *style,
                   GdkWindow     *window,
@@ -4837,6 +5436,7 @@ gtk_paint_extension (GtkStyle       *style,
 void
 gtk_paint_focus (GtkStyle      *style,
                  GdkWindow     *window,
+                GtkStateType   state_type,
                  GdkRectangle  *area,
                  GtkWidget     *widget,
                  const gchar   *detail,
@@ -4848,7 +5448,7 @@ gtk_paint_focus (GtkStyle      *style,
   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, area, widget, detail, x, y, width, height);
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
 }
 
 void
@@ -4950,12 +5550,25 @@ gtk_paint_resize_grip (GtkStyle      *style,
                                                  edge, x, y, width, height);
 }
 
+/**
+ * gtk_border_copy:
+ * @border: a #GtkBorder.
+ * @returns: a copy of @border.
+ *
+ * Copies a #GtkBorder structure.
+ **/
 GtkBorder *
 gtk_border_copy (const GtkBorder *border)
 {
   return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
 }
 
+/**
+ * gtk_border_free:
+ * @border: a #GtkBorder.
+ * 
+ * Frees a #GtkBorder structure.
+ **/
 void
 gtk_border_free (GtkBorder *border)
 {
@@ -4967,9 +5580,9 @@ gtk_border_free (GtkBorder *border)
  * @style: a #GtkStyle
  * 
  * Gets the #GdkFont to use for the given style. This is
- * meant only as a replacement for direct access to style->font
+ * meant only as a replacement for direct access to @style->font
  * and should not be used in new code. New code should
- * use style->font_desc instead.
+ * use @style->font_desc instead.
  * 
  * Return value: the #GdkFont for the style. This font is owned
  *   by the style; if you want to keep around a copy, you must
@@ -5051,6 +5664,7 @@ gtk_style_set_font (GtkStyle *style,
 
 /**
  * _gtk_draw_insertion_cursor:
+ * @widget: a #GtkWidget
  * @drawable: a #GdkDrawable
  * @gc: a #GdkGC
  * @location: location where to draw the cursor (@location->width is ignored)
@@ -5062,20 +5676,27 @@ gtk_style_set_font (GtkStyle *style,
  * but merely a convenience function for drawing the standard cursor shape.
  **/
 void
-_gtk_draw_insertion_cursor (GdkDrawable      *drawable,
+_gtk_draw_insertion_cursor (GtkWidget        *widget,
+                           GdkDrawable      *drawable,
                            GdkGC            *gc,
                            GdkRectangle     *location,
                            GtkTextDirection  dir)
 {
-  gint stem_width = location->height / 30 + 1;
-  gint arrow_width = stem_width + 1;
+  gint stem_width;
+  gint arrow_width;
   gint x, y;
   gint i;
+  gfloat cursor_aspect_ratio;
 
+  gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL);
+  
+  stem_width = location->height * cursor_aspect_ratio + 1;
+  arrow_width = stem_width + 1;
   for (i = 0; i < stem_width; i++)
     gdk_draw_line (drawable, gc,
                   location->x + i - stem_width / 2, location->y,
-                  location->x + i - stem_width / 2, location->y + location->height);
+                  location->x + i - stem_width / 2, location->y + location->height - 1);
 
   if (dir == GTK_TEXT_DIR_RTL)
     {
@@ -5104,4 +5725,3 @@ _gtk_draw_insertion_cursor (GdkDrawable      *drawable,
        }
     }
 }
-