]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktoolbar.c
Deprecate widget flag: GTK_WIDGET_MAPPED
[~andy/gtk] / gtk / gtktoolbar.c
index 56dd4ca4954cbd4f2158b916d4559fc5d160981a..3b3d9afae26a262d370ba0f4dc1e6bd3d9437915 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (C) 2002 Anders Carlsson <andersca@gnome.org>
  * Copyright (C) 2002 James Henstridge <james@daa.com.au>
  * Copyright (C) 2003, 2004 Soeren Sandmann <sandmann@daimi.au.dk>
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #undef GTK_DISABLE_DEPRECATED
 
-#include <config.h>
+#include "config.h"
+
+#include <math.h>
+#include <string.h>
+
+#include <gdk/gdkkeysyms.h>
+
 #include "gtkarrow.h"
-#include "gtktoolbar.h"
-#include "gtkradiotoolbutton.h"
-#include "gtkseparatortoolitem.h"
-#include "gtkmenu.h"
-#include "gtkradiobutton.h"
-#include "gtktoolbar.h"
 #include "gtkbindings.h"
-#include <gdk/gdkkeysyms.h>
-#include "gtkmarshalers.h"
+#include "gtkhbox.h"
+#include "gtkimage.h"
+#include "gtklabel.h"
 #include "gtkmain.h"
+#include "gtkmarshalers.h"
+#include "gtkmenu.h"
+#include "gtkorientable.h"
+#include "gtkradiobutton.h"
+#include "gtkradiotoolbutton.h"
+#include "gtkseparatormenuitem.h"
+#include "gtkseparatortoolitem.h"
 #include "gtkstock.h"
-#include "gtklabel.h"
+#include "gtktoolbar.h"
+#include "gtktoolshell.h"
+#include "gtkvbox.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
-#include <string.h>
-#include "gtkhbox.h"
-#include "gtkvbox.h"
-#include "gtkimage.h"
+#include "gtkalias.h"
 
 typedef struct _ToolbarContent ToolbarContent;
 
-#define DEFAULT_IPADDING 0
+#define DEFAULT_IPADDING    0
 
 #define DEFAULT_SPACE_SIZE  12
 #define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
@@ -64,19 +71,28 @@ typedef struct _ToolbarContent ToolbarContent;
 
 #define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
 #define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
+#define DEFAULT_ANIMATION_STATE TRUE
 
 #define MAX_HOMOGENEOUS_N_CHARS 13 /* Items that are wider than this do not participate
                                    * in the homogeneous game. In units of
                                    * pango_font_get_estimated_char_width().
                                    */
-#define SLIDE_SPEED 600           /* How fast the items slide, in pixels per second */
+#define SLIDE_SPEED 600.0         /* How fast the items slide, in pixels per second */
+#define ACCEL_THRESHOLD 0.18      /* After how much time in seconds will items start speeding up */
+
+#define MIXED_API_WARNING                                              \
+    "Mixing deprecated and non-deprecated GtkToolbar API is not allowed"
+
 
 /* Properties */
 enum {
   PROP_0,
   PROP_ORIENTATION,
   PROP_TOOLBAR_STYLE,
-  PROP_SHOW_ARROW
+  PROP_SHOW_ARROW,
+  PROP_TOOLTIPS,
+  PROP_ICON_SIZE,
+  PROP_ICON_SIZE_SET
 };
 
 /* Child properties */
@@ -91,7 +107,6 @@ enum {
   ORIENTATION_CHANGED,
   STYLE_CHANGED,
   POPUP_CONTEXT_MENU,
-  MOVE_FOCUS,
   FOCUS_HOME_OR_END,
   LAST_SIGNAL
 };
@@ -112,7 +127,7 @@ typedef enum {
   NOT_ALLOCATED,
   NORMAL,
   HIDDEN,
-  OVERFLOWN,
+  OVERFLOWN
 } ItemState;
 
 struct _GtkToolbarPrivate
@@ -121,7 +136,6 @@ struct _GtkToolbarPrivate
   
   GtkWidget *  arrow;
   GtkWidget *  arrow_button;
-  
   GtkMenu *    menu;
   
   GdkWindow *  event_window;
@@ -132,14 +146,16 @@ struct _GtkToolbarPrivate
   gint         max_homogeneous_pixels;
   
   GTimer *     timer;
-  
-  guint                show_arrow : 1;
-  guint                need_sync : 1;
-  guint                is_sliding : 1;
+
+  gulong        settings_connection;
+
+  guint         show_arrow : 1;
+  guint         need_sync : 1;
+  guint         is_sliding : 1;
+  guint         need_rebuild : 1;  /* whether the overflow menu should be regenerated */
+  guint         animation : 1;
 };
 
-static void       gtk_toolbar_init                 (GtkToolbar          *toolbar);
-static void       gtk_toolbar_class_init           (GtkToolbarClass     *klass);
 static void       gtk_toolbar_set_property         (GObject             *object,
                                                    guint                prop_id,
                                                    const GValue        *value,
@@ -160,6 +176,8 @@ static void       gtk_toolbar_style_set            (GtkWidget           *widget,
                                                    GtkStyle            *prev_style);
 static gboolean   gtk_toolbar_focus                (GtkWidget           *widget,
                                                    GtkDirectionType     dir);
+static void       gtk_toolbar_move_focus           (GtkWidget           *widget,
+                                                   GtkDirectionType     dir);
 static void       gtk_toolbar_screen_changed       (GtkWidget           *widget,
                                                    GdkScreen           *previous_screen);
 static void       gtk_toolbar_map                  (GtkWidget           *widget);
@@ -190,8 +208,6 @@ static void       gtk_toolbar_orientation_changed  (GtkToolbar          *toolbar
                                                    GtkOrientation       orientation);
 static void       gtk_toolbar_real_style_changed   (GtkToolbar          *toolbar,
                                                    GtkToolbarStyle      style);
-static gboolean   gtk_toolbar_move_focus           (GtkToolbar          *toolbar,
-                                                   GtkDirectionType     dir);
 static gboolean   gtk_toolbar_focus_home_or_end    (GtkToolbar          *toolbar,
                                                    gboolean             focus_home);
 static gboolean   gtk_toolbar_button_press         (GtkWidget           *toolbar,
@@ -210,7 +226,7 @@ static GtkWidget *internal_insert_element          (GtkToolbar          *toolbar
                                                    const char          *tooltip_text,
                                                    const char          *tooltip_private_text,
                                                    GtkWidget           *icon,
-                                                   GtkSignalFunc        callback,
+                                                   GCallback            callback,
                                                    gpointer             user_data,
                                                    gint                 position,
                                                    gboolean             use_stock);
@@ -220,6 +236,7 @@ static gboolean   gtk_toolbar_check_old_api        (GtkToolbar          *toolbar
 
 static GtkReliefStyle       get_button_relief    (GtkToolbar *toolbar);
 static gint                 get_internal_padding (GtkToolbar *toolbar);
+static gint                 get_max_child_expand (GtkToolbar *toolbar);
 static GtkShadowType        get_shadow_type      (GtkToolbar *toolbar);
 static gint                 get_space_size       (GtkToolbar *toolbar);
 static GtkToolbarSpaceStyle get_space_style      (GtkToolbar *toolbar);
@@ -279,44 +296,32 @@ static void            toolbar_content_set_size_request     (ToolbarContent
 static void            toolbar_content_toolbar_reconfigured (ToolbarContent      *content,
                                                             GtkToolbar          *toolbar);
 static GtkWidget *     toolbar_content_retrieve_menu_item   (ToolbarContent      *content);
+static gboolean        toolbar_content_has_proxy_menu_item  (ToolbarContent     *content);
 static gboolean        toolbar_content_is_separator         (ToolbarContent      *content);
 static void            toolbar_content_show_all             (ToolbarContent      *content);
 static void            toolbar_content_hide_all             (ToolbarContent      *content);
+static void           toolbar_content_set_expand           (ToolbarContent      *content,
+                                                            gboolean             expand);
 
+static void            toolbar_tool_shell_iface_init        (GtkToolShellIface   *iface);
+static GtkIconSize     toolbar_get_icon_size                (GtkToolShell        *shell);
+static GtkOrientation  toolbar_get_orientation              (GtkToolShell        *shell);
+static GtkToolbarStyle toolbar_get_style                    (GtkToolShell        *shell);
+static GtkReliefStyle  toolbar_get_relief_style             (GtkToolShell        *shell);
+static void            toolbar_rebuild_menu                 (GtkToolShell        *shell);
 
 #define GTK_TOOLBAR_GET_PRIVATE(o)  \
   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOLBAR, GtkToolbarPrivate))
 
-static GtkContainerClass *     parent_class = NULL;
-static guint                   toolbar_signals [LAST_SIGNAL] = { 0 };
 
-GType
-gtk_toolbar_get_type (void)
-{
-  static GtkType type = 0;
-  
-  if (!type)
-    {
-      static const GTypeInfo type_info =
-       {
-         sizeof (GtkToolbarClass),
-         (GBaseInitFunc) NULL,
-         (GBaseFinalizeFunc) NULL,
-         (GClassInitFunc) gtk_toolbar_class_init,
-         (GClassFinalizeFunc) NULL,
-         NULL,
-         sizeof (GtkToolbar),
-         0, /* n_preallocs */
-         (GInstanceInitFunc) gtk_toolbar_init,
-       };
-      
-      type = g_type_register_static (GTK_TYPE_CONTAINER,
-                                    "GtkToolbar",
-                                    &type_info, 0);
-    }
-  
-  return type;
-}
+G_DEFINE_TYPE_WITH_CODE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL,
+                                                toolbar_tool_shell_iface_init)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
+                                                NULL))
+
+static guint toolbar_signals[LAST_SIGNAL] = { 0 };
+
 
 static void
 add_arrow_bindings (GtkBindingSet   *binding_set,
@@ -326,10 +331,10 @@ add_arrow_bindings (GtkBindingSet   *binding_set,
   guint keypad_keysym = keysym - GDK_Left + GDK_KP_Left;
   
   gtk_binding_entry_add_signal (binding_set, keysym, 0,
-                                "move_focus", 1,
+                                "move-focus", 1,
                                 GTK_TYPE_DIRECTION_TYPE, dir);
   gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
-                                "move_focus", 1,
+                                "move-focus", 1,
                                 GTK_TYPE_DIRECTION_TYPE, dir);
 }
 
@@ -340,11 +345,11 @@ add_ctrl_tab_bindings (GtkBindingSet    *binding_set,
 {
   gtk_binding_entry_add_signal (binding_set,
                                GDK_Tab, GDK_CONTROL_MASK | modifiers,
-                               "move_focus", 1,
+                               "move-focus", 1,
                                GTK_TYPE_DIRECTION_TYPE, direction);
   gtk_binding_entry_add_signal (binding_set,
                                GDK_KP_Tab, GDK_CONTROL_MASK | modifiers,
-                               "move_focus", 1,
+                               "move-focus", 1,
                                GTK_TYPE_DIRECTION_TYPE, direction);
 }
 
@@ -356,8 +361,6 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   GtkContainerClass *container_class;
   GtkBindingSet *binding_set;
   
-  parent_class = g_type_class_peek_parent (klass);
-  
   gobject_class = (GObjectClass *)klass;
   widget_class = (GtkWidgetClass *)klass;
   container_class = (GtkContainerClass *)klass;
@@ -372,6 +375,14 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   widget_class->size_allocate = gtk_toolbar_size_allocate;
   widget_class->style_set = gtk_toolbar_style_set;
   widget_class->focus = gtk_toolbar_focus;
+
+  /* need to override the base class function via override_class_handler,
+   * because the signal slot is not available in GtkWidgetClass
+   */
+  g_signal_override_class_handler ("move-focus",
+                                   GTK_TYPE_TOOLBAR,
+                                   G_CALLBACK (gtk_toolbar_move_focus));
+
   widget_class->screen_changed = gtk_toolbar_screen_changed;
   widget_class->realize = gtk_toolbar_realize;
   widget_class->unrealize = gtk_toolbar_unrealize;
@@ -399,7 +410,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
    * Emitted when the orientation of the toolbar changes.
    */
   toolbar_signals[ORIENTATION_CHANGED] =
-    g_signal_new ("orientation-changed",
+    g_signal_new (I_("orientation-changed"),
                  G_OBJECT_CLASS_TYPE (klass),
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkToolbarClass, orientation_changed),
@@ -415,7 +426,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
    * Emitted when the style of the toolbar changes. 
    */
   toolbar_signals[STYLE_CHANGED] =
-    g_signal_new ("style-changed",
+    g_signal_new (I_("style-changed"),
                  G_OBJECT_CLASS_TYPE (klass),
                  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkToolbarClass, style_changed),
@@ -442,7 +453,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
    * Return value: return %TRUE if the signal was handled, %FALSE if not
    */
   toolbar_signals[POPUP_CONTEXT_MENU] =
-    g_signal_new ("popup_context_menu",
+    g_signal_new (I_("popup-context-menu"),
                  G_OBJECT_CLASS_TYPE (klass),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkToolbarClass, popup_context_menu),
@@ -451,25 +462,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
                  G_TYPE_BOOLEAN, 3,
                  G_TYPE_INT, G_TYPE_INT,
                  G_TYPE_INT);
-  /**
-   * GtkToolbar::move-focus:
-   * @toolbar: the #GtkToolbar which emitted the signal
-   * @dir: a #GtkDirection
-   *
-   * A keybinding signal used internally by GTK+. This signal can't
-   * be used in application code.
-   *
-   * Return value: %TRUE if the signal was handled, %FALSE if not
-   */
-  toolbar_signals[MOVE_FOCUS] =
-    _gtk_binding_signal_new ("move_focus",
-                            G_TYPE_FROM_CLASS (klass),
-                            G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                            G_CALLBACK (gtk_toolbar_move_focus),
-                            NULL, NULL,
-                            _gtk_marshal_BOOLEAN__ENUM,
-                            G_TYPE_BOOLEAN, 1,
-                            GTK_TYPE_DIRECTION_TYPE);
+
   /**
    * GtkToolbar::focus-home-or-end:
    * @toolbar: the #GtkToolbar which emitted the signal
@@ -481,114 +474,158 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
    * Return value: %TRUE if the signal was handled, %FALSE if not
    */
   toolbar_signals[FOCUS_HOME_OR_END] =
-    _gtk_binding_signal_new ("focus_home_or_end",
-                            G_OBJECT_CLASS_TYPE (klass),
-                            G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                            G_CALLBACK (gtk_toolbar_focus_home_or_end),
-                            NULL, NULL,
-                            _gtk_marshal_BOOLEAN__BOOLEAN,
-                            G_TYPE_BOOLEAN, 1,
-                            G_TYPE_BOOLEAN);
-  
+    g_signal_new_class_handler (I_("focus-home-or-end"),
+                                G_OBJECT_CLASS_TYPE (klass),
+                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                G_CALLBACK (gtk_toolbar_focus_home_or_end),
+                                NULL, NULL,
+                                _gtk_marshal_BOOLEAN__BOOLEAN,
+                                G_TYPE_BOOLEAN, 1,
+                                G_TYPE_BOOLEAN);
+
   /* properties */
-  g_object_class_install_property (gobject_class,
-                                  PROP_ORIENTATION,
-                                  g_param_spec_enum ("orientation",
-                                                     P_("Orientation"),
-                                                     P_("The orientation of the toolbar"),
-                                                     GTK_TYPE_ORIENTATION,
-                                                     GTK_ORIENTATION_HORIZONTAL,
-                                                     G_PARAM_READWRITE));
-  
+  g_object_class_override_property (gobject_class,
+                                    PROP_ORIENTATION,
+                                    "orientation");
+
   g_object_class_install_property (gobject_class,
                                   PROP_TOOLBAR_STYLE,
-                                  g_param_spec_enum ("toolbar_style",
+                                  g_param_spec_enum ("toolbar-style",
                                                      P_("Toolbar Style"),
                                                      P_("How to draw the toolbar"),
                                                      GTK_TYPE_TOOLBAR_STYLE,
-                                                     GTK_TOOLBAR_ICONS,
-                                                     G_PARAM_READWRITE));
+                                                     DEFAULT_TOOLBAR_STYLE,
+                                                     GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                   PROP_SHOW_ARROW,
-                                  g_param_spec_boolean ("show_arrow",
+                                  g_param_spec_boolean ("show-arrow",
                                                         P_("Show Arrow"),
                                                         P_("If an arrow should be shown if the toolbar doesn't fit"),
                                                         TRUE,
-                                                        G_PARAM_READWRITE));
+                                                        GTK_PARAM_READWRITE));
+  
+
+  /**
+   * GtkToolbar:tooltips:
+   * 
+   * If the tooltips of the toolbar should be active or not.
+   * 
+   * Since: 2.8
+   */
+  g_object_class_install_property (gobject_class,
+                                  PROP_TOOLTIPS,
+                                  g_param_spec_boolean ("tooltips",
+                                                        P_("Tooltips"),
+                                                        P_("If the tooltips of the toolbar should be active or not"),
+                                                        TRUE,
+                                                        GTK_PARAM_READWRITE));
   
+
+  /**
+   * GtkToolbar:icon-size:
+   *
+   * The size of the icons in a toolbar is normally determined by
+   * the toolbar-icon-size setting. When this property is set, it 
+   * overrides the setting. 
+   * 
+   * This should only be used for special-purpose toolbars, normal
+   * application toolbars should respect the user preferences for the
+   * size of icons.
+   *
+   * Since: 2.10
+   */
+  g_object_class_install_property (gobject_class,
+                                  PROP_ICON_SIZE,
+                                  g_param_spec_int ("icon-size",
+                                                    P_("Icon size"),
+                                                    P_("Size of icons in this toolbar"),
+                                                    0, G_MAXINT,
+                                                    DEFAULT_ICON_SIZE,
+                                                    GTK_PARAM_READWRITE));  
+
+  /**
+   * GtkToolbar:icon-size-set:
+   *
+   * Is %TRUE if the icon-size property has been set.
+   *
+   * Since: 2.10
+   */
+  g_object_class_install_property (gobject_class,
+                                  PROP_ICON_SIZE_SET,
+                                  g_param_spec_boolean ("icon-size-set",
+                                                        P_("Icon size set"),
+                                                        P_("Whether the icon-size property has been set"),
+                                                        FALSE,
+                                                        GTK_PARAM_READWRITE));  
+
   /* child properties */
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_EXPAND,
                                              g_param_spec_boolean ("expand", 
                                                                    P_("Expand"), 
                                                                    P_("Whether the item should receive extra space when the toolbar grows"),
-                                                                   TRUE,
-                                                                   G_PARAM_READWRITE));
+                                                                   FALSE,
+                                                                   GTK_PARAM_READWRITE));
   
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_HOMOGENEOUS,
                                              g_param_spec_boolean ("homogeneous", 
                                                                    P_("Homogeneous"), 
                                                                    P_("Whether the item should be the same size as other homogeneous items"),
-                                                                   TRUE,
-                                                                   G_PARAM_READWRITE));
+                                                                   FALSE,
+                                                                   GTK_PARAM_READWRITE));
   
   /* style properties */
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("space_size",
+                                          g_param_spec_int ("space-size",
                                                             P_("Spacer size"),
                                                             P_("Size of spacers"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_SPACE_SIZE,
-                                                            G_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE));
   
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("internal_padding",
+                                          g_param_spec_int ("internal-padding",
                                                             P_("Internal padding"),
                                                             P_("Amount of border space between the toolbar shadow and the buttons"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_IPADDING,
-                                                             G_PARAM_READABLE));
-  
+                                                             GTK_PARAM_READABLE));
+
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_enum ("space_style",
+                                           g_param_spec_int ("max-child-expand",
+                                                             P_("Maximum child expand"),
+                                                             P_("Maximum amount of space an expandable item will be given"),
+                                                             0,
+                                                             G_MAXINT,
+                                                             G_MAXINT,
+                                                             GTK_PARAM_READABLE));
+
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_enum ("space-style",
                                                              P_("Space style"),
                                                              P_("Whether spacers are vertical lines or just blank"),
                                                               GTK_TYPE_TOOLBAR_SPACE_STYLE,
                                                               DEFAULT_SPACE_STYLE,
-                                                              G_PARAM_READABLE));
+                                                              GTK_PARAM_READABLE));
   
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_enum ("button_relief",
+                                          g_param_spec_enum ("button-relief",
                                                              P_("Button relief"),
                                                              P_("Type of bevel around toolbar buttons"),
                                                               GTK_TYPE_RELIEF_STYLE,
                                                               GTK_RELIEF_NONE,
-                                                              G_PARAM_READABLE));
+                                                              GTK_PARAM_READABLE));
   gtk_widget_class_install_style_property (widget_class,
-                                           g_param_spec_enum ("shadow_type",
+                                           g_param_spec_enum ("shadow-type",
                                                               P_("Shadow type"),
                                                               P_("Style of bevel around the toolbar"),
                                                               GTK_TYPE_SHADOW_TYPE,
                                                               GTK_SHADOW_OUT,
-                                                              G_PARAM_READABLE));
-  
-  gtk_settings_install_property (g_param_spec_enum ("gtk-toolbar-style",
-                                                    P_("Toolbar style"),
-                                                    P_("Whether default toolbars have text only, text and icons, icons only, etc."),
-                                                    GTK_TYPE_TOOLBAR_STYLE,
-                                                    DEFAULT_TOOLBAR_STYLE,
-                                                    G_PARAM_READWRITE));
-  
-  gtk_settings_install_property (g_param_spec_enum ("gtk-toolbar-icon-size",
-                                                    P_("Toolbar icon size"),
-                                                    P_("Size of icons in default toolbars"),
-                                                    GTK_TYPE_ICON_SIZE,
-                                                    DEFAULT_ICON_SIZE,
-                                                    G_PARAM_READWRITE));  
-  
+                                                              GTK_PARAM_READABLE));
+
   binding_set = gtk_binding_set_by_class (klass);
   
   add_arrow_bindings (binding_set, GDK_Left, GTK_DIR_LEFT);
@@ -597,16 +634,16 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   add_arrow_bindings (binding_set, GDK_Down, GTK_DIR_DOWN);
   
   gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
-                                "focus_home_or_end", 1,
+                                "focus-home-or-end", 1,
                                G_TYPE_BOOLEAN, TRUE);
   gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
-                                "focus_home_or_end", 1,
+                                "focus-home-or-end", 1,
                                G_TYPE_BOOLEAN, TRUE);
   gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
-                                "focus_home_or_end", 1,
+                                "focus-home-or-end", 1,
                                G_TYPE_BOOLEAN, FALSE);
   gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
-                                "focus_home_or_end", 1,
+                                "focus-home-or-end", 1,
                                G_TYPE_BOOLEAN, FALSE);
   
   add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
@@ -615,12 +652,22 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate));  
 }
 
+static void
+toolbar_tool_shell_iface_init (GtkToolShellIface *iface)
+{
+  iface->get_icon_size    = toolbar_get_icon_size;
+  iface->get_orientation  = toolbar_get_orientation;
+  iface->get_style        = toolbar_get_style;
+  iface->get_relief_style = toolbar_get_relief_style;
+  iface->rebuild_menu     = toolbar_rebuild_menu;
+}
+
 static void
 gtk_toolbar_init (GtkToolbar *toolbar)
 {
   GtkToolbarPrivate *priv;
   
-  GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE);
   GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
   
   priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
@@ -628,12 +675,12 @@ gtk_toolbar_init (GtkToolbar *toolbar)
   toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
   toolbar->style = DEFAULT_TOOLBAR_STYLE;
   toolbar->icon_size = DEFAULT_ICON_SIZE;
+  priv->animation = DEFAULT_ANIMATION_STATE;
   toolbar->tooltips = gtk_tooltips_new ();
-  g_object_ref (toolbar->tooltips);
-  gtk_object_sink (GTK_OBJECT (toolbar->tooltips));
+  g_object_ref_sink (toolbar->tooltips);
   
   priv->arrow_button = gtk_toggle_button_new ();
-  g_signal_connect (priv->arrow_button, "button_press_event",
+  g_signal_connect (priv->arrow_button, "button-press-event",
                    G_CALLBACK (gtk_toolbar_arrow_button_press), toolbar);
   g_signal_connect (priv->arrow_button, "clicked",
                    G_CALLBACK (gtk_toolbar_arrow_button_clicked), toolbar);
@@ -672,7 +719,8 @@ gtk_toolbar_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      gtk_toolbar_set_orientation (toolbar, g_value_get_enum (value));
+      g_signal_emit (toolbar, toolbar_signals[ORIENTATION_CHANGED], 0,
+                     g_value_get_enum (value));
       break;
     case PROP_TOOLBAR_STYLE:
       gtk_toolbar_set_style (toolbar, g_value_get_enum (value));
@@ -680,6 +728,18 @@ gtk_toolbar_set_property (GObject      *object,
     case PROP_SHOW_ARROW:
       gtk_toolbar_set_show_arrow (toolbar, g_value_get_boolean (value));
       break;
+    case PROP_TOOLTIPS:
+      gtk_toolbar_set_tooltips (toolbar, g_value_get_boolean (value));
+      break;
+    case PROP_ICON_SIZE:
+      gtk_toolbar_set_icon_size (toolbar, g_value_get_int (value));
+      break;
+    case PROP_ICON_SIZE_SET:
+      if (g_value_get_boolean (value))
+       toolbar->icon_size_set = TRUE;
+      else
+       gtk_toolbar_unset_icon_size (toolbar);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -706,6 +766,15 @@ gtk_toolbar_get_property (GObject    *object,
     case PROP_SHOW_ARROW:
       g_value_set_boolean (value, priv->show_arrow);
       break;
+    case PROP_TOOLTIPS:
+      g_value_set_boolean (value, gtk_toolbar_get_tooltips (toolbar));
+      break;
+    case PROP_ICON_SIZE:
+      g_value_set_int (value, gtk_toolbar_get_icon_size (toolbar));
+      break;
+    case PROP_ICON_SIZE_SET:
+      g_value_set_boolean (value, toolbar->icon_size_set);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -717,7 +786,7 @@ gtk_toolbar_map (GtkWidget *widget)
 {
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
   
-  GTK_WIDGET_CLASS (parent_class)->map (widget);
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->map (widget);
   
   if (priv->event_window)
     gdk_window_show_unraised (priv->event_window);
@@ -731,7 +800,7 @@ gtk_toolbar_unmap (GtkWidget *widget)
   if (priv->event_window)
     gdk_window_hide (priv->event_window);
   
-  GTK_WIDGET_CLASS (parent_class)->unmap (widget);
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unmap (widget);
 }
 
 static void
@@ -782,9 +851,8 @@ gtk_toolbar_unrealize (GtkWidget *widget)
       gdk_window_destroy (priv->event_window);
       priv->event_window = NULL;
     }
-  
-  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
-    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize (widget);
 }
 
 static gint
@@ -799,7 +867,7 @@ gtk_toolbar_expose (GtkWidget      *widget,
   
   border_width = GTK_CONTAINER (widget)->border_width;
   
-  if (GTK_WIDGET_DRAWABLE (widget))
+  if (gtk_widget_is_drawable (widget))
     {
       gtk_paint_box (widget->style,
                     widget->window,
@@ -950,12 +1018,35 @@ gtk_toolbar_size_request (GtkWidget      *widget,
 }
 
 static gint
-position (gint from, gint to, gdouble elapsed)
+position (GtkToolbar *toolbar,
+          gint        from,
+          gint        to,
+          gdouble     elapsed)
 {
+  gint n_pixels;
+
+  if (! GTK_TOOLBAR_GET_PRIVATE (toolbar)->animation)
+    return to;
+
+  if (elapsed <= ACCEL_THRESHOLD)
+    {
+      n_pixels = SLIDE_SPEED * elapsed;
+    }
+  else
+    {
+      /* The formula is a second degree polynomial in
+       * @elapsed that has the line SLIDE_SPEED * @elapsed
+       * as tangent for @elapsed == ACCEL_THRESHOLD.
+       * This makes @n_pixels a smooth function of elapsed time.
+       */
+      n_pixels = (SLIDE_SPEED / ACCEL_THRESHOLD) * elapsed * elapsed -
+       SLIDE_SPEED * elapsed + SLIDE_SPEED * ACCEL_THRESHOLD;
+    }
+
   if (to > from)
-    return MIN (from + SLIDE_SPEED * elapsed, to);
+    return MIN (from + n_pixels, to);
   else
-    return MAX (from - SLIDE_SPEED * elapsed, to);
+    return MAX (from - n_pixels, to);
 }
 
 static void
@@ -966,13 +1057,15 @@ compute_intermediate_allocation (GtkToolbar          *toolbar,
 {
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   gdouble elapsed = g_timer_elapsed (priv->timer, NULL);
-  
-  intermediate->x = position (start->x, goal->x, elapsed);
-  intermediate->y = position (start->y, goal->y, elapsed);
-  intermediate->width =
-    position (start->x + start->width, goal->x + goal->width, elapsed) - intermediate->x;
-  intermediate->height =
-    position (start->y + start->height, goal->y + goal->height, elapsed) - intermediate->y;
+
+  intermediate->x      = position (toolbar, start->x, goal->x, elapsed);
+  intermediate->y      = position (toolbar, start->y, goal->y, elapsed);
+  intermediate->width  = position (toolbar, start->x + start->width,
+                                   goal->x + goal->width,
+                                   elapsed) - intermediate->x;
+  intermediate->height = position (toolbar, start->y + start->height,
+                                   goal->y + goal->height,
+                                   elapsed) - intermediate->y;
 }
 
 static void
@@ -1027,8 +1120,6 @@ slide_idle_handler (gpointer data)
   GtkToolbarPrivate *priv;
   GList *list;
   
-  GDK_THREADS_ENTER ();
-  
   priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   
   if (priv->need_sync)
@@ -1096,15 +1187,15 @@ slide_idle_handler (gpointer data)
        {
          gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
          
-         GDK_THREADS_LEAVE ();
          return TRUE;
        }
     }
   
+  gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
+
   priv->is_sliding = FALSE;
   priv->idle_id = 0;
 
-  GDK_THREADS_LEAVE();
   return FALSE;
 }
 
@@ -1134,11 +1225,14 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
    * item into content->start_allocation. For items that haven't
    * been allocated yet, we calculate their position and save that
    * in start_allocatino along with zero width and zero height.
+   *
+   * FIXME: It would be nice if we could share this code with
+   * the equivalent in gtk_widget_size_allocate().
    */
   priv->is_sliding = TRUE;
   
   if (!priv->idle_id)
-    priv->idle_id = g_idle_add (slide_idle_handler, toolbar);
+    priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar);
   
   rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
   vertical = (toolbar->orientation == GTK_ORIENTATION_VERTICAL);
@@ -1204,7 +1298,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
     }
 
   /* This resize will run before the first idle handler. This
-   * will make sure that items get the right goal allocatiuon
+   * will make sure that items get the right goal allocation
    * so that the idle handler will not immediately return
    * FALSE
    */
@@ -1246,6 +1340,94 @@ gtk_toolbar_stop_sliding (GtkToolbar *toolbar)
     }
 }
 
+static void
+remove_item (GtkWidget *menu_item,
+            gpointer   data)
+{
+  gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item);
+}
+
+static void
+menu_deactivated (GtkWidget  *menu,
+                 GtkToolbar *toolbar)
+{
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
+}
+
+static void
+menu_detached (GtkWidget  *toolbar,
+              GtkMenu    *menu)
+{
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+  priv->menu = NULL;
+}
+
+static void
+rebuild_menu (GtkToolbar *toolbar)
+{
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+  GList *list, *children;
+  
+  if (!priv->menu)
+    {
+      priv->menu = GTK_MENU (gtk_menu_new());
+      gtk_menu_attach_to_widget (priv->menu,
+                                GTK_WIDGET (toolbar),
+                                menu_detached);
+
+      g_signal_connect (priv->menu, "deactivate",
+                        G_CALLBACK (menu_deactivated), toolbar);
+    }
+
+  gtk_container_foreach (GTK_CONTAINER (priv->menu), remove_item, NULL);
+  
+  for (list = priv->content; list != NULL; list = list->next)
+    {
+      ToolbarContent *content = list->data;
+      
+      if (toolbar_content_get_state (content) == OVERFLOWN &&
+         !toolbar_content_is_placeholder (content))
+       {
+         GtkWidget *menu_item = toolbar_content_retrieve_menu_item (content);
+         
+         if (menu_item)
+           {
+             g_assert (GTK_IS_MENU_ITEM (menu_item));
+             gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
+           }
+       }
+    }
+
+  /* Remove leading and trailing separator items */
+  children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
+  
+  list = children;
+  while (list && GTK_IS_SEPARATOR_MENU_ITEM (list->data))
+    {
+      GtkWidget *child = list->data;
+      
+      gtk_container_remove (GTK_CONTAINER (priv->menu), child);
+      list = list->next;
+    }
+  g_list_free (children);
+
+  /* Regenerate the list of children so we don't try to remove items twice */
+  children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
+
+  list = g_list_last (children);
+  while (list && GTK_IS_SEPARATOR_MENU_ITEM (list->data))
+    {
+      GtkWidget *child = list->data;
+
+      gtk_container_remove (GTK_CONTAINER (priv->menu), child);
+      list = list->prev;
+    }
+  g_list_free (children);
+
+  priv->need_rebuild = FALSE;
+}
+
 static void
 gtk_toolbar_size_allocate (GtkWidget     *widget,
                           GtkAllocation *allocation)
@@ -1270,6 +1452,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   gboolean size_changed;
   gdouble elapsed;
   GtkAllocation item_area;
+  GtkShadowType shadow_type;
   
   size_changed = FALSE;
   if (widget->allocation.x != allocation->x            ||
@@ -1301,13 +1484,15 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button),
                                    &arrow_requisition);
   
+  shadow_type = get_shadow_type (toolbar);
+
   if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       available_size = size = allocation->width - 2 * border_width;
       short_size = allocation->height - 2 * border_width;
       arrow_size = arrow_requisition.width;
       
-      if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+      if (shadow_type != GTK_SHADOW_NONE)
        {
          available_size -= 2 * widget->style->xthickness;
          short_size -= 2 * widget->style->ythickness;
@@ -1319,7 +1504,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       short_size = allocation->width - 2 * border_width;
       arrow_size = arrow_requisition.height;
       
-      if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+      if (shadow_type != GTK_SHADOW_NONE)
        {
          available_size -= 2 * widget->style->ythickness;
          short_size -= 2 * widget->style->xthickness;
@@ -1331,22 +1516,38 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   new_states = g_new0 (ItemState, n_items);
   
   needed_size = 0;
+  need_arrow = FALSE;
   for (list = priv->content; list != NULL; list = list->next)
     {
       ToolbarContent *content = list->data;
       
       if (toolbar_content_visible (content, toolbar))
-       needed_size += get_item_size (toolbar, content);
+       {
+         needed_size += get_item_size (toolbar, content);
+
+         /* Do we need an arrow?
+          *
+          * Assume we don't, and see if any non-separator item with a
+          * proxy menu item is then going to overflow.
+          */
+         if (needed_size > available_size                      &&
+             !need_arrow                                       &&
+             priv->show_arrow                                  &&
+             priv->api_mode == NEW_API                         &&
+             toolbar_content_has_proxy_menu_item (content)     &&
+             !toolbar_content_is_separator (content))
+           {
+             need_arrow = TRUE;
+           }
+       }
     }
   
-  need_arrow = (needed_size > available_size) && priv->show_arrow && priv->api_mode == NEW_API;
-  
   if (need_arrow)
     size = available_size - arrow_size;
   else
     size = available_size;
   
-  /* calculate widths of items */
+  /* calculate widths and states of items */
   overflowing = FALSE;
   for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
     {
@@ -1378,7 +1579,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   if (need_arrow)
     {
       arrow_allocation.width = arrow_size;
-      arrow_allocation.height = short_size;
+      arrow_allocation.height = MAX (short_size, 1);
     }
   
   /* expand expandable items */
@@ -1389,7 +1590,9 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
    */
   if (!overflowing)
     {
+      gint max_child_expand;
       n_expand_items = 0;
+      
       for (i = 0, list = priv->content; list != NULL; list = list->next, ++i)
        {
          ToolbarContent *content = list->data;
@@ -1398,6 +1601,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
            n_expand_items++;
        }
       
+      max_child_expand = get_max_child_expand (toolbar);
       for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
        {
          ToolbarContent *content = list->data;
@@ -1407,7 +1611,10 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
              gint extra = size / n_expand_items;
              if (size % n_expand_items != 0)
                extra++;
-             
+
+              if (extra > max_child_expand)
+                extra = max_child_expand;
+
              allocations[i].width += extra;
              size -= extra;
              n_expand_items--;
@@ -1475,7 +1682,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       allocations[i].x += allocation->x;
       allocations[i].y += allocation->y;
       
-      if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+      if (shadow_type != GTK_SHADOW_NONE)
        {
          allocations[i].x += widget->style->xthickness;
          allocations[i].y += widget->style->ythickness;
@@ -1487,7 +1694,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       arrow_allocation.x += allocation->x;
       arrow_allocation.y += allocation->y;
       
-      if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+      if (shadow_type != GTK_SHADOW_NONE)
        {
          arrow_allocation.x += widget->style->xthickness;
          arrow_allocation.y += widget->style->ythickness;
@@ -1496,7 +1703,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
 
   item_area.x += allocation->x;
   item_area.y += allocation->y;
-  if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+  if (shadow_type != GTK_SHADOW_NONE)
     {
       item_area.x += widget->style->xthickness;
       item_area.y += widget->style->ythickness;
@@ -1510,7 +1717,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       if (toolbar_content_get_state (content) == NORMAL &&
          new_states[i] != NORMAL)
        {
-         /* an item disappeared, begin sliding */
+         /* an item disappeared and we didn't change size, so begin sliding */
          if (!size_changed && priv->api_mode == NEW_API)
            gtk_toolbar_begin_sliding (toolbar);
        }
@@ -1536,7 +1743,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
          new_states[i] == NORMAL)
        {
          GtkAllocation alloc;
-         GtkAllocation start_allocation;
+         GtkAllocation start_allocation = { 0, };
          GtkAllocation goal_allocation;
 
          if (priv->is_sliding)
@@ -1556,7 +1763,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
              alloc = allocations[i];
            }
 
-         if (alloc.width == 0 || alloc.height == 0)
+         if (alloc.width <= 0 || alloc.height <= 0)
            {
              toolbar_content_set_child_visible (content, toolbar, FALSE);
            }
@@ -1582,6 +1789,9 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       toolbar_content_set_state (content, new_states[i]);
     }
   
+  if (priv->menu && priv->need_rebuild)
+    rebuild_menu (toolbar);
+  
   if (need_arrow)
     {
       gtk_widget_size_allocate (GTK_WIDGET (priv->arrow_button),
@@ -1591,8 +1801,11 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   else
     {
       gtk_widget_hide (GTK_WIDGET (priv->arrow_button));
+
+      if (priv->menu && gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
+       gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
     }
-  
+
   g_free (allocations);
   g_free (new_states);
 }
@@ -1601,10 +1814,16 @@ static void
 gtk_toolbar_update_button_relief (GtkToolbar *toolbar)
 {
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+  GtkReliefStyle relief;
+
+  relief = get_button_relief (toolbar);
+
+  if (relief != gtk_button_get_relief (GTK_BUTTON (priv->arrow_button)))
+    {
+      gtk_toolbar_reconfigured (toolbar);
   
-  gtk_toolbar_reconfigured (toolbar);
-  
-  gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), get_button_relief (toolbar));
+      gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), relief);
+    }
 }
 
 static void
@@ -1614,7 +1833,7 @@ gtk_toolbar_style_set (GtkWidget *widget,
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
   
   priv->max_homogeneous_pixels = -1;
-  
+
   if (GTK_WIDGET_REALIZED (widget))
     gtk_style_set_background (widget->style, widget->window, widget->state);
   
@@ -1689,7 +1908,7 @@ gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
       if (GTK_CONTAINER (toolbar)->focus_child == child)
        break;
       
-      if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
+      if (gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
        break;
     }
   
@@ -1701,19 +1920,20 @@ gtk_toolbar_focus_home_or_end (GtkToolbar *toolbar,
 /* Keybinding handler. This function is called when the user presses
  * Ctrl TAB or an arrow key.
  */
-static gboolean
-gtk_toolbar_move_focus (GtkToolbar       *toolbar,
+static void
+gtk_toolbar_move_focus (GtkWidget        *widget,
                        GtkDirectionType  dir)
 {
+  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
+  GtkContainer *container = GTK_CONTAINER (toolbar);
   GList *list;
   gboolean try_focus = FALSE;
   GList *children;
-  GtkContainer *container = GTK_CONTAINER (toolbar);
-  
+
   if (container->focus_child &&
       gtk_widget_child_focus (container->focus_child, dir))
     {
-      return TRUE;
+      return;
     }
   
   children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
@@ -1722,7 +1942,7 @@ gtk_toolbar_move_focus (GtkToolbar       *toolbar,
     {
       GtkWidget *child = list->data;
       
-      if (try_focus && GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
+      if (try_focus && gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
        break;
       
       if (child == GTK_CONTAINER (toolbar)->focus_child)
@@ -1730,8 +1950,6 @@ gtk_toolbar_move_focus (GtkToolbar       *toolbar,
     }
   
   g_list_free (children);
-  
-  return FALSE;
 }
 
 /* The focus handler for the toolbar. It called when the user presses
@@ -1743,7 +1961,8 @@ gtk_toolbar_focus (GtkWidget        *widget,
 {
   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
   GList *children, *list;
-  
+  gboolean result = FALSE;
+
   /* if focus is already somewhere inside the toolbar then return FALSE.
    * The only way focus can stay inside the toolbar is when the user presses
    * arrow keys or Ctrl TAB (both of which are handled by the
@@ -1751,20 +1970,30 @@ gtk_toolbar_focus (GtkWidget        *widget,
    */
   if (GTK_CONTAINER (widget)->focus_child)
     return FALSE;
-  
+
   children = gtk_toolbar_list_children_in_focus_order (toolbar, dir);
-  
+
   for (list = children; list != NULL; list = list->next)
     {
       GtkWidget *child = list->data;
       
-      if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
-       return TRUE;
+      if (gtk_widget_get_mapped (child) && gtk_widget_child_focus (child, dir))
+       {
+         result = TRUE;
+         break;
+       }
     }
-  
+
   g_list_free (children);
-  
-  return FALSE;
+
+  return result;
+}
+
+static GtkSettings *
+toolbar_get_settings (GtkToolbar *toolbar)
+{
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+  return priv->settings;
 }
 
 static void
@@ -1773,27 +2002,50 @@ style_change_notify (GtkToolbar *toolbar)
   if (!toolbar->style_set)
     {
       /* pretend it was set, then unset, thus reverting to new default */
-      toolbar->style_set = TRUE; 
+      toolbar->style_set = TRUE;
       gtk_toolbar_unset_style (toolbar);
     }
 }
 
 static void
 icon_size_change_notify (GtkToolbar *toolbar)
-{ 
+{
   if (!toolbar->icon_size_set)
     {
       /* pretend it was set, then unset, thus reverting to new default */
-      toolbar->icon_size_set = TRUE; 
+      toolbar->icon_size_set = TRUE;
       gtk_toolbar_unset_icon_size (toolbar);
     }
 }
 
-static GtkSettings *
-toolbar_get_settings (GtkToolbar *toolbar)
+static void
+animation_change_notify (GtkToolbar *toolbar)
 {
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  return priv->settings;
+  GtkSettings *settings = toolbar_get_settings (toolbar);
+  gboolean animation;
+
+  if (settings)
+    g_object_get (settings,
+                  "gtk-enable-animations", &animation,
+                  NULL);
+  else
+    animation = DEFAULT_ANIMATION_STATE;
+
+  priv->animation = animation;
+}
+
+static void
+settings_change_notify (GtkSettings      *settings,
+                        const GParamSpec *pspec,
+                        GtkToolbar       *toolbar)
+{
+  if (! strcmp (pspec->name, "gtk-toolbar-style"))
+    style_change_notify (toolbar);
+  else if (! strcmp (pspec->name, "gtk-toolbar-icon-size"))
+    icon_size_change_notify (toolbar);
+  else if (! strcmp (pspec->name, "gtk-enable-animations"))
+    animation_change_notify (toolbar);
 }
 
 static void
@@ -1815,33 +2067,26 @@ gtk_toolbar_screen_changed (GtkWidget *widget,
   
   if (old_settings)
     {
-      g_signal_handler_disconnect (old_settings, toolbar->style_set_connection);
-      g_signal_handler_disconnect (old_settings, toolbar->icon_size_connection);
-      
+      g_signal_handler_disconnect (old_settings, priv->settings_connection);
+
       g_object_unref (old_settings);
     }
-  
+
   if (settings)
     {
-      toolbar->style_set_connection =
-       g_signal_connect_swapped (settings,
-                                 "notify::gtk-toolbar-style",
-                                 G_CALLBACK (style_change_notify),
-                                 toolbar);
-      toolbar->icon_size_connection =
-       g_signal_connect_swapped (settings,
-                                 "notify::gtk-toolbar-icon-size",
-                                 G_CALLBACK (icon_size_change_notify),
-                                 toolbar);
-      
-      g_object_ref (settings);
-      priv->settings = settings;
+      priv->settings_connection =
+       g_signal_connect (settings, "notify",
+                          G_CALLBACK (settings_change_notify),
+                          toolbar);
+
+      priv->settings = g_object_ref (settings);
     }
   else
     priv->settings = NULL;
-  
+
   style_change_notify (toolbar);
   icon_size_change_notify (toolbar);
+  animation_change_notify (toolbar);
 }
 
 static int
@@ -2008,12 +2253,13 @@ logical_to_physical (GtkToolbar *toolbar,
 /**
  * gtk_toolbar_set_drop_highlight_item:
  * @toolbar: a #GtkToolbar
- * @tool_item: a #GtkToolItem, or %NULL to turn of highlighting
- * @index: a position on @toolbar
- * 
+ * @tool_item: (allow-none): a #GtkToolItem, or %NULL to turn of highlighting
+ * @index_: a position on @toolbar
+ *
  * Highlights @toolbar to give an idea of what it would look like
- * if @item was added to @toolbar at position indicated by @index. If @item
- * is %NULL, highlighting is turned off. In that case @index is ignored.
+ * if @item was added to @toolbar at the position indicated by @index_.
+ * If @item is %NULL, highlighting is turned off. In that case @index_ 
+ * is ignored.
  *
  * The @tool_item passed to this function must not be part of any widget
  * hierarchy. When an item is set as drop highlight item it can not
@@ -2025,7 +2271,7 @@ logical_to_physical (GtkToolbar *toolbar,
 void
 gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
                                     GtkToolItem *tool_item,
-                                    gint         index)
+                                    gint         index_)
 {
   ToolbarContent *content;
   GtkToolbarPrivate *priv;
@@ -2056,16 +2302,15 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
     }
   
   n_items = gtk_toolbar_get_n_items (toolbar);
-  if (index < 0 || index > n_items)
-    index = n_items;
+  if (index_ < 0 || index_ > n_items)
+    index_ = n_items;
   
   if (tool_item != priv->highlight_tool_item)
     {
       if (priv->highlight_tool_item)
        g_object_unref (priv->highlight_tool_item);
       
-      g_object_ref (tool_item);
-      gtk_object_sink (GTK_OBJECT (tool_item));
+      g_object_ref_sink (tool_item);
       
       priv->highlight_tool_item = tool_item;
       
@@ -2073,15 +2318,15 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
                             GTK_WIDGET (toolbar));
     }
   
-  index = logical_to_physical (toolbar, index);
+  index_ = logical_to_physical (toolbar, index_);
   
-  content = g_list_nth_data (priv->content, index);
+  content = g_list_nth_data (priv->content, index_);
   
-  if (index > 0)
+  if (index_ > 0)
     {
       ToolbarContent *prev_content;
       
-      prev_content = g_list_nth_data (priv->content, index - 1);
+      prev_content = g_list_nth_data (priv->content, index_ - 1);
       
       if (prev_content && toolbar_content_is_placeholder (prev_content))
        content = prev_content;
@@ -2095,7 +2340,7 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
 
       content = toolbar_content_new_tool_item (toolbar,
                                               GTK_TOOL_ITEM (placeholder),
-                                              TRUE, index);
+                                              TRUE, index_);
       gtk_widget_show (placeholder);
     }
   
@@ -2105,6 +2350,7 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar  *toolbar,
   gtk_widget_size_request (GTK_WIDGET (priv->highlight_tool_item),
                           &requisition);
 
+  toolbar_content_set_expand (content, gtk_tool_item_get_expand (tool_item));
   
   restart_sliding = FALSE;
   toolbar_content_size_request (content, toolbar, &old_requisition);
@@ -2218,13 +2464,8 @@ static void
 gtk_toolbar_add (GtkContainer *container,
                 GtkWidget    *widget)
 {
-  GtkToolbar *toolbar;
-  
-  g_return_if_fail (GTK_IS_TOOLBAR (container));
-  g_return_if_fail (widget != NULL);
-  
-  toolbar = GTK_TOOLBAR (container);
-  
+  GtkToolbar *toolbar = GTK_TOOLBAR (container);
+
   if (GTK_IS_TOOL_ITEM (widget))
     gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (widget), -1);
   else
@@ -2235,17 +2476,11 @@ static void
 gtk_toolbar_remove (GtkContainer *container,
                    GtkWidget    *widget)
 {
-  GtkToolbar *toolbar;
-  GtkToolbarPrivate *priv;
+  GtkToolbar *toolbar = GTK_TOOLBAR (container);
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   ToolbarContent *content_to_remove;
   GList *list;
-  
-  g_return_if_fail (GTK_IS_TOOLBAR (container));
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  
-  toolbar = GTK_TOOLBAR (container);
-  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  
+
   content_to_remove = NULL;
   for (list = priv->content; list != NULL; list = list->next)
     {
@@ -2289,14 +2524,14 @@ gtk_toolbar_forall (GtkContainer *container,
          GtkWidget *child = toolbar_content_get_widget (content);
          
          if (child)
-           (*callback) (child, callback_data);
+           callback (child, callback_data);
        }
       
       list = next;
     }
   
   if (include_internals)
-    (* callback) (priv->arrow_button, callback_data);
+    callback (priv->arrow_button, callback_data);
 }
 
 static GType
@@ -2355,7 +2590,7 @@ gtk_toolbar_real_style_changed (GtkToolbar     *toolbar,
       gtk_toolbar_reconfigured (toolbar);
       
       gtk_widget_queue_resize (GTK_WIDGET (toolbar));
-      g_object_notify (G_OBJECT (toolbar), "toolbar_style");
+      g_object_notify (G_OBJECT (toolbar), "toolbar-style");
     }
 }
 
@@ -2370,18 +2605,35 @@ menu_position_func (GtkMenu  *menu,
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   GtkRequisition req;
   GtkRequisition menu_req;
+  GdkRectangle monitor;
+  gint monitor_num;
+  GdkScreen *screen;
   
-  gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
   gtk_widget_size_request (priv->arrow_button, &req);
   gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
   
+  screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+  monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window);
+  if (monitor_num < 0)
+    monitor_num = 0;
+  gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+  gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
   if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      *y += priv->arrow_button->allocation.height;
       if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) 
        *x += priv->arrow_button->allocation.width - req.width;
       else 
        *x += req.width - menu_req.width;
+
+      if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height)
+       *y += priv->arrow_button->allocation.height;
+      else if ((*y - menu_req.height) >= monitor.y)
+       *y -= menu_req.height;
+      else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y)
+       *y += priv->arrow_button->allocation.height;
+      else
+       *y -= menu_req.height;
     }
   else 
     {
@@ -2389,33 +2641,13 @@ menu_position_func (GtkMenu  *menu,
        *x += priv->arrow_button->allocation.width;
       else 
        *x -= menu_req.width;
-      *y += priv->arrow_button->allocation.height - req.height;      
-    }
-  
-  *push_in = TRUE;
-}
 
-static void
-menu_deactivated (GtkWidget  *menu,
-                 GtkToolbar *toolbar)
-{
-  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
-}
+      if (*y + menu_req.height > monitor.y + monitor.height &&
+         *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y)
+       *y += priv->arrow_button->allocation.height - menu_req.height;
+    }
 
-static void
-menu_detached (GtkWidget  *toolbar,
-              GtkMenu    *menu)
-{
-  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  priv->menu = NULL;
-}
-
-static void
-remove_item (GtkWidget *menu_item,
-            gpointer   data)
-{
-  gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item);
+  *push_in = FALSE;
 }
 
 static void
@@ -2423,36 +2655,8 @@ show_menu (GtkToolbar     *toolbar,
           GdkEventButton *event)
 {
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  GList *list;
-  
-  if (priv->menu)
-    {
-      gtk_container_foreach (GTK_CONTAINER (priv->menu), remove_item, NULL);
-      gtk_widget_destroy (GTK_WIDGET (priv->menu));
-    }
 
-  priv->menu = GTK_MENU (gtk_menu_new ());
-  gtk_menu_attach_to_widget (priv->menu,
-                            GTK_WIDGET (toolbar),
-                            menu_detached);
-  g_signal_connect (priv->menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
-
-  for (list = priv->content; list != NULL; list = list->next)
-    {
-      ToolbarContent *content = list->data;
-      
-      if (toolbar_content_get_state (content) == OVERFLOWN &&
-         !toolbar_content_is_placeholder (content))
-       {
-         GtkWidget *menu_item = toolbar_content_retrieve_menu_item (content);
-         
-         if (menu_item)
-           {
-             g_assert (GTK_IS_MENU_ITEM (menu_item));
-             gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
-           }
-       }
-    }
+  rebuild_menu (toolbar);
 
   gtk_widget_show_all (GTK_WIDGET (priv->menu));
 
@@ -2469,9 +2673,9 @@ gtk_toolbar_arrow_button_clicked (GtkWidget  *button,
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);  
   
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)) &&
-      (!priv->menu || !GTK_WIDGET_VISIBLE (GTK_WIDGET (priv->menu))))
+      (!priv->menu || !gtk_widget_get_visible (GTK_WIDGET (priv->menu))))
     {
-      /* We only get here when the button is clicked with the keybaord,
+      /* We only get here when the button is clicked with the keyboard,
        * because mouse button presses result in the menu being shown so
        * that priv->menu would be non-NULL and visible.
        */
@@ -2618,8 +2822,10 @@ gtk_toolbar_get_item_index (GtkToolbar  *toolbar,
  * gtk_toolbar_set_orientation:
  * @toolbar: a #GtkToolbar.
  * @orientation: a new #GtkOrientation.
- * 
+ *
  * Sets whether a toolbar should appear horizontally or vertically.
+ *
+ * Deprecated: 2.16: Use gtk_orientable_set_orientation() instead.
  **/
 void
 gtk_toolbar_set_orientation (GtkToolbar     *toolbar,
@@ -2633,11 +2839,13 @@ gtk_toolbar_set_orientation (GtkToolbar     *toolbar,
 /**
  * gtk_toolbar_get_orientation:
  * @toolbar: a #GtkToolbar
- * 
+ *
  * Retrieves the current orientation of the toolbar. See
  * gtk_toolbar_set_orientation().
  *
  * Return value: the orientation
+ *
+ * Deprecated: 2.16: Use gtk_orientable_get_orientation() instead.
  **/
 GtkOrientation
 gtk_toolbar_get_orientation (GtkToolbar *toolbar)
@@ -2719,6 +2927,9 @@ gtk_toolbar_unset_style (GtkToolbar *toolbar)
  * @enable: set to %FALSE to disable the tooltips, or %TRUE to enable them.
  * 
  * Sets if the tooltips of a toolbar should be active or not.
+ *
+ * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
+ * is now used instead.
  **/
 void
 gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
@@ -2730,6 +2941,8 @@ gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
     gtk_tooltips_enable (toolbar->tooltips);
   else
     gtk_tooltips_disable (toolbar->tooltips);
+
+  g_object_notify (G_OBJECT (toolbar), "tooltips");
 }
 
 /**
@@ -2740,13 +2953,16 @@ gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
  * gtk_toolbar_set_tooltips().
  *
  * Return value: %TRUE if tooltips are enabled
+ *
+ * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
+ * is now used instead.
  **/
 gboolean
 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
 {
   g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
   
-  return toolbar->tooltips->enabled;
+  return TRUE;
 }
 
 /**
@@ -2779,11 +2995,11 @@ gtk_toolbar_get_n_items (GtkToolbar *toolbar)
  * @toolbar: a #GtkToolbar
  * @n: A position on the toolbar
  *
- * Returns the @n<!-- -->'s item on @toolbar, or %NULL if the
+ * Returns the @n<!-- -->'th item on @toolbar, or %NULL if the
  * toolbar does not contain an @n<!-- -->'th item.
  * 
  * Return value: The @n<!-- -->'th #GtkToolItem on @toolbar, or %NULL if there
- * isn't an @n<!-- -->th item.
+ * isn't an @n<!-- -->'th item.
  * 
  * Since: 2.4
  **/
@@ -2819,9 +3035,10 @@ gtk_toolbar_get_nth_item (GtkToolbar *toolbar,
  * gtk_toolbar_get_icon_size:
  * @toolbar: a #GtkToolbar
  *
- * Retrieves the icon size fo the toolbar. See gtk_toolbar_set_icon_size().
+ * Retrieves the icon size for the toolbar. See gtk_toolbar_set_icon_size().
  *
- * Return value: the current icon size for the icons on the toolbar.
+ * Return value: (type int): the current icon size for the icons on
+ * the toolbar.
  **/
 GtkIconSize
 gtk_toolbar_get_icon_size (GtkToolbar *toolbar)
@@ -2881,7 +3098,7 @@ gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
        gtk_widget_hide (priv->arrow_button);
       
       gtk_widget_queue_resize (GTK_WIDGET (toolbar));      
-      g_object_notify (G_OBJECT (toolbar), "show_arrow");
+      g_object_notify (G_OBJECT (toolbar), "show-arrow");
     }
 }
 
@@ -2890,9 +3107,9 @@ gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
  * @toolbar: a #GtkToolbar
  * 
  * Returns whether the toolbar has an overflow menu.
- * See gtk_toolbar_set_show_arrow()
+ * See gtk_toolbar_set_show_arrow().
  * 
- * Return value: 
+ * Return value: %TRUE if the toolbar has an overflow menu.
  * 
  * Since: 2.4
  **/
@@ -2951,6 +3168,9 @@ gtk_toolbar_finalize (GObject *object)
   if (toolbar->tooltips)
     g_object_unref (toolbar->tooltips);
   
+  if (priv->arrow_button)
+    gtk_widget_unparent (priv->arrow_button);
+
   for (list = priv->content; list != NULL; list = list->next)
     {
       ToolbarContent *content = list->data;
@@ -2968,36 +3188,43 @@ gtk_toolbar_finalize (GObject *object)
   
   if (priv->idle_id)
     g_source_remove (priv->idle_id);
-  
-  G_OBJECT_CLASS (parent_class)->finalize (object);
-}
 
-/*
- * Deprecated API
- */
+  G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object);
+}
 
 /**
  * gtk_toolbar_set_icon_size:
  * @toolbar: A #GtkToolbar
- * @icon_size: The #GtkIconSize that stock icons in the toolbar shall have.
+ * @icon_size: (type int): The #GtkIconSize that stock icons in the
+ *     toolbar shall have.
  *
  * This function sets the size of stock icons in the toolbar. You
  * can call it both before you add the icons and after they've been
  * added. The size you set will override user preferences for the default
  * icon size.
+ * 
+ * This should only be used for special-purpose toolbars, normal
+ * application toolbars should respect the user preferences for the
+ * size of icons.
  **/
 void
 gtk_toolbar_set_icon_size (GtkToolbar  *toolbar,
                           GtkIconSize  icon_size)
 {
   g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
+  g_return_if_fail (icon_size != GTK_ICON_SIZE_INVALID);
   
-  toolbar->icon_size_set = TRUE;
-  
+  if (!toolbar->icon_size_set)
+    {
+      toolbar->icon_size_set = TRUE;  
+      g_object_notify (G_OBJECT (toolbar), "icon-size-set");
+    }
+
   if (toolbar->icon_size == icon_size)
     return;
   
   toolbar->icon_size = icon_size;
+  g_object_notify (G_OBJECT (toolbar), "icon-size");
   
   gtk_toolbar_reconfigured (toolbar);
   
@@ -3032,12 +3259,20 @@ gtk_toolbar_unset_icon_size (GtkToolbar *toolbar)
        size = DEFAULT_ICON_SIZE;
       
       if (size != toolbar->icon_size)
-       gtk_toolbar_set_icon_size (toolbar, size);
+       {
+         gtk_toolbar_set_icon_size (toolbar, size);
+         g_object_notify (G_OBJECT (toolbar), "icon-size");      
+       }
       
       toolbar->icon_size_set = FALSE;
+      g_object_notify (G_OBJECT (toolbar), "icon-size-set");      
     }
 }
 
+/*
+ * Deprecated API
+ */
+
 /**
  * gtk_toolbar_append_item:
  * @toolbar: a #GtkToolbar.
@@ -3047,14 +3282,16 @@ gtk_toolbar_unset_icon_size (GtkToolbar *toolbar)
  * @icon: a #GtkWidget that should be used as the button's icon.
  * @callback: the function to be executed when the button is pressed.
  * @user_data: a pointer to any data you wish to be passed to the callback.
- * 
+ *
  * Inserts a new item into the toolbar. You must specify the position
  * in the toolbar where it will be inserted.
  *
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar item as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget *
 gtk_toolbar_append_item (GtkToolbar    *toolbar,
@@ -3062,7 +3299,7 @@ gtk_toolbar_append_item (GtkToolbar    *toolbar,
                         const char    *tooltip_text,
                         const char    *tooltip_private_text,
                         GtkWidget     *icon,
-                        GtkSignalFunc  callback,
+                        GCallback      callback,
                         gpointer       user_data)
 {
   return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
@@ -3081,13 +3318,15 @@ gtk_toolbar_append_item (GtkToolbar    *toolbar,
  * @icon: a #GtkWidget that should be used as the button's icon.
  * @callback: the function to be executed when the button is pressed.
  * @user_data: a pointer to any data you wish to be passed to the callback.
- * 
+ *
  * Adds a new button to the beginning (top or left edges) of the given toolbar.
  *
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar item as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget *
 gtk_toolbar_prepend_item (GtkToolbar    *toolbar,
@@ -3095,7 +3334,7 @@ gtk_toolbar_prepend_item (GtkToolbar    *toolbar,
                          const char    *tooltip_text,
                          const char    *tooltip_private_text,
                          GtkWidget     *icon,
-                         GtkSignalFunc  callback,
+                         GCallback      callback,
                          gpointer       user_data)
 {
   return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
@@ -3115,14 +3354,16 @@ gtk_toolbar_prepend_item (GtkToolbar    *toolbar,
  * @callback: the function to be executed when the button is pressed.
  * @user_data: a pointer to any data you wish to be passed to the callback.
  * @position: the number of widgets to insert this item after.
- * 
+ *
  * Inserts a new item into the toolbar. You must specify the position in the
  * toolbar where it will be inserted.
  *
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar item as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget *
 gtk_toolbar_insert_item (GtkToolbar    *toolbar,
@@ -3130,7 +3371,7 @@ gtk_toolbar_insert_item (GtkToolbar    *toolbar,
                         const char    *tooltip_text,
                         const char    *tooltip_private_text,
                         GtkWidget     *icon,
-                        GtkSignalFunc  callback,
+                        GCallback      callback,
                         gpointer       user_data,
                         gint           position)
 {
@@ -3157,16 +3398,18 @@ gtk_toolbar_insert_item (GtkToolbar    *toolbar,
  * except that underscores used to mark mnemonics are removed.
  *
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Returns: the inserted widget
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  */
 GtkWidget*
 gtk_toolbar_insert_stock (GtkToolbar      *toolbar,
                          const gchar     *stock_id,
                          const char      *tooltip_text,
                          const char      *tooltip_private_text,
-                         GtkSignalFunc    callback,
+                         GCallback        callback,
                          gpointer         user_data,
                          gint             position)
 {
@@ -3180,8 +3423,10 @@ gtk_toolbar_insert_stock (GtkToolbar      *toolbar,
 /**
  * gtk_toolbar_append_space:
  * @toolbar: a #GtkToolbar.
- * 
+ *
  * Adds a new space to the end of the toolbar.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 void
 gtk_toolbar_append_space (GtkToolbar *toolbar)
@@ -3196,8 +3441,10 @@ gtk_toolbar_append_space (GtkToolbar *toolbar)
 /**
  * gtk_toolbar_prepend_space:
  * @toolbar: a #GtkToolbar.
- * 
+ *
  * Adds a new space to the beginning of the toolbar.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 void
 gtk_toolbar_prepend_space (GtkToolbar *toolbar)
@@ -3213,8 +3460,10 @@ gtk_toolbar_prepend_space (GtkToolbar *toolbar)
  * gtk_toolbar_insert_space:
  * @toolbar: a #GtkToolbar
  * @position: the number of widgets after which a space should be inserted.
- * 
+ *
  * Inserts a new space in the toolbar at the specified position.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 void
 gtk_toolbar_insert_space (GtkToolbar *toolbar,
@@ -3231,8 +3480,10 @@ gtk_toolbar_insert_space (GtkToolbar *toolbar,
  * gtk_toolbar_remove_space:
  * @toolbar: a #GtkToolbar.
  * @position: the index of the space to remove.
- * 
+ *
  * Removes a space from the specified position.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 void
 gtk_toolbar_remove_space (GtkToolbar *toolbar,
@@ -3269,12 +3520,14 @@ gtk_toolbar_remove_space (GtkToolbar *toolbar,
 /**
  * gtk_toolbar_append_widget:
  * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar. 
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
- * 
+ * @widget: a #GtkWidget to add to the toolbar.
+ * @tooltip_text: (allow-none): the element's tooltip.
+ * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
+ *
  * Adds a widget to the end of the given toolbar.
- **/ 
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
+ **/
 void
 gtk_toolbar_append_widget (GtkToolbar  *toolbar,
                           GtkWidget   *widget,
@@ -3291,12 +3544,14 @@ gtk_toolbar_append_widget (GtkToolbar  *toolbar,
 /**
  * gtk_toolbar_prepend_widget:
  * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar. 
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
- * 
+ * @widget: a #GtkWidget to add to the toolbar.
+ * @tooltip_text: (allow-none): the element's tooltip.
+ * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
+ *
  * Adds a widget to the beginning of the given toolbar.
- **/ 
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
+ **/
 void
 gtk_toolbar_prepend_widget (GtkToolbar  *toolbar,
                            GtkWidget   *widget,
@@ -3313,12 +3568,14 @@ gtk_toolbar_prepend_widget (GtkToolbar  *toolbar,
 /**
  * gtk_toolbar_insert_widget:
  * @toolbar: a #GtkToolbar.
- * @widget: a #GtkWidget to add to the toolbar. 
- * @tooltip_text: the element's tooltip.
- * @tooltip_private_text: used for context-sensitive help about this toolbar element.
+ * @widget: a #GtkWidget to add to the toolbar.
+ * @tooltip_text: (allow-none): the element's tooltip.
+ * @tooltip_private_text: (allow-none): used for context-sensitive help about this toolbar element.
  * @position: the number of widgets to insert this widget after.
- * 
+ *
  * Inserts a widget in the toolbar at the given position.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/ 
 void
 gtk_toolbar_insert_widget (GtkToolbar *toolbar,
@@ -3338,7 +3595,7 @@ gtk_toolbar_insert_widget (GtkToolbar *toolbar,
  * gtk_toolbar_append_element:
  * @toolbar: a #GtkToolbar.
  * @type: a value of type #GtkToolbarChildType that determines what @widget will be.
- * @widget: a #GtkWidget, or %NULL.
+ * @widget: (allow-none): a #GtkWidget, or %NULL.
  * @text: the element's label.
  * @tooltip_text: the element's tooltip.
  * @tooltip_private_text: used for context-sensitive help about this toolbar element.
@@ -3354,9 +3611,11 @@ gtk_toolbar_insert_widget (GtkToolbar *toolbar,
  * be %NULL.
  * 
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar element as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget*
 gtk_toolbar_append_element (GtkToolbar          *toolbar,
@@ -3366,7 +3625,7 @@ gtk_toolbar_append_element (GtkToolbar          *toolbar,
                            const char          *tooltip_text,
                            const char          *tooltip_private_text,
                            GtkWidget           *icon,
-                           GtkSignalFunc        callback,
+                           GCallback            callback,
                            gpointer             user_data)
 {
   return gtk_toolbar_insert_element (toolbar, type, widget, text,
@@ -3379,7 +3638,7 @@ gtk_toolbar_append_element (GtkToolbar          *toolbar,
  * gtk_toolbar_prepend_element:
  * @toolbar: a #GtkToolbar.
  * @type: a value of type #GtkToolbarChildType that determines what @widget will be.
- * @widget: a #GtkWidget, or %NULL
+ * @widget: (allow-none): a #GtkWidget, or %NULL
  * @text: the element's label.
  * @tooltip_text: the element's tooltip.
  * @tooltip_private_text: used for context-sensitive help about this toolbar element.
@@ -3395,9 +3654,11 @@ gtk_toolbar_append_element (GtkToolbar          *toolbar,
  * be %NULL.
  * 
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar element as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget *
 gtk_toolbar_prepend_element (GtkToolbar          *toolbar,
@@ -3407,7 +3668,7 @@ gtk_toolbar_prepend_element (GtkToolbar          *toolbar,
                             const char          *tooltip_text,
                             const char          *tooltip_private_text,
                             GtkWidget           *icon,
-                            GtkSignalFunc        callback,
+                            GCallback            callback,
                             gpointer             user_data)
 {
   return gtk_toolbar_insert_element (toolbar, type, widget, text,
@@ -3420,7 +3681,7 @@ gtk_toolbar_prepend_element (GtkToolbar          *toolbar,
  * @toolbar: a #GtkToolbar.
  * @type: a value of type #GtkToolbarChildType that determines what @widget
  *   will be.
- * @widget: a #GtkWidget, or %NULL. 
+ * @widget: (allow-none): a #GtkWidget, or %NULL. 
  * @text: the element's label.
  * @tooltip_text: the element's tooltip.
  * @tooltip_private_text: used for context-sensitive help about this toolbar element.
@@ -3437,9 +3698,11 @@ gtk_toolbar_prepend_element (GtkToolbar          *toolbar,
  * be %NULL.
  *
  * @callback must be a pointer to a function taking a #GtkWidget and a gpointer as
- * arguments. Use the GTK_SIGNAL_FUNC() to cast the function to #GtkSignalFunc.
+ * arguments. Use G_CALLBACK() to cast the function to #GCallback.
  *
  * Return value: the new toolbar element as a #GtkWidget.
+ *
+ * Deprecated: 2.4: Use gtk_toolbar_insert() instead.
  **/
 GtkWidget *
 gtk_toolbar_insert_element (GtkToolbar          *toolbar,
@@ -3449,7 +3712,7 @@ gtk_toolbar_insert_element (GtkToolbar          *toolbar,
                            const char          *tooltip_text,
                            const char          *tooltip_private_text,
                            GtkWidget           *icon,
-                           GtkSignalFunc        callback,
+                           GCallback            callback,
                            gpointer             user_data,
                            gint                 position)
 {
@@ -3504,16 +3767,14 @@ internal_insert_element (GtkToolbar          *toolbar,
                         const char          *tooltip_text,
                         const char          *tooltip_private_text,
                         GtkWidget           *icon,
-                        GtkSignalFunc        callback,
+                        GCallback            callback,
                         gpointer             user_data,
                         gint                 position,
                         gboolean             use_stock)
 {
   GtkWidget *box;
   ToolbarContent *content;
-  GtkToolbarPrivate *priv;
   char *free_me = NULL;
-  gboolean is_button = FALSE;
 
   GtkWidget *child_widget;
   GtkWidget *child_label;
@@ -3524,12 +3785,12 @@ internal_insert_element (GtkToolbar          *toolbar,
     g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
   else if (type != GTK_TOOLBAR_CHILD_RADIOBUTTON)
     g_return_val_if_fail (widget == NULL, NULL);
+  if (GTK_IS_TOOL_ITEM (widget))
+    g_warning (MIXED_API_WARNING);
   
   if (!gtk_toolbar_check_old_api (toolbar))
     return NULL;
   
-  priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-  
   child_widget = NULL;
   child_label = NULL;
   child_icon = NULL;
@@ -3546,7 +3807,6 @@ internal_insert_element (GtkToolbar          *toolbar,
     case GTK_TOOLBAR_CHILD_BUTTON:
     case GTK_TOOLBAR_CHILD_TOGGLEBUTTON:
     case GTK_TOOLBAR_CHILD_RADIOBUTTON:
-      is_button = TRUE;
       if (type == GTK_TOOLBAR_CHILD_BUTTON)
        {
          child_widget = gtk_button_new ();
@@ -3626,8 +3886,7 @@ internal_insert_element (GtkToolbar          *toolbar,
   content = toolbar_content_new_compatibility (toolbar, type, child_widget,
                                               child_icon, child_label, position);
   
-  if (free_me)
-    g_free (free_me);
+  g_free (free_me);
   
   return child_widget;
 }
@@ -3635,6 +3894,12 @@ internal_insert_element (GtkToolbar          *toolbar,
 /*
  * ToolbarContent methods
  */
+typedef enum {
+  UNKNOWN,
+  YES,
+  NO
+} TriState;
+
 struct _ToolbarContent
 {
   ContentType  type;
@@ -3649,6 +3914,7 @@ struct _ToolbarContent
       GtkAllocation    goal_allocation;
       guint            is_placeholder : 1;
       guint            disappearing : 1;
+      guint            has_menu : 2;
     } tool_item;
     
     struct
@@ -3669,7 +3935,7 @@ toolbar_content_new_tool_item (GtkToolbar  *toolbar,
   ToolbarContent *content;
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   
-  content = g_new0 (ToolbarContent, 1);
+  content = g_slice_new0 (ToolbarContent);
   
   content->type = TOOL_ITEM;
   content->state = NOT_ALLOCATED;
@@ -3688,6 +3954,7 @@ toolbar_content_new_tool_item (GtkToolbar  *toolbar,
     }
 
   gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+  priv->need_rebuild = TRUE;
   
   return content;
 }
@@ -3704,7 +3971,7 @@ toolbar_content_new_compatibility (GtkToolbar          *toolbar,
   GtkToolbarChild *child;
   GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
   
-  content = g_new0 (ToolbarContent, 1);
+  content = g_slice_new0 (ToolbarContent);
 
   child = &(content->u.compatibility.child);
   
@@ -3733,6 +4000,7 @@ toolbar_content_new_compatibility (GtkToolbar          *toolbar,
 
   priv->content = g_list_insert (priv->content, content, pos);
   toolbar->children = g_list_insert (toolbar->children, child, pos);
+  priv->need_rebuild = TRUE;
   
   toolbar->num_children++;
   
@@ -3775,12 +4043,13 @@ toolbar_content_remove (ToolbarContent *content,
     toolbar->num_children--;
 
   gtk_widget_queue_resize (GTK_WIDGET (toolbar));
+  priv->need_rebuild = TRUE;
 }
 
 static void
 toolbar_content_free (ToolbarContent *content)
 {
-  g_free (content);
+  g_slice_free (ToolbarContent, content);
 }
 
 static gint
@@ -3821,13 +4090,11 @@ toolbar_content_expose (ToolbarContent *content,
       
       if (child->type == GTK_TOOLBAR_CHILD_SPACE)
        {
-         if (get_space_style (toolbar) == GTK_TOOLBAR_SPACE_LINE &&
-             content->u.compatibility.space_visible)
-           {
-             _gtk_toolbar_paint_space_line (GTK_WIDGET (toolbar), toolbar,
-                                            &expose->area,
-                                            &content->u.compatibility.space_allocation);
-           }
+         if (content->u.compatibility.space_visible &&
+              get_space_style (toolbar) == GTK_TOOLBAR_SPACE_LINE)
+            _gtk_toolbar_paint_space_line (GTK_WIDGET (toolbar), toolbar,
+                                           &expose->area,
+                                           &content->u.compatibility.space_allocation);
          return;
        }
       
@@ -3850,27 +4117,23 @@ toolbar_content_visible (ToolbarContent *content,
     case TOOL_ITEM:
       item = content->u.tool_item.item;
       
-      if (!GTK_WIDGET_VISIBLE (item))
+      if (!gtk_widget_get_visible (GTK_WIDGET (item)))
        return FALSE;
       
       if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL &&
          gtk_tool_item_get_visible_horizontal (item))
-       {
-         return TRUE;
-       }
+       return TRUE;
       
       if ((toolbar->orientation == GTK_ORIENTATION_VERTICAL &&
           gtk_tool_item_get_visible_vertical (item)))
-       {
-         return TRUE;
-       }
+       return TRUE;
       
       return FALSE;
       break;
       
     case COMPATIBILITY:
       if (content->u.compatibility.child.type != GTK_TOOLBAR_CHILD_SPACE)
-       return GTK_WIDGET_VISIBLE (content->u.compatibility.child.widget);
+       return gtk_widget_get_visible (content->u.compatibility.child.widget);
       else
        return TRUE;
       break;
@@ -4087,7 +4350,8 @@ static gboolean
 toolbar_content_get_expand (ToolbarContent *content)
 {
   if (content->type == TOOL_ITEM &&
-      gtk_tool_item_get_expand (content->u.tool_item.item))
+      gtk_tool_item_get_expand (content->u.tool_item.item) &&
+      !content->u.tool_item.disappearing)
     {
       return TRUE;
     }
@@ -4135,8 +4399,11 @@ toolbar_content_set_child_visible (ToolbarContent *content,
        }
       else
        {
-         content->u.compatibility.space_visible = visible;
-         gtk_widget_queue_draw (GTK_WIDGET (toolbar));
+         if (content->u.compatibility.space_visible != visible)
+           {
+             content->u.compatibility.space_visible = visible;
+             gtk_widget_queue_draw (GTK_WIDGET (toolbar));
+           }
        }
       break;
     }
@@ -4345,7 +4612,7 @@ toolbar_content_toolbar_reconfigured (ToolbarContent *content,
   switch (content->type)
     {
     case TOOL_ITEM:
-      _gtk_tool_item_toolbar_reconfigured (content->u.tool_item.item);
+      gtk_tool_item_toolbar_reconfigured (content->u.tool_item.item);
       break;
       
     case COMPATIBILITY:
@@ -4364,6 +4631,37 @@ toolbar_content_retrieve_menu_item (ToolbarContent *content)
   return NULL; 
 }
 
+static gboolean
+toolbar_content_has_proxy_menu_item (ToolbarContent *content)
+{
+  if (content->type == TOOL_ITEM)
+    {
+      GtkWidget *menu_item;
+
+      if (content->u.tool_item.has_menu == YES)
+       return TRUE;
+      else if (content->u.tool_item.has_menu == NO)
+       return FALSE;
+
+      menu_item = toolbar_content_retrieve_menu_item (content);
+
+      content->u.tool_item.has_menu = menu_item? YES : NO;
+      
+      return menu_item != NULL;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static void
+toolbar_content_set_unknown_menu_status (ToolbarContent *content)
+{
+  if (content->type == TOOL_ITEM)
+    content->u.tool_item.has_menu = UNKNOWN;
+}
+
 static gboolean
 toolbar_content_is_separator (ToolbarContent *content)
 {
@@ -4384,6 +4682,14 @@ toolbar_content_is_separator (ToolbarContent *content)
   return FALSE;
 }
 
+static void
+toolbar_content_set_expand (ToolbarContent *content,
+                           gboolean        expand)
+{
+  if (content->type == TOOL_ITEM)
+    gtk_tool_item_set_expand (content->u.tool_item.item, expand);
+}
+
 static gboolean
 ignore_show_and_hide_all (ToolbarContent *content)
 {
@@ -4439,7 +4745,7 @@ get_space_size (GtkToolbar *toolbar)
   if (toolbar)
     {
       gtk_widget_style_get (GTK_WIDGET (toolbar),
-                           "space_size", &space_size,
+                           "space-size", &space_size,
                            NULL);
     }
   
@@ -4454,7 +4760,7 @@ get_space_style (GtkToolbar *toolbar)
   if (toolbar)
     {
       gtk_widget_style_get (GTK_WIDGET (toolbar),
-                           "space_style", &space_style,
+                           "space-style", &space_style,
                            NULL);
     }
   
@@ -4469,7 +4775,7 @@ get_button_relief (GtkToolbar *toolbar)
   gtk_widget_ensure_style (GTK_WIDGET (toolbar));
   
   gtk_widget_style_get (GTK_WIDGET (toolbar),
-                        "button_relief", &button_relief,
+                        "button-relief", &button_relief,
                         NULL);
   
   return button_relief;
@@ -4481,19 +4787,30 @@ get_internal_padding (GtkToolbar *toolbar)
   gint ipadding = 0;
   
   gtk_widget_style_get (GTK_WIDGET (toolbar),
-                       "internal_padding", &ipadding,
+                       "internal-padding", &ipadding,
                        NULL);
   
   return ipadding;
 }
 
+static gint
+get_max_child_expand (GtkToolbar *toolbar)
+{
+  gint mexpand = G_MAXINT;
+
+  gtk_widget_style_get (GTK_WIDGET (toolbar),
+                        "max-child-expand", &mexpand,
+                        NULL);
+  return mexpand;
+}
+
 static GtkShadowType
 get_shadow_type (GtkToolbar *toolbar)
 {
   GtkShadowType shadow_type;
   
   gtk_widget_style_get (GTK_WIDGET (toolbar),
-                       "shadow_type", &shadow_type,
+                       "shadow-type", &shadow_type,
                        NULL);
   
   return shadow_type;
@@ -4502,9 +4819,6 @@ get_shadow_type (GtkToolbar *toolbar)
 /*
  * API checks
  */
-#define mixed_api_warning \
-    "mixing deprecated and non-deprecated GtkToolbar API is not allowed"
-
 static gboolean
 gtk_toolbar_check_old_api (GtkToolbar *toolbar)
 {
@@ -4512,7 +4826,7 @@ gtk_toolbar_check_old_api (GtkToolbar *toolbar)
   
   if (priv->api_mode == NEW_API)
     {
-      g_warning (mixed_api_warning);
+      g_warning (MIXED_API_WARNING);
       return FALSE;
     }
   
@@ -4527,7 +4841,7 @@ gtk_toolbar_check_new_api (GtkToolbar *toolbar)
   
   if (priv->api_mode == OLD_API)
     {
-      g_warning (mixed_api_warning);
+      g_warning (MIXED_API_WARNING);
       return FALSE;
     }
   
@@ -4544,41 +4858,71 @@ _gtk_toolbar_get_default_space_size (void)
 }
 
 void
-_gtk_toolbar_paint_space_line (GtkWidget       *widget,
-                              GtkToolbar      *toolbar,
-                              GdkRectangle    *area,
-                              GtkAllocation   *allocation)
+_gtk_toolbar_paint_space_line (GtkWidget           *widget,
+                              GtkToolbar          *toolbar,
+                              const GdkRectangle  *area,
+                              const GtkAllocation *allocation)
 {
   const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION);
   const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION);
   
-  gint space_size;
-  GtkToolbarSpaceStyle space_style;
   GtkOrientation orientation;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   
-  space_size = get_space_size (toolbar);
-  space_style = get_space_style (toolbar);
   orientation = toolbar? toolbar->orientation : GTK_ORIENTATION_HORIZONTAL;
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      gtk_paint_vline (widget->style, widget->window,
-                      GTK_WIDGET_STATE (widget), area, widget,
-                      "toolbar",
-                      allocation->y + allocation->height * start_fraction,
-                      allocation->y + allocation->height * end_fraction,
-                      allocation->x + (space_size - widget->style->xthickness) / 2);
+      gboolean wide_separators;
+      gint     separator_width;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators", &wide_separators,
+                            "separator-width", &separator_width,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       area, widget, "vseparator",
+                       allocation->x + (allocation->width - separator_width) / 2,
+                       allocation->y + allocation->height * start_fraction,
+                       separator_width,
+                       allocation->height * (end_fraction - start_fraction));
+      else
+        gtk_paint_vline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget), area, widget,
+                         "toolbar",
+                         allocation->y + allocation->height * start_fraction,
+                         allocation->y + allocation->height * end_fraction,
+                         allocation->x + (allocation->width - widget->style->xthickness) / 2);
     }
   else
     {
-      gtk_paint_hline (widget->style, widget->window,
-                      GTK_WIDGET_STATE (widget), area, widget,
-                      "toolbar",
-                      allocation->x + allocation->width * start_fraction,
-                      allocation->x + allocation->width * end_fraction,
-                      allocation->y + (space_size - widget->style->ythickness) / 2);
+      gboolean wide_separators;
+      gint     separator_height;
+
+      gtk_widget_style_get (widget,
+                            "wide-separators",  &wide_separators,
+                            "separator-height", &separator_height,
+                            NULL);
+
+      if (wide_separators)
+        gtk_paint_box (widget->style, widget->window,
+                       GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
+                       area, widget, "hseparator",
+                       allocation->x + allocation->width * start_fraction,
+                       allocation->y + (allocation->height - separator_height) / 2,
+                       allocation->width * (end_fraction - start_fraction),
+                       separator_height);
+      else
+        gtk_paint_hline (widget->style, widget->window,
+                         GTK_WIDGET_STATE (widget), area, widget,
+                         "toolbar",
+                         allocation->x + allocation->width * start_fraction,
+                         allocation->x + allocation->width * end_fraction,
+                         allocation->y + (allocation->height - widget->style->ythickness) / 2);
     }
 }
 
@@ -4586,24 +4930,86 @@ gchar *
 _gtk_toolbar_elide_underscores (const gchar *original)
 {
   gchar *q, *result;
-  const gchar *p;
+  const gchar *p, *end;
+  gsize len;
   gboolean last_underscore;
   
-  q = result = g_malloc (strlen (original) + 1);
+  if (!original)
+    return NULL;
+
+  len = strlen (original);
+  q = result = g_malloc (len + 1);
   last_underscore = FALSE;
   
-  for (p = original; *p; p++)
+  end = original + len;
+  for (p = original; p < end; p++)
     {
       if (!last_underscore && *p == '_')
        last_underscore = TRUE;
       else
        {
          last_underscore = FALSE;
-         *q++ = *p;
+         if (original + 2 <= p && p + 1 <= end && 
+              p[-2] == '(' && p[-1] == '_' && p[0] != '_' && p[1] == ')')
+           {
+             q--;
+             *q = '\0';
+             p++;
+           }
+         else
+           *q++ = *p;
        }
     }
+
+  if (last_underscore)
+    *q++ = '_';
   
   *q = '\0';
   
   return result;
 }
+
+static GtkIconSize
+toolbar_get_icon_size (GtkToolShell *shell)
+{
+  return GTK_TOOLBAR (shell)->icon_size;
+}
+
+static GtkOrientation
+toolbar_get_orientation (GtkToolShell *shell)
+{
+  return GTK_TOOLBAR (shell)->orientation;
+}
+
+static GtkToolbarStyle
+toolbar_get_style (GtkToolShell *shell)
+{
+  return GTK_TOOLBAR (shell)->style;
+}
+
+static GtkReliefStyle
+toolbar_get_relief_style (GtkToolShell *shell)
+{
+  return get_button_relief (GTK_TOOLBAR (shell));
+}
+
+static void
+toolbar_rebuild_menu (GtkToolShell *shell)
+{
+  GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (shell);
+  GList *list;
+
+  priv->need_rebuild = TRUE;
+
+  for (list = priv->content; list != NULL; list = list->next)
+    {
+      ToolbarContent *content = list->data;
+
+      toolbar_content_set_unknown_menu_status (content);
+    }
+  
+  gtk_widget_queue_resize (GTK_WIDGET (shell));
+}
+
+#define __GTK_TOOLBAR_C__
+#include "gtkaliasdef.c"