]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcombobox.c
Added new constructors gtk_combo_box_new_with_area and gtk_combo_box_new_with_area_an...
[~andy/gtk] / gtk / gtkcombobox.c
index 26da1cd6ed345be8f271935ddfbc3f0048302105..84ed7c47f0f006425856705711a659169259ca59 100644 (file)
@@ -19,7 +19,8 @@
 
 #include "config.h"
 #include "gtkcombobox.h"
-
+#include "gtkcellareabox.h"
+#include "gtktreemenu.h"
 #include "gtkarrow.h"
 #include "gtkbindings.h"
 #include "gtkcelllayout.h"
@@ -30,7 +31,8 @@
 #include "gtkhbox.h"
 #include "gtkliststore.h"
 #include "gtkmain.h"
-#include "gtkmenu.h"
+#include "gtkmenuprivate.h"
+#include "gtkmenushellprivate.h"
 #include "gtkscrolledwindow.h"
 #include "gtkseparatormenuitem.h"
 #include "gtktearoffmenuitem.h"
 #include "gtkmarshalers.h"
 #include "gtkintl.h"
 
+#include "gtkentryprivate.h"
 #include "gtktreeprivate.h"
-#include "gtkalias.h"
-
-/* WELCOME, to THE house of evil code */
-
-typedef struct _ComboCellInfo ComboCellInfo;
-struct _ComboCellInfo
-{
-  GtkCellRenderer *cell;
-  GSList *attributes;
 
-  GtkCellLayoutDataFunc func;
-  gpointer func_data;
-  GDestroyNotify destroy;
 
-  guint expand : 1;
-  guint pack : 1;
-};
+/**
+ * SECTION:gtkcombobox
+ * @Short_description: A widget used to choose from a list of items
+ * @Title: GtkComboBox
+ * @See_also: #GtkComboBoxText, #GtkTreeModel, #GtkCellRenderer
+ *
+ * A GtkComboBox is a widget that allows the user to choose from a list of
+ * valid choices. The GtkComboBox displays the selected choice. When
+ * activated, the GtkComboBox displays a popup which allows the user to
+ * make a new choice. The style in which the selected value is displayed,
+ * and the style of the popup is determined by the current theme. It may
+ * be similar to a Windows-style combo box.
+ *
+ * The GtkComboBox uses the model-view pattern; the list of valid choices
+ * is specified in the form of a tree model, and the display of the choices
+ * can be adapted to the data in the model by using cell renderers, as you
+ * would in a tree view. This is possible since GtkComboBox implements the
+ * #GtkCellLayout interface. The tree model holding the valid choices is
+ * not restricted to a flat list, it can be a real tree, and the popup will
+ * reflect the tree structure.
+ *
+ * For a simple list of textual choices, the model-view API of GtkComboBox
+ * can be a bit overwhelming. In this case, #GtkComboBoxText offers a
+ * simple alternative.
+ */
 
-#define GTK_COMBO_BOX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_COMBO_BOX, GtkComboBoxPrivate))
 
+/* WELCOME, to THE house of evil code */
 struct _GtkComboBoxPrivate
 {
   GtkTreeModel *model;
 
+  GtkCellArea *area;
+
   gint col_column;
   gint row_column;
 
@@ -99,19 +114,22 @@ struct _GtkComboBoxPrivate
   GtkWidget *popup_window;
   GtkWidget *scrolled_window;
 
-  guint inserted_id;
-  guint deleted_id;
-  guint reordered_id;
-  guint changed_id;
+  gulong inserted_id;
+  gulong deleted_id;
+  gulong reordered_id;
+  gulong changed_id;
   guint popup_idle_id;
   guint activate_button;
   guint32 activate_time;
   guint scroll_timer;
   guint resize_idle_id;
 
-  gint width;
-  gint height;
-  GSList *cells;
+  /* For "has-entry" specific behavior we track
+   * an automated cell renderer and text column */
+  gint  text_column;
+  GtkCellRenderer *text_renderer;
+
+  gint id_column;
 
   guint popup_in_progress : 1;
   guint popup_shown : 1;
@@ -122,11 +140,16 @@ struct _GtkComboBoxPrivate
   guint auto_scroll : 1;
   guint focus_on_click : 1;
   guint button_sensitivity : 2;
+  guint has_entry : 1;
+  guint popup_fixed_width : 1;
 
   GtkTreeViewRowSeparatorFunc row_separator_func;
   gpointer                    row_separator_data;
   GDestroyNotify              row_separator_destroy;
 
+  GdkDevice *grab_pointer;
+  GdkDevice *grab_keyboard;
+
   gchar *tearoff_title;
 };
 
@@ -205,7 +228,13 @@ enum {
   PROP_FOCUS_ON_CLICK,
   PROP_POPUP_SHOWN,
   PROP_BUTTON_SENSITIVITY,
-  PROP_EDITING_CANCELED
+  PROP_EDITING_CANCELED,
+  PROP_HAS_ENTRY,
+  PROP_ENTRY_TEXT_COLUMN,
+  PROP_POPUP_FIXED_WIDTH,
+  PROP_ID_COLUMN,
+  PROP_ACTIVE_ID,
+  PROP_CELL_AREA
 };
 
 static guint combo_box_signals[LAST_SIGNAL] = {0,};
@@ -217,9 +246,12 @@ static guint combo_box_signals[LAST_SIGNAL] = {0,};
 
 static void     gtk_combo_box_cell_layout_init     (GtkCellLayoutIface *iface);
 static void     gtk_combo_box_cell_editable_init   (GtkCellEditableIface *iface);
+static GObject *gtk_combo_box_constructor          (GType                  type,
+                                                   guint                  n_construct_properties,
+                                                   GObjectConstructParam *construct_properties);
 static void     gtk_combo_box_dispose              (GObject          *object);
 static void     gtk_combo_box_finalize             (GObject          *object);
-static void     gtk_combo_box_destroy              (GtkObject        *object);
+static void     gtk_combo_box_destroy              (GtkWidget        *widget);
 
 static void     gtk_combo_box_set_property         (GObject         *object,
                                                     guint            prop_id,
@@ -233,21 +265,17 @@ static void     gtk_combo_box_get_property         (GObject         *object,
 static void     gtk_combo_box_state_changed        (GtkWidget        *widget,
                                                    GtkStateType      previous);
 static void     gtk_combo_box_grab_focus           (GtkWidget       *widget);
-static void     gtk_combo_box_style_set            (GtkWidget       *widget,
-                                                    GtkStyle        *previous);
+static void     gtk_combo_box_style_updated        (GtkWidget       *widget);
 static void     gtk_combo_box_button_toggled       (GtkWidget       *widget,
                                                     gpointer         data);
-static void     gtk_combo_box_button_state_changed (GtkWidget       *widget,
-                                                   GtkStateType     previous,
-                                                   gpointer         data);
+static void     gtk_combo_box_button_state_flags_changed (GtkWidget     *widget,
+                                                          GtkStateFlags  previous,
+                                                          gpointer       data);
 static void     gtk_combo_box_add                  (GtkContainer    *container,
                                                     GtkWidget       *widget);
 static void     gtk_combo_box_remove               (GtkContainer    *container,
                                                     GtkWidget       *widget);
 
-static ComboCellInfo *gtk_combo_box_get_cell_info  (GtkComboBox      *combo_box,
-                                                    GtkCellRenderer  *cell);
-
 static void     gtk_combo_box_menu_show            (GtkWidget        *menu,
                                                     gpointer          user_data);
 static void     gtk_combo_box_menu_hide            (GtkWidget        *menu,
@@ -271,29 +299,22 @@ static void     gtk_combo_box_menu_position        (GtkMenu          *menu,
                                                     gint             *push_in,
                                                     gpointer          user_data);
 
-static gint     gtk_combo_box_calc_requested_width (GtkComboBox      *combo_box,
-                                                    GtkTreePath      *path);
-static void     gtk_combo_box_remeasure            (GtkComboBox      *combo_box);
-
 static void     gtk_combo_box_unset_model          (GtkComboBox      *combo_box);
 
-static void     gtk_combo_box_size_request         (GtkWidget        *widget,
-                                                    GtkRequisition   *requisition);
 static void     gtk_combo_box_size_allocate        (GtkWidget        *widget,
                                                     GtkAllocation    *allocation);
 static void     gtk_combo_box_forall               (GtkContainer     *container,
                                                     gboolean          include_internals,
                                                     GtkCallback       callback,
                                                     gpointer          callback_data);
-static gboolean gtk_combo_box_expose_event         (GtkWidget        *widget,
-                                                    GdkEventExpose   *event);
+static gboolean gtk_combo_box_draw                 (GtkWidget        *widget,
+                                                    cairo_t          *cr);
 static gboolean gtk_combo_box_scroll_event         (GtkWidget        *widget,
                                                     GdkEventScroll   *event);
 static void     gtk_combo_box_set_active_internal  (GtkComboBox      *combo_box,
                                                    GtkTreePath      *path);
 
 static void     gtk_combo_box_check_appearance     (GtkComboBox      *combo_box);
-static gchar *  gtk_combo_box_real_get_active_text (GtkComboBox      *combo_box);
 static void     gtk_combo_box_real_move_active     (GtkComboBox      *combo_box,
                                                     GtkScrollType     scroll);
 static void     gtk_combo_box_real_popup           (GtkComboBox      *combo_box);
@@ -362,90 +383,42 @@ static void     gtk_combo_box_list_popup_resize    (GtkComboBox      *combo_box)
 /* menu */
 static void     gtk_combo_box_menu_setup           (GtkComboBox      *combo_box,
                                                     gboolean          add_children);
-static void     gtk_combo_box_menu_fill            (GtkComboBox      *combo_box);
-static void     gtk_combo_box_menu_fill_level      (GtkComboBox      *combo_box,
-                                                   GtkWidget        *menu,
-                                                   GtkTreeIter      *iter);
 static void     gtk_combo_box_update_title         (GtkComboBox      *combo_box);
 static void     gtk_combo_box_menu_destroy         (GtkComboBox      *combo_box);
 
-static void     gtk_combo_box_relayout_item        (GtkComboBox      *combo_box,
-                                                   GtkWidget        *item,
-                                                    GtkTreeIter      *iter,
-                                                   GtkWidget        *last);
-static void     gtk_combo_box_relayout             (GtkComboBox      *combo_box);
 
 static gboolean gtk_combo_box_menu_button_press    (GtkWidget        *widget,
                                                     GdkEventButton   *event,
                                                     gpointer          user_data);
-static void     gtk_combo_box_menu_item_activate   (GtkWidget        *item,
-                                                    gpointer          user_data);
-
+static void     gtk_combo_box_menu_activate        (GtkWidget        *menu,
+                                                   const gchar      *path,
+                                                   GtkComboBox      *combo_box);
 static void     gtk_combo_box_update_sensitivity   (GtkComboBox      *combo_box);
-static void     gtk_combo_box_menu_row_inserted    (GtkTreeModel     *model,
-                                                    GtkTreePath      *path,
-                                                    GtkTreeIter      *iter,
-                                                    gpointer          user_data);
-static void     gtk_combo_box_menu_row_deleted     (GtkTreeModel     *model,
-                                                    GtkTreePath      *path,
-                                                    gpointer          user_data);
-static void     gtk_combo_box_menu_rows_reordered  (GtkTreeModel     *model,
-                                                   GtkTreePath      *path,
-                                                   GtkTreeIter      *iter,
-                                                   gint             *new_order,
-                                                   gpointer          user_data);
-static void     gtk_combo_box_menu_row_changed     (GtkTreeModel     *model,
-                                                    GtkTreePath      *path,
-                                                    GtkTreeIter      *iter,
-                                                    gpointer          data);
 static gboolean gtk_combo_box_menu_key_press       (GtkWidget        *widget,
                                                    GdkEventKey      *event,
                                                    gpointer          data);
 static void     gtk_combo_box_menu_popup           (GtkComboBox      *combo_box,
                                                    guint             button, 
                                                    guint32           activate_time);
-static GtkWidget *gtk_cell_view_menu_item_new      (GtkComboBox      *combo_box,
-                                                   GtkTreeModel     *model,
-                                                   GtkTreeIter      *iter);
 
 /* cell layout */
-static void     gtk_combo_box_cell_layout_pack_start         (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell,
-                                                              gboolean               expand);
-static void     gtk_combo_box_cell_layout_pack_end           (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell,
-                                                              gboolean               expand);
-static GList   *gtk_combo_box_cell_layout_get_cells          (GtkCellLayout         *layout);
-static void     gtk_combo_box_cell_layout_clear              (GtkCellLayout         *layout);
-static void     gtk_combo_box_cell_layout_add_attribute      (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell,
-                                                              const gchar           *attribute,
-                                                              gint                   column);
-static void     gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell,
-                                                              GtkCellLayoutDataFunc  func,
-                                                              gpointer               func_data,
-                                                              GDestroyNotify         destroy);
-static void     gtk_combo_box_cell_layout_clear_attributes   (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell);
-static void     gtk_combo_box_cell_layout_reorder            (GtkCellLayout         *layout,
-                                                              GtkCellRenderer       *cell,
-                                                              gint                   position);
+GtkCellArea    *gtk_combo_box_cell_layout_get_area (GtkCellLayout    *cell_layout);
+
 static gboolean gtk_combo_box_mnemonic_activate              (GtkWidget    *widget,
                                                              gboolean      group_cycling);
 
-static void     gtk_combo_box_sync_cells                     (GtkComboBox   *combo_box,
-                                                             GtkCellLayout *cell_layout);
-static void     combo_cell_data_func                         (GtkCellLayout   *cell_layout,
-                                                             GtkCellRenderer *cell,
-                                                             GtkTreeModel    *tree_model,
-                                                             GtkTreeIter     *iter,
-                                                             gpointer         data);
 static void     gtk_combo_box_child_show                     (GtkWidget       *widget,
                                                              GtkComboBox     *combo_box);
 static void     gtk_combo_box_child_hide                     (GtkWidget       *widget,
                                                              GtkComboBox     *combo_box);
 
+/* GtkComboBox:has-entry callbacks */
+static void     gtk_combo_box_entry_contents_changed         (GtkEntry        *entry,
+                                                             gpointer         user_data);
+static void     gtk_combo_box_entry_active_changed           (GtkComboBox     *combo_box,
+                                                             gpointer         user_data);
+
+
 /* GtkBuildable method implementation */
 static GtkBuildableIface *parent_buildable_iface;
 
@@ -461,10 +434,29 @@ static void     gtk_combo_box_buildable_custom_tag_end       (GtkBuildable  *bui
                                                              GObject       *child,
                                                              const gchar   *tagname,
                                                              gpointer      *data);
+static GObject *gtk_combo_box_buildable_get_internal_child   (GtkBuildable *buildable,
+                                                             GtkBuilder   *builder,
+                                                             const gchar  *childname);
+
 
 /* GtkCellEditable method implementations */
-static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
-                                        GdkEvent        *event);
+static void     gtk_combo_box_start_editing                  (GtkCellEditable *cell_editable,
+                                                             GdkEvent        *event);
+
+static void     gtk_combo_box_get_preferred_width            (GtkWidget           *widget,
+                                                             gint                *minimum_size,
+                                                             gint                *natural_size);
+static void     gtk_combo_box_get_preferred_height           (GtkWidget           *widget,
+                                                             gint                *minimum_size,
+                                                             gint                *natural_size);
+static void     gtk_combo_box_get_preferred_width_for_height (GtkWidget             *widget,
+                                                             gint                   avail_size,
+                                                             gint                  *minimum_size,
+                                                             gint                  *natural_size);
+static void     gtk_combo_box_get_preferred_height_for_width (GtkWidget             *widget,
+                                                             gint                   avail_size,
+                                                             gint                  *minimum_size,
+                                                             gint                  *natural_size);
 
 
 G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
@@ -481,13 +473,10 @@ static void
 gtk_combo_box_class_init (GtkComboBoxClass *klass)
 {
   GObjectClass *object_class;
-  GtkObjectClass *gtk_object_class;
   GtkContainerClass *container_class;
   GtkWidgetClass *widget_class;
   GtkBindingSet *binding_set;
 
-  klass->get_active_text = gtk_combo_box_real_get_active_text;
-
   container_class = (GtkContainerClass *)klass;
   container_class->forall = gtk_combo_box_forall;
   container_class->add = gtk_combo_box_add;
@@ -495,18 +484,20 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
 
   widget_class = (GtkWidgetClass *)klass;
   widget_class->size_allocate = gtk_combo_box_size_allocate;
-  widget_class->size_request = gtk_combo_box_size_request;
-  widget_class->expose_event = gtk_combo_box_expose_event;
+  widget_class->draw = gtk_combo_box_draw;
   widget_class->scroll_event = gtk_combo_box_scroll_event;
   widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
   widget_class->grab_focus = gtk_combo_box_grab_focus;
-  widget_class->style_set = gtk_combo_box_style_set;
+  widget_class->style_updated = gtk_combo_box_style_updated;
   widget_class->state_changed = gtk_combo_box_state_changed;
-
-  gtk_object_class = (GtkObjectClass *)klass;
-  gtk_object_class->destroy = gtk_combo_box_destroy;
+  widget_class->get_preferred_width = gtk_combo_box_get_preferred_width;
+  widget_class->get_preferred_height = gtk_combo_box_get_preferred_height;
+  widget_class->get_preferred_height_for_width = gtk_combo_box_get_preferred_height_for_width;
+  widget_class->get_preferred_width_for_height = gtk_combo_box_get_preferred_width_for_height;
+  widget_class->destroy = gtk_combo_box_destroy;
 
   object_class = (GObjectClass *)klass;
+  object_class->constructor = gtk_combo_box_constructor;
   object_class->dispose = gtk_combo_box_dispose;
   object_class->finalize = gtk_combo_box_finalize;
   object_class->set_property = gtk_combo_box_set_property;
@@ -519,10 +510,10 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
    * 
    * The changed signal is emitted when the active
    * item is changed. The can be due to the user selecting
-   * a different item from the list, or due to a 
+   * a different item from the list, or due to a
    * call to gtk_combo_box_set_active_iter().
-   * It will also be emitted while typing into a GtkComboBoxEntry, 
-   * as well as when selecting an item from the GtkComboBoxEntry's list.
+   * It will also be emitted while typing into the entry of a combo box
+   * with an entry.
    *
    * Since: 2.4
    */
@@ -599,53 +590,53 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   /* key bindings */
   binding_set = gtk_binding_set_by_class (widget_class);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Down, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
                                "popup", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, GDK_MOD1_MASK,
                                "popup", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
                                "popdown", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, GDK_MOD1_MASK,
                                "popdown", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
                                "popdown", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Home, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Home, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_End, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_End, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
 
@@ -850,6 +841,104 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                        GTK_SENSITIVITY_AUTO,
                                                        GTK_PARAM_READWRITE));
 
+   /**
+    * GtkComboBox:has-entry:
+    *
+    * Whether the combo box has an entry.
+    *
+    * Since: 2.24
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_HAS_ENTRY,
+                                    g_param_spec_boolean ("has-entry",
+                                                         P_("Has Entry"),
+                                                         P_("Whether combo box has an entry"),
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+   /**
+    * GtkComboBox:entry-text-column:
+    *
+    * The column in the combo box's model to associate with strings from the entry
+    * if the combo was created with #GtkComboBox:has-entry = %TRUE.
+    *
+    * Since: 2.24
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_ENTRY_TEXT_COLUMN,
+                                    g_param_spec_int ("entry-text-column",
+                                                     P_("Entry Text Column"),
+                                                     P_("The column in the combo box's model to associate "
+                                                        "with strings from the entry if the combo was "
+                                                        "created with #GtkComboBox:has-entry = %TRUE"),
+                                                     -1, G_MAXINT, -1,
+                                                     GTK_PARAM_READWRITE));
+
+   /**
+    * GtkComboBox:id-column:
+    *
+    * The column in the combo box's model that provides string
+    * IDs for the values in the model, if != -1.
+    *
+    * Since: 3.0
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_ID_COLUMN,
+                                    g_param_spec_int ("id-column",
+                                                      P_("ID Column"),
+                                                      P_("The column in the combo box's model that provides "
+                                                      "string IDs for the values in the model"),
+                                                      -1, G_MAXINT, -1,
+                                                      GTK_PARAM_READWRITE));
+
+   /**
+    * GtkComboBox:active-id:
+    *
+    * The value of the ID column of the active row.
+    *
+    * Since: 3.0
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_ACTIVE_ID,
+                                    g_param_spec_string ("active-id",
+                                                         P_("Active id"),
+                                                         P_("The value of the id column "
+                                                         "for the active row"),
+                                                         NULL, GTK_PARAM_READWRITE));
+
+   /**
+    * GtkComboBox:popup-fixed-width:
+    *
+    * Whether the popup's width should be a fixed width matching the
+    * allocated width of the combo box.
+    *
+    * Since: 3.0
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_POPUP_FIXED_WIDTH,
+                                    g_param_spec_boolean ("popup-fixed-width",
+                                                         P_("Popup Fixed Width"),
+                                                         P_("Whether the popup's width should be a "
+                                                            "fixed width matching the allocated width "
+                                                            "of the combo box"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+
+   /**
+    * GtkComboBox:cell-area:
+    *
+    * The #GtkCellArea used to layout cell renderers for this combo box.
+    *
+    * Since: 3.0
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_CELL_AREA,
+                                    g_param_spec_object ("cell-area",
+                                                        P_("Cell Area"),
+                                                        P_("The GtkCellArea used to layout cells"),
+                                                        GTK_TYPE_CELL_AREA,
+                                                        GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_boolean ("appears-as-list",
                                                                  P_("Appears as list"),
@@ -901,19 +990,13 @@ gtk_combo_box_buildable_init (GtkBuildableIface *iface)
   iface->add_child = _gtk_cell_layout_buildable_add_child;
   iface->custom_tag_start = gtk_combo_box_buildable_custom_tag_start;
   iface->custom_tag_end = gtk_combo_box_buildable_custom_tag_end;
+  iface->get_internal_child = gtk_combo_box_buildable_get_internal_child;
 }
 
 static void
 gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
 {
-  iface->pack_start = gtk_combo_box_cell_layout_pack_start;
-  iface->pack_end = gtk_combo_box_cell_layout_pack_end;
-  iface->get_cells = gtk_combo_box_cell_layout_get_cells;
-  iface->clear = gtk_combo_box_cell_layout_clear;
-  iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
-  iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func;
-  iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
-  iface->reorder = gtk_combo_box_cell_layout_reorder;
+  iface->get_area = gtk_combo_box_cell_layout_get_area;
 }
 
 static void
@@ -925,15 +1008,13 @@ gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface)
 static void
 gtk_combo_box_init (GtkComboBox *combo_box)
 {
-  GtkComboBoxPrivate *priv = GTK_COMBO_BOX_GET_PRIVATE (combo_box);
+  GtkComboBoxPrivate *priv;
 
-  priv->cell_view = gtk_cell_view_new ();
-  gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (combo_box));
-  GTK_BIN (combo_box)->child = priv->cell_view;
-  gtk_widget_show (priv->cell_view);
+  combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
+                                                 GTK_TYPE_COMBO_BOX,
+                                                 GtkComboBoxPrivate);
+  priv = combo_box->priv;
 
-  priv->width = 0;
-  priv->height = 0;
   priv->wrap_width = 0;
 
   priv->active = -1;
@@ -949,10 +1030,12 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   priv->auto_scroll = FALSE;
   priv->focus_on_click = TRUE;
   priv->button_sensitivity = GTK_SENSITIVITY_AUTO;
+  priv->has_entry = FALSE;
+  priv->popup_fixed_width = TRUE;
 
-  combo_box->priv = priv;
-
-  gtk_combo_box_check_appearance (combo_box);
+  priv->text_column = -1;
+  priv->text_renderer = NULL;
+  priv->id_column = -1;
 }
 
 static void
@@ -962,6 +1045,7 @@ gtk_combo_box_set_property (GObject      *object,
                             GParamSpec   *pspec)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+  GtkCellArea *area;
 
   switch (prop_id)
     {
@@ -991,6 +1075,17 @@ gtk_combo_box_set_property (GObject      *object,
 
     case PROP_HAS_FRAME:
       combo_box->priv->has_frame = g_value_get_boolean (value);
+
+      if (combo_box->priv->has_entry)
+        {
+          GtkWidget *child;
+
+          child = gtk_bin_get_child (GTK_BIN (combo_box));
+
+          gtk_entry_set_has_frame (GTK_ENTRY (child),
+                                   combo_box->priv->has_frame);
+        }
+
       break;
 
     case PROP_FOCUS_ON_CLICK:
@@ -1014,10 +1109,39 @@ gtk_combo_box_set_property (GObject      *object,
                                             g_value_get_enum (value));
       break;
 
+    case PROP_POPUP_FIXED_WIDTH:
+      gtk_combo_box_set_popup_fixed_width (combo_box,
+                                          g_value_get_boolean (value));
+      break;
+
     case PROP_EDITING_CANCELED:
       combo_box->priv->editing_canceled = g_value_get_boolean (value);
       break;
 
+    case PROP_HAS_ENTRY:
+      combo_box->priv->has_entry = g_value_get_boolean (value);
+      break;
+
+    case PROP_ENTRY_TEXT_COLUMN:
+      gtk_combo_box_set_entry_text_column (combo_box, g_value_get_int (value));
+      break;
+
+    case PROP_ID_COLUMN:
+      gtk_combo_box_set_id_column (combo_box, g_value_get_int (value));
+      break;
+
+    case PROP_ACTIVE_ID:
+      gtk_combo_box_set_active_id (combo_box, g_value_get_string (value));
+      break;
+
+    case PROP_CELL_AREA:
+      /* Construct-only, can only be assigned once */
+      area = g_value_get_object (value);
+
+      if (area)
+       combo_box->priv->area = g_object_ref_sink (area);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1031,7 +1155,7 @@ gtk_combo_box_get_property (GObject    *object,
                             GParamSpec *pspec)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (object);
-  GtkComboBoxPrivate *priv = GTK_COMBO_BOX_GET_PRIVATE (combo_box);
+  GtkComboBoxPrivate *priv = combo_box->priv;
 
   switch (prop_id)
     {
@@ -1079,10 +1203,34 @@ gtk_combo_box_get_property (GObject    *object,
         g_value_set_enum (value, combo_box->priv->button_sensitivity);
         break;
 
+      case PROP_POPUP_FIXED_WIDTH:
+        g_value_set_boolean (value, combo_box->priv->popup_fixed_width);
+        break;
+
       case PROP_EDITING_CANCELED:
         g_value_set_boolean (value, priv->editing_canceled);
         break;
 
+      case PROP_HAS_ENTRY:
+       g_value_set_boolean (value, priv->has_entry);
+       break;
+
+      case PROP_ENTRY_TEXT_COLUMN:
+       g_value_set_int (value, priv->text_column);
+       break;
+
+      case PROP_ID_COLUMN:
+        g_value_set_int (value, priv->id_column);
+        break;
+
+      case PROP_ACTIVE_ID:
+        g_value_set_string (value, gtk_combo_box_get_active_id (combo_box));
+        break;
+
+      case PROP_CELL_AREA:
+       g_value_set_object (value, priv->area);
+       break;
+
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -1096,35 +1244,43 @@ gtk_combo_box_state_changed (GtkWidget    *widget,
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
       if (priv->tree_view && priv->cell_view)
-       gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view), 
-                                           &widget->style->base[GTK_WIDGET_STATE (widget)]);
+        {
+          GtkStyleContext *context;
+          GtkStateFlags state;
+          GdkRGBA *color;
+
+          context  = gtk_widget_get_style_context (widget);
+          state = gtk_widget_get_state_flags (widget);
+
+          gtk_style_context_get (context, state,
+                                 "background-color", &color,
+                                 NULL);
+
+          gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), color);
+          gdk_rgba_free (color);
+        }
     }
 
   gtk_widget_queue_draw (widget);
 }
 
 static void
-gtk_combo_box_button_state_changed (GtkWidget    *widget,
-                                   GtkStateType  previous,
-                                   gpointer      data)
+gtk_combo_box_button_state_flags_changed (GtkWidget     *widget,
+                                          GtkStateFlags  previous,
+                                          gpointer       data)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
       if (!priv->tree_view && priv->cell_view)
-       {
-         if ((GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE) !=
-             (GTK_WIDGET_STATE (priv->cell_view) == GTK_STATE_INSENSITIVE))
-           gtk_widget_set_sensitive (priv->cell_view, GTK_WIDGET_SENSITIVE (widget));
-         
-         gtk_widget_set_state (priv->cell_view, 
-                               GTK_WIDGET_STATE (widget));
-       }
+        gtk_widget_set_state_flags (priv->cell_view,
+                                    gtk_widget_get_state_flags (widget),
+                                    TRUE);
     }
 
   gtk_widget_queue_draw (widget);
@@ -1145,7 +1301,7 @@ gtk_combo_box_check_appearance (GtkComboBox *combo_box)
     gtk_widget_style_get (GTK_WIDGET (combo_box),
                          "appears-as-list", &appears_as_list,
                          NULL);
-
+  
   if (appears_as_list)
     {
       /* Destroy all the menu mode widgets, if they exist. */
@@ -1173,20 +1329,33 @@ gtk_combo_box_check_appearance (GtkComboBox *combo_box)
 }
 
 static void
-gtk_combo_box_style_set (GtkWidget *widget,
-                         GtkStyle  *previous)
+gtk_combo_box_style_updated (GtkWidget *widget)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
   GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkWidget *child;
 
   gtk_combo_box_check_appearance (combo_box);
 
   if (priv->tree_view && priv->cell_view)
-    gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view), 
-                                       &widget->style->base[GTK_WIDGET_STATE (widget)]);
+    {
+      GtkStyleContext *context;
+      GdkRGBA *color;
+
+      context = gtk_widget_get_style_context (widget);
+      gtk_style_context_get (context, 0,
+                             "background-color", &color,
+                             NULL);
+
+      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view),
+                                         color);
+
+      gdk_rgba_free (color);
+    }
 
-  if (GTK_IS_ENTRY (GTK_BIN (combo_box)->child))
-    g_object_set (GTK_BIN (combo_box)->child, "shadow-type",
+  child = gtk_bin_get_child (GTK_BIN (combo_box));
+  if (GTK_IS_ENTRY (child))
+    g_object_set (child, "shadow-type",
                   GTK_SHADOW_NONE == priv->shadow_type ?
                   GTK_SHADOW_IN : GTK_SHADOW_NONE, NULL);
 }
@@ -1213,15 +1382,24 @@ gtk_combo_box_add (GtkContainer *container,
   GtkComboBox *combo_box = GTK_COMBO_BOX (container);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
-  if (priv->cell_view && priv->cell_view->parent)
+  if (priv->has_entry && !GTK_IS_ENTRY (widget))
+    {
+      g_warning ("Attempting to add a widget with type %s to a GtkComboBox that needs an entry "
+                "(need an instance of GtkEntry or of a subclass)",
+                 G_OBJECT_TYPE_NAME (widget));
+      return;
+    }
+
+  if (priv->cell_view &&
+      gtk_widget_get_parent (priv->cell_view))
     {
       gtk_widget_unparent (priv->cell_view);
-      GTK_BIN (container)->child = NULL;
+      _gtk_bin_set_child (GTK_BIN (container), NULL);
       gtk_widget_queue_resize (GTK_WIDGET (container));
     }
   
   gtk_widget_set_parent (widget, GTK_WIDGET (container));
-  GTK_BIN (container)->child = widget;
+  _gtk_bin_set_child (GTK_BIN (container), widget);
 
   if (priv->cell_view &&
       widget != priv->cell_view)
@@ -1231,8 +1409,8 @@ gtk_combo_box_add (GtkContainer *container,
 
       if (!priv->tree_view && priv->separator)
         {
-         gtk_container_remove (GTK_CONTAINER (priv->separator->parent),
-                               priv->separator);
+          gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->separator)),
+                                priv->separator);
          priv->separator = NULL;
 
           gtk_widget_queue_resize (GTK_WIDGET (container));
@@ -1244,6 +1422,19 @@ gtk_combo_box_add (GtkContainer *container,
           priv->box = NULL;
         }
     }
+
+  if (priv->has_entry)
+    {
+      /* this flag is a hack to tell the entry to fill its allocation.
+       */
+      _gtk_entry_set_is_cell_renderer (GTK_ENTRY (widget), TRUE);
+
+      g_signal_connect (widget, "changed",
+                       G_CALLBACK (gtk_combo_box_entry_contents_changed),
+                       combo_box);
+
+      gtk_entry_set_has_frame (GTK_ENTRY (widget), priv->has_frame);
+    }
 }
 
 static void
@@ -1255,13 +1446,27 @@ gtk_combo_box_remove (GtkContainer *container,
   GtkTreePath *path;
   gboolean appears_as_list;
 
+  if (priv->has_entry)
+    {
+      GtkWidget *child_widget;
+
+      child_widget = gtk_bin_get_child (GTK_BIN (container));
+      if (widget && widget == child_widget)
+       {
+         g_signal_handlers_disconnect_by_func (widget,
+                                               gtk_combo_box_entry_contents_changed,
+                                               container);
+          _gtk_entry_set_is_cell_renderer (GTK_ENTRY (widget), FALSE);
+       }
+    }
+
   if (widget == priv->cell_view)
     priv->cell_view = NULL;
 
   gtk_widget_unparent (widget);
-  GTK_BIN (container)->child = NULL;
+  _gtk_bin_set_child (GTK_BIN (container), NULL);
 
-  if (GTK_OBJECT_FLAGS (combo_box) & GTK_IN_DESTRUCTION)
+  if (gtk_widget_in_destruction (GTK_WIDGET (combo_box)))
     return;
 
   gtk_widget_queue_resize (GTK_WIDGET (container));
@@ -1284,12 +1489,11 @@ gtk_combo_box_remove (GtkContainer *container,
     {
       priv->cell_view = gtk_cell_view_new ();
       gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (container));
-      GTK_BIN (container)->child = priv->cell_view;
+      _gtk_bin_set_child (GTK_BIN (container), priv->cell_view);
       
       gtk_widget_show (priv->cell_view);
       gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view),
                               priv->model);
-      gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (priv->cell_view));
     }
 
 
@@ -1308,23 +1512,6 @@ gtk_combo_box_remove (GtkContainer *container,
     gtk_combo_box_set_active_internal (combo_box, NULL);
 }
 
-static ComboCellInfo *
-gtk_combo_box_get_cell_info (GtkComboBox     *combo_box,
-                             GtkCellRenderer *cell)
-{
-  GSList *i;
-
-  for (i = combo_box->priv->cells; i; i = i->next)
-    {
-      ComboCellInfo *info = (ComboCellInfo *)i->data;
-
-      if (info && info->cell == cell)
-        return info;
-    }
-
-  return NULL;
-}
-
 static void
 gtk_combo_box_menu_show (GtkWidget *menu,
                          gpointer   user_data)
@@ -1469,6 +1656,24 @@ gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
     }
 }
 
+static void
+get_widget_border (GtkWidget *widget,
+                   GtkBorder *border)
+{
+  GtkStyleContext *context;
+  GtkBorder *border_width;
+
+  context = gtk_widget_get_style_context (widget);
+
+  gtk_style_context_get (context,
+                         gtk_widget_get_state_flags (widget),
+                         "border-width", &border_width,
+                         NULL);
+
+  *border = *border_width;
+  gtk_border_free (border_width);
+}
+
 static void
 gtk_combo_box_menu_position_below (GtkMenu  *menu,
                                   gint     *x,
@@ -1477,40 +1682,47 @@ gtk_combo_box_menu_position_below (GtkMenu  *menu,
                                   gpointer  user_data)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+  GtkAllocation child_allocation;
   gint sx, sy;
   GtkWidget *child;
   GtkRequisition req;
   GdkScreen *screen;
   gint monitor_num;
   GdkRectangle monitor;
-  
+  GtkBorder border;
+
   /* FIXME: is using the size request here broken? */
-  child = GTK_BIN (combo_box)->child;
+  child = gtk_bin_get_child (GTK_BIN (combo_box));
 
   sx = sy = 0;
 
+  gtk_widget_get_allocation (child, &child_allocation);
+
   if (!gtk_widget_get_has_window (child))
     {
-      sx += child->allocation.x;
-      sy += child->allocation.y;
+      sx += child_allocation.x;
+      sy += child_allocation.y;
     }
 
-  gdk_window_get_root_coords (child->window, sx, sy, &sx, &sy);
+  gdk_window_get_root_coords (gtk_widget_get_window (child),
+                              sx, sy, &sx, &sy);
+  get_widget_border (GTK_WIDGET (combo_box), &border);
+  sx -= border.left;
 
-  if (GTK_SHADOW_NONE != combo_box->priv->shadow_type)
-    sx -= GTK_WIDGET (combo_box)->style->xthickness;
-
-  gtk_widget_size_request (GTK_WIDGET (menu), &req);
+  if (combo_box->priv->popup_fixed_width)
+    gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+  else
+    gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
 
   if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
     *x = sx;
   else
-    *x = sx + child->allocation.width - req.width;
+    *x = sx + child_allocation.width - req.width;
   *y = sy;
 
   screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
   monitor_num = gdk_screen_get_monitor_at_window (screen, 
-                                                 GTK_WIDGET (combo_box)->window);
+                                                  gtk_widget_get_window (GTK_WIDGET (combo_box)));
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
   
   if (*x < monitor.x)
@@ -1518,12 +1730,12 @@ gtk_combo_box_menu_position_below (GtkMenu  *menu,
   else if (*x + req.width > monitor.x + monitor.width)
     *x = monitor.x + monitor.width - req.width;
   
-  if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
-    *y += child->allocation.height;
+  if (monitor.y + monitor.height - *y - child_allocation.height >= req.height)
+    *y += child_allocation.height;
   else if (*y - monitor.y >= req.height)
     *y -= req.height;
-  else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) 
-    *y += child->allocation.height;
+  else if (monitor.y + monitor.height - *y - child_allocation.height > *y - monitor.y)
+    *y += child_allocation.height;
   else
     *y -= req.height;
 
@@ -1537,32 +1749,37 @@ gtk_combo_box_menu_position_over (GtkMenu  *menu,
                                  gboolean *push_in,
                                  gpointer  user_data)
 {
-  GtkComboBox *combo_box;
-  GtkWidget *active;
-  GtkWidget *child;
-  GtkWidget *widget;
-  GtkRequisition requisition;
-  GList *children;
-  gint screen_width;
-  gint menu_xpos;
-  gint menu_ypos;
-  gint menu_width;
+  GtkComboBox    *combo_box;
+  GtkWidget      *active;
+  GtkWidget      *child;
+  GtkWidget      *widget;
+  GtkAllocation   allocation;
+  GtkAllocation   child_allocation;
+  GList          *children;
+  gint            screen_width;
+  gint            menu_xpos;
+  gint            menu_ypos;
+  gint            menu_width;
 
   combo_box = GTK_COMBO_BOX (user_data);
   widget = GTK_WIDGET (combo_box);
 
-  gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
-  menu_width = requisition.width;
-
   active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
 
-  menu_xpos = widget->allocation.x;
-  menu_ypos = widget->allocation.y + widget->allocation.height / 2 - 2;
+  gtk_widget_get_allocation (widget, &allocation);
+
+  menu_xpos = allocation.x;
+  menu_ypos = allocation.y + allocation.height / 2 - 2;
+
+  if (combo_box->priv->popup_fixed_width)
+    gtk_widget_get_preferred_width (GTK_WIDGET (menu), &menu_width, NULL);
+  else
+    gtk_widget_get_preferred_width (GTK_WIDGET (menu), NULL, &menu_width);
 
   if (active != NULL)
     {
-      gtk_widget_get_child_requisition (active, &requisition);
-      menu_ypos -= requisition.height / 2;
+      gtk_widget_get_allocation (active, &child_allocation);
+      menu_ypos -= child_allocation.height / 2;
     }
 
   children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
@@ -1573,19 +1790,21 @@ gtk_combo_box_menu_position_over (GtkMenu  *menu,
       if (active == child)
        break;
 
-      if (GTK_WIDGET_VISIBLE (child))
+      if (gtk_widget_get_visible (child))
        {
-         gtk_widget_get_child_requisition (child, &requisition);
-         menu_ypos -= requisition.height;
+         gtk_widget_get_allocation (child, &child_allocation);
+
+         menu_ypos -= child_allocation.height;
        }
 
       children = children->next;
     }
 
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-    menu_xpos = menu_xpos + widget->allocation.width - menu_width;
+    menu_xpos = menu_xpos + allocation.width - menu_width;
 
-  gdk_window_get_root_coords (widget->window, menu_xpos, menu_ypos,
+  gdk_window_get_root_coords (gtk_widget_get_window (widget),
+                              menu_xpos, menu_ypos,
                              &menu_xpos, &menu_ypos);
 
   /* Clamp the position on screen */
@@ -1613,7 +1832,6 @@ gtk_combo_box_menu_position (GtkMenu  *menu,
   GtkComboBoxPrivate *priv = combo_box->priv;
   GtkWidget *menu_item;
 
-
   if (priv->wrap_width > 0 || priv->cell_view == NULL) 
     gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
   else
@@ -1627,7 +1845,7 @@ gtk_combo_box_menu_position (GtkMenu  *menu,
       gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
     }
 
-  if (!GTK_WIDGET_VISIBLE (GTK_MENU (priv->popup_widget)->toplevel))
+  if (!gtk_widget_get_visible (GTK_MENU (priv->popup_widget)->toplevel))
     gtk_window_set_type_hint (GTK_WINDOW (GTK_MENU (priv->popup_widget)->toplevel),
                               GDK_WINDOW_TYPE_HINT_COMBO);
 }
@@ -1640,60 +1858,87 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
                             gint        *height)
 {
   GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkAllocation allocation;
   GdkScreen *screen;
   gint monitor_num;
   GdkRectangle monitor;
   GtkRequisition popup_req;
   GtkPolicyType hpolicy, vpolicy;
-  
+  GdkWindow *window;
+
   /* under windows, the drop down list is as wide as the combo box itself.
      see bug #340204 */
-  GtkWidget *sample = GTK_WIDGET (combo_box);
+  GtkWidget *widget = GTK_WIDGET (combo_box);
 
   *x = *y = 0;
 
-  if (!gtk_widget_get_has_window (sample))
+  gtk_widget_get_allocation (widget, &allocation);
+
+  if (!gtk_widget_get_has_window (widget))
     {
-      *x += sample->allocation.x;
-      *y += sample->allocation.y;
+      *x += allocation.x;
+      *y += allocation.y;
     }
-  
-  gdk_window_get_root_coords (sample->window, *x, *y, x, y);
 
-  *width = sample->allocation.width;
+  window = gtk_widget_get_window (widget);
+
+  gdk_window_get_root_coords (gtk_widget_get_window (widget),
+                              *x, *y, x, y);
+
+  *width = allocation.width;
 
   hpolicy = vpolicy = GTK_POLICY_NEVER;
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
                                  hpolicy, vpolicy);
-  gtk_widget_size_request (priv->scrolled_window, &popup_req);
 
-  if (popup_req.width > *width)
+  if (combo_box->priv->popup_fixed_width)
     {
-      hpolicy = GTK_POLICY_ALWAYS;
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
-                                     hpolicy, vpolicy);
-      gtk_widget_size_request (priv->scrolled_window, &popup_req);
+      gtk_widget_get_preferred_size (priv->scrolled_window, &popup_req, NULL);
+
+      if (popup_req.width > *width)
+       {
+         hpolicy = GTK_POLICY_ALWAYS;
+         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
+                                         hpolicy, vpolicy);
+       }
+    }
+  else
+    {
+      /* XXX This code depends on treeviews properly reporting their natural width
+       * list-mode menus won't fill up to their natural width until then */
+      gtk_widget_get_preferred_size (priv->scrolled_window, NULL, &popup_req);
+
+      if (popup_req.width > *width)
+       {
+         hpolicy = GTK_POLICY_NEVER;
+         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
+                                         hpolicy, vpolicy);
+
+         *width = popup_req.width;
+       }
     }
 
   *height = popup_req.height;
 
   screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
-  monitor_num = gdk_screen_get_monitor_at_window (screen, 
-                                                 GTK_WIDGET (combo_box)->window);
+  monitor_num = gdk_screen_get_monitor_at_window (screen, window);
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
+  if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_RTL)
+    *x = *x + allocation.width - *width;
+
   if (*x < monitor.x)
     *x = monitor.x;
   else if (*x + *width > monitor.x + monitor.width)
     *x = monitor.x + monitor.width - *width;
   
-  if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
-    *y += sample->allocation.height;
+  if (*y + allocation.height + *height <= monitor.y + monitor.height)
+    *y += allocation.height;
   else if (*y - *height >= monitor.y)
     *y -= *height;
-  else if (monitor.y + monitor.height - (*y + sample->allocation.height) > *y - monitor.y)
+  else if (monitor.y + monitor.height - (*y + allocation.height) > *y - monitor.y)
     {
-      *y += sample->allocation.height;
+      *y += allocation.height;
       *height = monitor.y + monitor.height - *y;
     }
   else 
@@ -1787,7 +2032,7 @@ update_menu_sensitivity (GtkComboBox *combo_box,
   for (child = children; child; child = child->next)
     {
       item = GTK_WIDGET (child->data);
-      cell_view = GTK_BIN (item)->child;
+      cell_view = gtk_bin_get_child (GTK_BIN (item));
 
       if (!GTK_IS_CELL_VIEW (cell_view))
        continue;
@@ -1824,8 +2069,7 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
   GtkComboBoxPrivate *priv = combo_box->priv;
   GtkTreePath *path;
   gint active_item;
-  GtkRequisition requisition;
-  gint width;
+  gint width, min_width, nat_width;
   
   update_menu_sensitivity (combo_box, priv->popup_widget);
 
@@ -1845,12 +2089,19 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
   
   if (priv->wrap_width == 0)
     {
-      width = GTK_WIDGET (combo_box)->allocation.width;
+      GtkAllocation allocation;
+
+      gtk_widget_get_allocation (GTK_WIDGET (combo_box), &allocation);
+      width = allocation.width;
       gtk_widget_set_size_request (priv->popup_widget, -1, -1);
-      gtk_widget_size_request (priv->popup_widget, &requisition);
-      
-      gtk_widget_set_size_request (priv->popup_widget,
-                                  MAX (width, requisition.width), -1);
+      gtk_widget_get_preferred_width (priv->popup_widget, &min_width, &nat_width);
+
+      if (combo_box->priv->popup_fixed_width)
+       width = MAX (width, min_width);
+      else
+       width = MAX (width, nat_width);
+
+      gtk_widget_set_size_request (priv->popup_widget, width, -1);
     }
   
   gtk_menu_popup (GTK_MENU (priv->popup_widget),
@@ -1861,27 +2112,31 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
 
 static gboolean
 popup_grab_on_window (GdkWindow *window,
-                     guint32    activate_time,
-                     gboolean   grab_keyboard)
-{
-  if ((gdk_pointer_grab (window, TRUE,
-                        GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
-                        GDK_POINTER_MOTION_MASK,
-                        NULL, NULL, activate_time) == 0))
+                      GdkDevice *keyboard,
+                      GdkDevice *pointer,
+                     guint32    activate_time)
+{
+  if (keyboard &&
+      gdk_device_grab (keyboard, window,
+                       GDK_OWNERSHIP_WINDOW, TRUE,
+                       GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
+                       NULL, activate_time) != GDK_GRAB_SUCCESS)
+    return FALSE;
+
+  if (pointer &&
+      gdk_device_grab (pointer, window,
+                       GDK_OWNERSHIP_WINDOW, TRUE,
+                       GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+                       GDK_POINTER_MOTION_MASK,
+                       NULL, activate_time) != GDK_GRAB_SUCCESS)
     {
-      if (!grab_keyboard ||
-         gdk_keyboard_grab (window, TRUE,
-                            activate_time) == 0)
-       return TRUE;
-      else
-       {
-         gdk_display_pointer_ungrab (gdk_drawable_get_display (window),
-                                     activate_time);
-         return FALSE;
-       }
+      if (keyboard)
+        gdk_device_ungrab (keyboard, activate_time);
+
+      return FALSE;
     }
 
-  return FALSE;
+  return TRUE;
 }
 
 /**
@@ -1903,20 +2158,53 @@ gtk_combo_box_popup (GtkComboBox *combo_box)
   g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
 }
 
-static void
-gtk_combo_box_real_popup (GtkComboBox *combo_box)
+/**
+ * gtk_combo_box_popup_for_device:
+ * @combo_box: a #GtkComboBox
+ * @device: a #GdkDevice
+ *
+ * Pops up the menu or dropdown list of @combo_box, the popup window
+ * will be grabbed so only @device and its associated pointer/keyboard
+ * are the only #GdkDevice<!-- -->s able to send events to it.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
+                                GdkDevice   *device)
 {
   GtkComboBoxPrivate *priv = combo_box->priv;
   gint x, y, width, height;
   GtkTreePath *path = NULL, *ppath;
   GtkWidget *toplevel;
+  GdkDevice *keyboard, *pointer;
+  guint32 time;
+
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
+    return;
 
-  if (!GTK_WIDGET_REALIZED (combo_box))
+  if (gtk_widget_get_mapped (priv->popup_widget))
     return;
 
-  if (GTK_WIDGET_MAPPED (priv->popup_widget))
+  if (priv->grab_pointer && priv->grab_keyboard)
     return;
 
+  time = gtk_get_current_event_time ();
+
+  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+    {
+      keyboard = device;
+      pointer = gdk_device_get_associated_device (device);
+    }
+  else
+    {
+      pointer = device;
+      keyboard = gdk_device_get_associated_device (device);
+    }
+
   if (GTK_IS_MENU (priv->popup_widget))
     {
       gtk_combo_box_menu_popup (combo_box, 
@@ -1962,17 +2250,44 @@ gtk_combo_box_real_popup (GtkComboBox *combo_box)
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
                                 TRUE);
 
-  if (!GTK_WIDGET_HAS_FOCUS (priv->tree_view))
+  if (!gtk_widget_has_focus (priv->tree_view))
     gtk_widget_grab_focus (priv->tree_view);
 
-  if (!popup_grab_on_window (priv->popup_window->window,
-                            GDK_CURRENT_TIME, TRUE))
+  if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window),
+                            keyboard, pointer, time))
     {
       gtk_widget_hide (priv->popup_window);
       return;
     }
 
-  gtk_grab_add (priv->popup_window);
+  gtk_device_grab_add (priv->popup_window, pointer, TRUE);
+  priv->grab_pointer = pointer;
+  priv->grab_keyboard = keyboard;
+}
+
+static void
+gtk_combo_box_real_popup (GtkComboBox *combo_box)
+{
+  GdkDevice *device;
+
+  device = gtk_get_current_event_device ();
+
+  if (!device)
+    {
+      GdkDeviceManager *device_manager;
+      GdkDisplay *display;
+      GList *devices;
+
+      display = gtk_widget_get_display (GTK_WIDGET (combo_box));
+      device_manager = gdk_display_get_device_manager (display);
+
+      /* No device was set, pick the first master device */
+      devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
+      device = devices->data;
+      g_list_free (devices);
+    }
+
+  gtk_combo_box_popup_for_device (combo_box, device);
 }
 
 static gboolean
@@ -2011,265 +2326,77 @@ gtk_combo_box_popdown (GtkComboBox *combo_box)
       return;
     }
 
-  if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box)))
+  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
     return;
 
-  gtk_grab_remove (priv->popup_window);
-  gtk_widget_hide_all (priv->popup_window);
+  gtk_device_grab_remove (priv->popup_window, priv->grab_pointer);
+  gtk_widget_hide (priv->popup_window);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
                                 FALSE);
-}
-
-static gint
-gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
-                                    GtkTreePath *path)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  gint padding;
-  GtkRequisition req;
-
-  if (priv->cell_view)
-    gtk_widget_style_get (priv->cell_view,
-                          "focus-line-width", &padding,
-                          NULL);
-  else
-    padding = 0;
-
-  /* add some pixels for good measure */
-  padding += BONUS_PADDING;
-
-  if (priv->cell_view)
-    gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (priv->cell_view),
-                                   path, &req);
-  else
-    req.width = 0;
 
-  return req.width + padding;
-}
-
-static void
-gtk_combo_box_remeasure (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkTreeIter iter;
-  GtkTreePath *path;
-
-  if (!priv->model ||
-      !gtk_tree_model_get_iter_first (priv->model, &iter))
-    return;
-
-  priv->width = 0;
-  priv->height = 0;
-
-  path = gtk_tree_path_new_from_indices (0, -1);
-
-  do
-    {
-      GtkRequisition req;
-
-      if (priv->cell_view)
-       gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (priv->cell_view), 
-                                       path, &req);
-      else
-        {
-          req.width = 0;
-          req.height = 0;
-        }
-
-      priv->width = MAX (priv->width, req.width);
-      priv->height = MAX (priv->height, req.height);
-
-      gtk_tree_path_next (path);
-    }
-  while (gtk_tree_model_iter_next (priv->model, &iter));
-
-  gtk_tree_path_free (path);
-}
-
-static void
-gtk_combo_box_size_request (GtkWidget      *widget,
-                            GtkRequisition *requisition)
-{
-  gint width, height;
-  gint focus_width, focus_pad;
-  gint font_size;
-  gint arrow_size;
-  GtkRequisition bin_req;
-  PangoContext *context;
-  PangoFontMetrics *metrics;
-  PangoFontDescription *font_desc;
-
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  /* common */
-  gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
-  gtk_combo_box_remeasure (combo_box);
-  bin_req.width = MAX (bin_req.width, priv->width);
-  bin_req.height = MAX (bin_req.height, priv->height);
-
-  gtk_widget_style_get (GTK_WIDGET (widget),
-                       "focus-line-width", &focus_width,
-                       "focus-padding", &focus_pad,
-                       "arrow-size", &arrow_size,
-                       NULL);
-
-  font_desc = GTK_BIN (widget)->child->style->font_desc;
-  context = gtk_widget_get_pango_context (widget);
-  metrics = pango_context_get_metrics (context, font_desc,
-                                      pango_context_get_language (context));
-  font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
-                           pango_font_metrics_get_descent (metrics));
-  pango_font_metrics_unref (metrics);
-
-  arrow_size = MAX (arrow_size, font_size);
-
-  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
-
-  if (!priv->tree_view)
-    {
-      /* menu mode */
-
-      if (priv->cell_view)
-        {
-          GtkRequisition button_req, sep_req, arrow_req;
-          gint border_width, xthickness, ythickness;
-
-          gtk_widget_size_request (priv->button, &button_req);
-         border_width = GTK_CONTAINER (combo_box)->border_width;
-          xthickness = priv->button->style->xthickness;
-          ythickness = priv->button->style->ythickness;
-
-          bin_req.width = MAX (bin_req.width, priv->width);
-          bin_req.height = MAX (bin_req.height, priv->height);
-
-          gtk_widget_size_request (priv->separator, &sep_req);
-          gtk_widget_size_request (priv->arrow, &arrow_req);
-
-          height = MAX (sep_req.height, arrow_req.height);
-          height = MAX (height, bin_req.height);
-
-          width = bin_req.width + sep_req.width + arrow_req.width;
-
-          height += 2*(border_width + ythickness + focus_width + focus_pad);
-          width  += 2*(border_width + xthickness + focus_width + focus_pad);
-
-          requisition->width = width;
-          requisition->height = height;
-        }
-      else
-        {
-          GtkRequisition but_req;
-
-          gtk_widget_size_request (priv->button, &but_req);
-
-          requisition->width = bin_req.width + but_req.width;
-          requisition->height = MAX (bin_req.height, but_req.height);
-        }
-    }
-  else
-    {
-      /* list mode */
-      GtkRequisition button_req, frame_req;
-
-      /* sample + frame */
-      *requisition = bin_req;
-
-      requisition->width += 2 * focus_width;
-      
-      if (priv->cell_view_frame)
-        {
-         gtk_widget_size_request (priv->cell_view_frame, &frame_req);
-         if (priv->has_frame)
-           {
-             requisition->width += 2 *
-               (GTK_CONTAINER (priv->cell_view_frame)->border_width +
-                GTK_WIDGET (priv->cell_view_frame)->style->xthickness);
-             requisition->height += 2 *
-               (GTK_CONTAINER (priv->cell_view_frame)->border_width +
-                GTK_WIDGET (priv->cell_view_frame)->style->ythickness);
-           }
-        }
-
-      /* the button */
-      gtk_widget_size_request (priv->button, &button_req);
-
-      requisition->height = MAX (requisition->height, button_req.height);
-      requisition->width += button_req.width;
-    }
-
-  if (GTK_SHADOW_NONE != priv->shadow_type)
-    {
-      requisition->height += 2 * widget->style->ythickness;
-      requisition->width += 2 * widget->style->xthickness;
-    }
+  priv->grab_pointer = NULL;
+  priv->grab_keyboard = NULL;
 }
 
 #define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON                                     \
-  gtk_widget_size_request (combo_box->priv->button, &req);                     \
+  gtk_widget_get_preferred_size (combo_box->priv->button,                      \
+                                 &req, NULL);                                  \
                                                                                \
   if (is_rtl)                                                                  \
-    child.x = allocation->x + shadow_width;                                    \
+    child.x = allocation->x + border.right;                                    \
   else                                                                         \
-    child.x = allocation->x + allocation->width - req.width - shadow_width;    \
+    child.x = allocation->x + allocation->width - req.width - border.left;     \
                                                                                \
-  child.y = allocation->y + shadow_height;                                     \
+  child.y = allocation->y + border.top;                                                \
   child.width = req.width;                                                     \
-  child.height = allocation->height - 2 * shadow_height;                       \
+  child.height = allocation->height - (border.top + border.bottom);            \
   child.width = MAX (1, child.width);                                          \
   child.height = MAX (1, child.height);                                                \
                                                                                \
   gtk_widget_size_allocate (combo_box->priv->button, &child);
 
+
 static void
 gtk_combo_box_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
   GtkComboBoxPrivate *priv = combo_box->priv;
-  gint shadow_width, shadow_height;
+  GtkWidget *child_widget;
   gint focus_width, focus_pad;
   GtkAllocation child;
   GtkRequisition req;
   gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
+  GtkBorder border;
 
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
+  child_widget = gtk_bin_get_child (GTK_BIN (widget));
+  get_widget_border (widget, &border);
 
-  gtk_widget_style_get (GTK_WIDGET (widget),
+  gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "focus-padding", &focus_pad,
                        NULL);
 
-  if (GTK_SHADOW_NONE != priv->shadow_type)
-    {
-      shadow_width = widget->style->xthickness;
-      shadow_height = widget->style->ythickness;
-    }
-  else
-    {
-      shadow_width = 0;
-      shadow_height = 0;
-    }
-
   if (!priv->tree_view)
     {
       if (priv->cell_view)
         {
-          gint border_width, xthickness, ythickness;
+         GtkBorder button_border;
           gint width;
+          guint border_width;
 
           /* menu mode */
-          allocation->x += shadow_width;
-          allocation->y += shadow_height;
-          allocation->width -= 2 * shadow_width;
-          allocation->height -= 2 * shadow_height;
+          allocation->x += border.left;
+          allocation->y += border.top;
+          allocation->width -= border.left + border.right;
+          allocation->height -= border.top + border.bottom;
 
           gtk_widget_size_allocate (priv->button, allocation);
 
           /* set some things ready */
-          border_width = GTK_CONTAINER (priv->button)->border_width;
-          xthickness = priv->button->style->xthickness;
-          ythickness = priv->button->style->ythickness;
+          border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button));
+         get_widget_border (priv->button, &button_border);
 
           child.x = allocation->x;
           child.y = allocation->y;
@@ -2278,15 +2405,16 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
 
          if (!priv->is_cell_renderer)
            {
-             child.x += border_width + xthickness + focus_width + focus_pad;
-             child.y += border_width + ythickness + focus_width + focus_pad;
-             width -= 2 * (child.x - allocation->x);
-             child.height -= 2 * (child.y - allocation->y);
+             child.x += border_width + button_border.left + focus_width + focus_pad;
+             child.y += border_width + button_border.top + focus_width + focus_pad;
+             width -= (2 * (border_width + focus_width + focus_pad)) +
+                button_border.left + button_border.right;
+             child.height -= (2 * (border_width + focus_width + focus_pad)) +
+                button_border.top + button_border.bottom;
            }
 
-
           /* handle the children */
-          gtk_widget_size_request (priv->arrow, &req);
+          gtk_widget_get_preferred_size (priv->arrow, &req, NULL);
           child.width = req.width;
           if (!is_rtl)
             child.x += width - req.width;
@@ -2295,7 +2423,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
           gtk_widget_size_allocate (priv->arrow, &child);
           if (is_rtl)
             child.x += req.width;
-          gtk_widget_size_request (priv->separator, &req);
+          gtk_widget_get_preferred_size (priv->separator, &req, NULL);
           child.width = req.width;
           if (!is_rtl)
             child.x -= req.width;
@@ -2307,60 +2435,65 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
             {
               child.x += req.width;
               child.width = allocation->x + allocation->width 
-                - (border_width + xthickness + focus_width + focus_pad) 
+                - (border_width + button_border.right + focus_width + focus_pad) 
                - child.x;
             }
           else 
             {
               child.width = child.x;
               child.x = allocation->x 
-               + border_width + xthickness + focus_width + focus_pad;
+               + border_width + button_border.left + focus_width + focus_pad;
               child.width -= child.x;
             }
 
-          if (GTK_WIDGET_VISIBLE (priv->popup_widget))
+          if (gtk_widget_get_visible (priv->popup_widget))
             {
-              gint width;
-              GtkRequisition requisition;
+              gint width, menu_width;
 
-              /* Warning here, without the check in the position func */
-              gtk_menu_reposition (GTK_MENU (priv->popup_widget));
               if (priv->wrap_width == 0)
                 {
-                  width = GTK_WIDGET (combo_box)->allocation.width;
+                  GtkAllocation combo_box_allocation;
+
+                  gtk_widget_get_allocation (GTK_WIDGET (combo_box), &combo_box_allocation);
+                  width = combo_box_allocation.width;
                   gtk_widget_set_size_request (priv->popup_widget, -1, -1);
-                  gtk_widget_size_request (priv->popup_widget, &requisition);
+
+                 if (combo_box->priv->popup_fixed_width)
+                   gtk_widget_get_preferred_width (priv->popup_widget, &menu_width, NULL);
+                 else
+                   gtk_widget_get_preferred_width (priv->popup_widget, NULL, &menu_width);
+
                   gtk_widget_set_size_request (priv->popup_widget,
-                    MAX (width, requisition.width), -1);
+                                              MAX (width, menu_width), -1);
                }
+
+              /* reposition the menu after giving it a new width */
+              gtk_menu_reposition (GTK_MENU (priv->popup_widget));
             }
 
          child.width = MAX (1, child.width);
          child.height = MAX (1, child.height);
-          gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
+          gtk_widget_size_allocate (child_widget, &child);
         }
       else
         {
           GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
 
           if (is_rtl)
-            child.x = allocation->x + req.width + shadow_width;
+            child.x = allocation->x + req.width + border.right;
           else
-            child.x = allocation->x + shadow_width;
-          child.y = allocation->y + shadow_height;
-          child.width = allocation->width - req.width - 2 * shadow_width;
+            child.x = allocation->x + border.left;
+          child.y = allocation->y + border.top;
+          child.width = allocation->width - req.width - (border.left + border.right);
          child.width = MAX (1, child.width);
          child.height = MAX (1, child.height);
-          gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
+          gtk_widget_size_allocate (child_widget, &child);
         }
     }
   else
     {
       /* list mode */
-
-      /* Combobox thickness + border-width */
-      int delta_x = shadow_width + GTK_CONTAINER (widget)->border_width;
-      int delta_y = shadow_height + GTK_CONTAINER (widget)->border_width;
+      guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
       /* button */
       GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON
@@ -2377,35 +2510,35 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
 
       if (priv->cell_view_frame)
         {
-          child.x += delta_x;
-          child.y += delta_y;
-          child.width = MAX (1, child.width - delta_x * 2);
-          child.height = MAX (1, child.height - delta_y * 2);
+          child.x += border.left + border_width;
+          child.y += border.top + border_width;
+          child.width = MAX (1, child.width - (2 * border_width) - (border.left + border.right));
+          child.height = MAX (1, child.height - (2 * border_width) - (border.top + border.bottom));
           gtk_widget_size_allocate (priv->cell_view_frame, &child);
 
           /* the sample */
           if (priv->has_frame)
             {
-              delta_x = GTK_CONTAINER (priv->cell_view_frame)->border_width +
-                GTK_WIDGET (priv->cell_view_frame)->style->xthickness;
-              delta_y = GTK_CONTAINER (priv->cell_view_frame)->border_width +
-                GTK_WIDGET (priv->cell_view_frame)->style->ythickness;
-
-              child.x += delta_x;
-              child.y += delta_y;
-              child.width -= delta_x * 2;
-              child.height -= delta_y * 2;
+             GtkBorder frame_border;
+
+              border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
+             get_widget_border (priv->cell_view_frame, &frame_border);
+
+              child.x += border_width + frame_border.left;
+              child.y += border_width + frame_border.right;
+              child.width -= (2 * border_width) + frame_border.left + frame_border.right;
+              child.height -= (2 * border_width) + frame_border.top + frame_border.bottom;
             }
         }
       else
         {
-          child.x += delta_x;
-          child.y += delta_y;
-          child.width -= delta_x * 2;
-          child.height -= delta_y * 2;
+          child.x += border.left + border_width;
+          child.y += border.top + border_width;
+          child.width -= (2 * border_width) - (border.left + border.right);
+          child.height -= (2 * border_width) - (border.top + border.bottom);
         }
 
-      if (GTK_WIDGET_VISIBLE (priv->popup_window))
+      if (gtk_widget_get_visible (priv->popup_window))
         {
           gint x, y, width, height;
           gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
@@ -2417,7 +2550,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
       child.width = MAX (1, child.width);
       child.height = MAX (1, child.height);
       
-      gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child);
+      gtk_widget_size_allocate (child_widget, &child);
     }
 }
 
@@ -2440,14 +2573,6 @@ gtk_combo_box_unset_model (GtkComboBox *combo_box)
                                   priv->changed_id);
     }
 
-  /* menu mode */
-  if (!priv->tree_view)
-    {
-      if (priv->popup_widget)
-        gtk_container_foreach (GTK_CONTAINER (priv->popup_widget),
-                               (GtkCallback)gtk_widget_destroy, NULL);
-    }
-
   if (priv->model)
     {
       g_object_unref (priv->model);
@@ -2472,6 +2597,7 @@ gtk_combo_box_forall (GtkContainer *container,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (container);
   GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkWidget *child;
 
   if (include_internals)
     {
@@ -2481,8 +2607,9 @@ gtk_combo_box_forall (GtkContainer *container,
        (* callback) (priv->cell_view_frame, callback_data);
     }
 
-  if (GTK_BIN (container)->child)
-    (* callback) (GTK_BIN (container)->child, callback_data);
+  child = gtk_bin_get_child (GTK_BIN (container));
+  if (child)
+    (* callback) (child, callback_data);
 }
 
 static void 
@@ -2506,33 +2633,41 @@ gtk_combo_box_child_hide (GtkWidget *widget,
 }
 
 static gboolean
-gtk_combo_box_expose_event (GtkWidget      *widget,
-                            GdkEventExpose *event)
+gtk_combo_box_draw (GtkWidget *widget,
+                    cairo_t   *cr)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
-  if (gtk_widget_is_drawable (widget) &&
-      GTK_SHADOW_NONE != priv->shadow_type)
+  if (priv->shadow_type != GTK_SHADOW_NONE)
     {
-      gtk_paint_shadow (widget->style, widget->window,
-                        GTK_STATE_NORMAL, priv->shadow_type,
-                        NULL, widget, "combobox",
-                        widget->allocation.x, widget->allocation.y,
-                        widget->allocation.width, widget->allocation.height);
+      GtkStyleContext *context;
+      GtkStateFlags state;
+
+      context = gtk_widget_get_style_context (widget);
+      state = gtk_widget_get_state_flags (widget);
+      gtk_style_context_set_state (context, state);
+
+      gtk_render_background (context, cr, 0, 0,
+                             gtk_widget_get_allocated_width (widget),
+                             gtk_widget_get_allocated_height (widget));
+      gtk_render_frame (context, cr, 0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
     }
 
-  gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                 priv->button, event);
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                               priv->button, cr);
 
   if (priv->tree_view && priv->cell_view_frame)
     {
-      gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                     priv->cell_view_frame, event);
+      gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                                   priv->cell_view_frame, cr);
     }
 
-  gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                  GTK_BIN (widget)->child, event);
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                                gtk_bin_get_child (GTK_BIN (widget)),
+                                cr);
 
   return FALSE;
 }
@@ -2774,37 +2909,28 @@ gtk_combo_box_scroll_event (GtkWidget          *widget,
  * menu style
  */
 
-static void
-gtk_combo_box_sync_cells (GtkComboBox   *combo_box,
-                         GtkCellLayout *cell_layout)
+static gboolean 
+gtk_combo_box_row_separator_func (GtkTreeModel      *model,
+                                 GtkTreeIter       *iter,
+                                 GtkComboBox       *combo)
 {
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GSList *k;
-
-  for (k = priv->cells; k; k = k->next)
-    {
-      GSList *j;
-      ComboCellInfo *info = (ComboCellInfo *)k->data;
+  GtkComboBoxPrivate *priv = combo->priv;
 
-      if (info->pack == GTK_PACK_START)
-        gtk_cell_layout_pack_start (cell_layout,
-                                    info->cell, info->expand);
-      else if (info->pack == GTK_PACK_END)
-        gtk_cell_layout_pack_end (cell_layout,
-                                  info->cell, info->expand);
+  if (priv->row_separator_func)
+    return priv->row_separator_func (model, iter, priv->row_separator_data);
 
-      gtk_cell_layout_set_cell_data_func (cell_layout,
-                                          info->cell,
-                                          combo_cell_data_func, info, NULL);
+  return FALSE;
+}
 
-      for (j = info->attributes; j; j = j->next->next)
-        {
-          gtk_cell_layout_add_attribute (cell_layout,
-                                         info->cell,
-                                         j->data,
-                                         GPOINTER_TO_INT (j->next->data));
-        }
-    }
+static gboolean 
+gtk_combo_box_header_func (GtkTreeModel      *model,
+                          GtkTreeIter       *iter,
+                          GtkComboBox       *combo)
+{
+  /* Every submenu has a selectable header, however we
+   * can expose a method to make that configurable by 
+   * the user (like row_separator_func is done) */
+  return TRUE;
 }
 
 static void
@@ -2812,8 +2938,11 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
                           gboolean     add_children)
 {
   GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkWidget *child;
   GtkWidget *menu;
 
+  child = gtk_bin_get_child (GTK_BIN (combo_box));
+
   if (priv->cell_view)
     {
       priv->button = gtk_toggle_button_new ();
@@ -2823,12 +2952,12 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
       g_signal_connect (priv->button, "toggled",
                         G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
       gtk_widget_set_parent (priv->button,
-                             GTK_BIN (combo_box)->child->parent);
+                             gtk_widget_get_parent (child));
 
-      priv->box = gtk_hbox_new (FALSE, 0);
+      priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
       gtk_container_add (GTK_CONTAINER (priv->button), priv->box);
 
-      priv->separator = gtk_vseparator_new ();
+      priv->separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
       gtk_container_add (GTK_CONTAINER (priv->box), priv->separator);
 
       priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
@@ -2845,7 +2974,7 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
       g_signal_connect (priv->button, "toggled",
                         G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
       gtk_widget_set_parent (priv->button,
-                             GTK_BIN (combo_box)->child->parent);
+                             gtk_widget_get_parent (child));
 
       priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
       gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
@@ -2855,158 +2984,41 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
   g_signal_connect (priv->button, "button-press-event",
                     G_CALLBACK (gtk_combo_box_menu_button_press),
                     combo_box);
-  g_signal_connect (priv->button, "state-changed",
-                   G_CALLBACK (gtk_combo_box_button_state_changed), 
+  g_signal_connect (priv->button, "state-flags-changed",
+                   G_CALLBACK (gtk_combo_box_button_state_flags_changed), 
                    combo_box);
 
   /* create our funky menu */
-  menu = gtk_menu_new ();
+  menu = gtk_tree_menu_new_with_area (priv->area);
   gtk_widget_set_name (menu, "gtk-combobox-popup-menu");
-  gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);
-  
-  g_signal_connect (menu, "key-press-event",
-                   G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
-  gtk_combo_box_set_popup_widget (combo_box, menu);
-
-  /* add items */
-  if (add_children)
-    gtk_combo_box_menu_fill (combo_box);
-
-  /* the column is needed in tree_column_row_is_sensitive() */
-  priv->column = gtk_tree_view_column_new ();
-  g_object_ref_sink (priv->column);
-  gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (priv->column));
-
-  gtk_combo_box_update_title (combo_box);
-  gtk_combo_box_update_sensitivity (combo_box);
-}
-
-static void
-gtk_combo_box_menu_fill (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkWidget *menu;
-
-  if (!priv->model)
-    return;
-
-  menu = priv->popup_widget;
 
-  if (priv->add_tearoffs)
-    {
-      GtkWidget *tearoff = gtk_tearoff_menu_item_new ();
+  gtk_tree_menu_set_model (GTK_TREE_MENU (menu), priv->model);
 
-      gtk_widget_show (tearoff);
-      
-      if (priv->wrap_width)
-       gtk_menu_attach (GTK_MENU (menu), tearoff, 0, priv->wrap_width, 0, 1);
-      else
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
-    }
-  
-  gtk_combo_box_menu_fill_level (combo_box, menu, NULL);
-}
+  gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (menu), priv->wrap_width);
+  gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (menu), priv->row_column);
+  gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (menu), priv->col_column);
+  gtk_tree_menu_set_tearoff (GTK_TREE_MENU (menu), 
+                            combo_box->priv->add_tearoffs);
 
-static GtkWidget *
-gtk_cell_view_menu_item_new (GtkComboBox  *combo_box,
-                            GtkTreeModel *model,
-                            GtkTreeIter  *iter)
-{
-  GtkWidget *cell_view; 
-  GtkWidget *item;
-  GtkTreePath *path;
-  GtkRequisition req;
+  g_signal_connect (menu, "menu-activate",
+                   G_CALLBACK (gtk_combo_box_menu_activate), combo_box);
 
-  cell_view = gtk_cell_view_new ();
-  item = gtk_menu_item_new ();
-  gtk_container_add (GTK_CONTAINER (item), cell_view);
+  /* Chain our row_separator_func through */
+  gtk_tree_menu_set_row_separator_func (GTK_TREE_MENU (menu),
+                                       (GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
+                                       combo_box, NULL);
 
-  gtk_cell_view_set_model (GTK_CELL_VIEW (cell_view), model);    
-  path = gtk_tree_model_get_path (model, iter);
-  gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (cell_view), path);
-  gtk_tree_path_free (path);
+  gtk_tree_menu_set_header_func (GTK_TREE_MENU (menu),
+                                (GtkTreeMenuHeaderFunc)gtk_combo_box_header_func,
+                                combo_box, NULL);
 
-  gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (cell_view));
-  gtk_widget_size_request (cell_view, &req);
-  gtk_widget_show (cell_view);
-  
-  return item;
-}
-static void
-gtk_combo_box_menu_fill_level (GtkComboBox *combo_box,
-                              GtkWidget   *menu,
-                              GtkTreeIter *parent)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkTreeModel *model = priv->model;
-  GtkWidget *item, *submenu, *subitem, *separator;
-  GtkTreeIter iter;
-  gboolean is_separator;
-  gint i, n_children;
-  GtkWidget *last;
-  GtkTreePath *path;
-  
-  n_children = gtk_tree_model_iter_n_children (model, parent);
+  gtk_widget_set_name (menu, "gtk-combobox-popup-menu");
   
-  last = NULL;
-  for (i = 0; i < n_children; i++)
-    {
-      gtk_tree_model_iter_nth_child (model, &iter, parent, i);
+  g_signal_connect (menu, "key-press-event",
+                   G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
+  gtk_combo_box_set_popup_widget (combo_box, menu);
 
-      if (priv->row_separator_func)
-       is_separator = priv->row_separator_func (priv->model, &iter,
-                                                 priv->row_separator_data);
-      else
-       is_separator = FALSE;
-      
-      if (is_separator)
-       {
-         item = gtk_separator_menu_item_new ();
-         path = gtk_tree_model_get_path (model, &iter);
-         g_object_set_data_full (G_OBJECT (item),
-                                 I_("gtk-combo-box-item-path"),
-                                 gtk_tree_row_reference_new (model, path),
-                                 (GDestroyNotify)gtk_tree_row_reference_free);
-         gtk_tree_path_free (path);
-       }
-      else
-       {
-         item = gtk_cell_view_menu_item_new (combo_box, model, &iter);
-         if (gtk_tree_model_iter_has_child (model, &iter))
-           {
-             submenu = gtk_menu_new ();
-              gtk_menu_set_reserve_toggle_size (GTK_MENU (submenu), FALSE);
-             gtk_widget_show (submenu);
-             gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
-             
-             /* Ugly - since menus can only activate leafs, we have to
-              * duplicate the item inside the submenu.
-              */
-             subitem = gtk_cell_view_menu_item_new (combo_box, model, &iter);
-             separator = gtk_separator_menu_item_new ();
-             gtk_widget_show (subitem);
-             gtk_widget_show (separator);
-             g_signal_connect (subitem, "activate",
-                               G_CALLBACK (gtk_combo_box_menu_item_activate),
-                               combo_box);
-             gtk_menu_shell_append (GTK_MENU_SHELL (submenu), subitem);
-             gtk_menu_shell_append (GTK_MENU_SHELL (submenu), separator);
-             
-             gtk_combo_box_menu_fill_level (combo_box, submenu, &iter);
-           }
-         g_signal_connect (item, "activate",
-                           G_CALLBACK (gtk_combo_box_menu_item_activate),
-                           combo_box);
-       }
-      
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-      if (priv->wrap_width && menu == priv->popup_widget)
-        gtk_combo_box_relayout_item (combo_box, item, &iter, last);
-      gtk_widget_show (item);
-      
-      last = item;
-    }
+  gtk_combo_box_update_title (combo_box);
 }
 
 static void
@@ -3021,140 +3033,25 @@ gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
   g_signal_handlers_disconnect_matched (priv->button,
                                         G_SIGNAL_MATCH_DATA,
                                         0, 0, NULL,
-                                        gtk_combo_box_button_state_changed, combo_box);
+                                        gtk_combo_box_button_state_flags_changed, combo_box);
+  g_signal_handlers_disconnect_matched (priv->popup_widget,
+                                        G_SIGNAL_MATCH_DATA,
+                                        0, 0, NULL,
+                                        gtk_combo_box_menu_activate, combo_box);
 
   /* unparent will remove our latest ref */
   gtk_widget_unparent (priv->button);
-  
+
   priv->box = NULL;
   priv->button = NULL;
   priv->arrow = NULL;
   priv->separator = NULL;
 
-  g_object_unref (priv->column);
   priv->column = NULL;
 
   /* changing the popup window will unref the menu and the children */
 }
 
-/*
- * grid
- */
-
-static gboolean
-menu_occupied (GtkMenu   *menu,
-               guint      left_attach,
-               guint      right_attach,
-               guint      top_attach,
-               guint      bottom_attach)
-{
-  GList *i;
-
-  for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
-    {
-      guint l, r, b, t;
-
-      gtk_container_child_get (GTK_CONTAINER (menu), 
-                              i->data,
-                               "left-attach", &l,
-                               "right-attach", &r,
-                               "bottom-attach", &b,
-                               "top-attach", &t,
-                               NULL);
-
-      /* look if this item intersects with the given coordinates */
-      if (right_attach > l && left_attach < r && bottom_attach > t && top_attach < b)
-       return TRUE;
-    }
-
-  return FALSE;
-}
-
-static void
-gtk_combo_box_relayout_item (GtkComboBox *combo_box,
-                            GtkWidget   *item,
-                             GtkTreeIter *iter,
-                            GtkWidget   *last)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  gint current_col = 0, current_row = 0;
-  gint rows = 1, cols = 1;
-  GtkWidget *menu = priv->popup_widget;
-
-  if (!GTK_IS_MENU_SHELL (menu))
-    return;
-  
-  if (priv->col_column == -1 &&
-      priv->row_column == -1 &&
-      last)
-    {
-      gtk_container_child_get (GTK_CONTAINER (menu), 
-                              last,
-                              "right-attach", &current_col,
-                              "top-attach", &current_row,
-                              NULL);
-      if (current_col + cols > priv->wrap_width)
-       {
-         current_col = 0;
-         current_row++;
-       }
-    }
-  else
-    {
-      if (priv->col_column != -1)
-       gtk_tree_model_get (priv->model, iter,
-                           priv->col_column, &cols,
-                           -1);
-      if (priv->row_column != -1)
-       gtk_tree_model_get (priv->model, iter,
-                           priv->row_column, &rows,
-                           -1);
-
-      while (1)
-       {
-         if (current_col + cols > priv->wrap_width)
-           {
-             current_col = 0;
-             current_row++;
-           }
-         
-         if (!menu_occupied (GTK_MENU (menu), 
-                             current_col, current_col + cols,
-                             current_row, current_row + rows))
-           break;
-         
-         current_col++;
-       }
-    }
-
-  /* set attach props */
-  gtk_menu_attach (GTK_MENU (menu), item,
-                   current_col, current_col + cols,
-                   current_row, current_row + rows);
-}
-
-static void
-gtk_combo_box_relayout (GtkComboBox *combo_box)
-{
-  GList *list, *j;
-  GtkWidget *menu;
-
-  menu = combo_box->priv->popup_widget;
-  
-  /* do nothing unless we are in menu style and realized */
-  if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
-    return;
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  
-  for (j = g_list_last (list); j; j = j->prev)
-    gtk_container_remove (GTK_CONTAINER (menu), j->data);
-  
-  gtk_combo_box_menu_fill (combo_box);
-
-  g_list_free (list);
-}
-
 /* callbacks */
 static gboolean
 gtk_combo_box_menu_button_press (GtkWidget      *widget,
@@ -3168,7 +3065,7 @@ gtk_combo_box_menu_button_press (GtkWidget      *widget,
       event->type == GDK_BUTTON_PRESS && event->button == 1)
     {
       if (priv->focus_on_click && 
-         !GTK_WIDGET_HAS_FOCUS (priv->button))
+         !gtk_widget_has_focus (priv->button))
        gtk_widget_grab_focus (priv->button);
 
       gtk_combo_box_menu_popup (combo_box, event->button, event->time);
@@ -3180,33 +3077,21 @@ gtk_combo_box_menu_button_press (GtkWidget      *widget,
 }
 
 static void
-gtk_combo_box_menu_item_activate (GtkWidget *item,
-                                  gpointer   user_data)
+gtk_combo_box_menu_activate (GtkWidget   *menu,
+                            const gchar *path,
+                            GtkComboBox *combo_box)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkWidget *cell_view;
-  GtkTreePath *path;
   GtkTreeIter iter;
 
-  cell_view = GTK_BIN (item)->child;
-
-  g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
-
-  path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (cell_view));
-
-  if (gtk_tree_model_get_iter (combo_box->priv->model, &iter, path))
-  {
-    if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)) == NULL)
-      gtk_combo_box_set_active_iter (combo_box, &iter);
-  }
-
-  gtk_tree_path_free (path);
+  if (gtk_tree_model_get_iter_from_string (combo_box->priv->model, &iter, path))
+    gtk_combo_box_set_active_iter (combo_box, &iter);
 
   g_object_set (combo_box,
                 "editing-canceled", FALSE,
                 NULL);
 }
 
+
 static void
 gtk_combo_box_update_sensitivity (GtkComboBox *combo_box)
 {
@@ -3251,8 +3136,6 @@ gtk_combo_box_model_row_inserted (GtkTreeModel     *model,
 
   if (combo_box->priv->tree_view)
     gtk_combo_box_list_popup_resize (combo_box);
-  else
-    gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
 
   gtk_combo_box_update_sensitivity (combo_box);
 }
@@ -3274,8 +3157,6 @@ gtk_combo_box_model_row_deleted (GtkTreeModel     *model,
   
   if (priv->tree_view)
     gtk_combo_box_list_popup_resize (combo_box);
-  else
-    gtk_combo_box_menu_row_deleted (model, path, user_data);  
 
   gtk_combo_box_update_sensitivity (combo_box);
 }
@@ -3287,12 +3168,7 @@ gtk_combo_box_model_rows_reordered (GtkTreeModel    *model,
                                    gint            *new_order,
                                    gpointer         user_data)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-
   gtk_tree_row_reference_reordered (G_OBJECT (user_data), path, iter, new_order);
-
-  if (!combo_box->priv->tree_view)
-    gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
 }
                                                    
 static void
@@ -3317,8 +3193,6 @@ gtk_combo_box_model_row_changed (GtkTreeModel     *model,
       
   if (priv->tree_view)
     gtk_combo_box_list_row_changed (model, path, iter, user_data);
-  else
-    gtk_combo_box_menu_row_changed (model, path, iter, user_data);
 }
 
 static gboolean
@@ -3328,7 +3202,7 @@ list_popup_resize_idle (gpointer user_data)
   GtkComboBoxPrivate *priv = combo_box->priv;
   gint x, y, width, height;
 
-  if (priv->tree_view && GTK_WIDGET_MAPPED (priv->popup_window))
+  if (priv->tree_view && gtk_widget_get_mapped (priv->popup_window))
     {
       gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
   
@@ -3363,309 +3237,6 @@ gtk_combo_box_model_row_expanded (GtkTreeModel     *model,
 }
 
 
-static GtkWidget *
-find_menu_by_path (GtkWidget   *menu,
-                  GtkTreePath *path,
-                  gboolean     skip_first)
-{
-  GList *i, *list;
-  GtkWidget *item;
-  GtkWidget *submenu;    
-  GtkTreeRowReference *mref;
-  GtkTreePath *mpath;
-  gboolean skip;
-
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  skip = skip_first;
-  item = NULL;
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_SEPARATOR_MENU_ITEM (i->data))
-       {
-         mref = g_object_get_data (G_OBJECT (i->data), "gtk-combo-box-item-path");
-         if (!mref)
-           continue;
-         else if (!gtk_tree_row_reference_valid (mref))
-           mpath = NULL;
-         else
-           mpath = gtk_tree_row_reference_get_path (mref);
-       }
-      else if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
-       {
-         if (skip)
-           {
-             skip = FALSE;
-             continue;
-           }
-
-         mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child));
-       }
-      else 
-       continue;
-
-      /* this case is necessary, since the row reference of
-       * the cell view may already be updated after a deletion
-       */
-      if (!mpath)
-       {
-         item = i->data;
-         break;
-       }
-      if (gtk_tree_path_compare (mpath, path) == 0)
-       {
-         gtk_tree_path_free (mpath);
-         item = i->data;
-         break;
-       }
-      if (gtk_tree_path_is_ancestor (mpath, path))
-       {
-         submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-         if (submenu != NULL)
-           {
-             gtk_tree_path_free (mpath);
-             item = find_menu_by_path (submenu, path, TRUE);
-             break;
-           }
-       }
-      gtk_tree_path_free (mpath);
-    }
-  
-  g_list_free (list);  
-
-  return item;
-}
-
-#if 0
-static void
-dump_menu_tree (GtkWidget   *menu, 
-               gint         level)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  GtkTreePath *path;
-
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
-       {
-         path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child));
-         g_print ("%*s%s\n", 2 * level, " ", gtk_tree_path_to_string (path));
-         gtk_tree_path_free (path);
-
-         submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-         if (submenu != NULL)
-           dump_menu_tree (submenu, level + 1);
-       }
-    }
-  
-  g_list_free (list);  
-}
-#endif
-
-static void
-gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
-                                 GtkTreePath  *path,
-                                 GtkTreeIter  *iter,
-                                 gpointer      user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkWidget *parent;
-  GtkWidget *item, *menu, *separator;
-  GtkTreePath *ppath;
-  GtkTreeIter piter;
-  gint depth, pos;
-  gboolean is_separator;
-
-  if (!priv->popup_widget)
-    return;
-
-  depth = gtk_tree_path_get_depth (path);
-  pos = gtk_tree_path_get_indices (path)[depth - 1];
-  if (depth > 1)
-    {
-      ppath = gtk_tree_path_copy (path);
-      gtk_tree_path_up (ppath);
-      parent = find_menu_by_path (priv->popup_widget, ppath, FALSE);
-      gtk_tree_path_free (ppath);
-
-      menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent));
-      if (!menu)
-       {
-         menu = gtk_menu_new ();
-          gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);
-         gtk_widget_show (menu);
-         gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), menu);
-         
-         /* Ugly - since menus can only activate leaves, we have to
-          * duplicate the item inside the submenu.
-          */
-         gtk_tree_model_iter_parent (model, &piter, iter);
-         item = gtk_cell_view_menu_item_new (combo_box, model, &piter);
-         separator = gtk_separator_menu_item_new ();
-         g_signal_connect (item, "activate",
-                           G_CALLBACK (gtk_combo_box_menu_item_activate),
-                           combo_box);
-         gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-         gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
-         if (cell_view_is_sensitive (GTK_CELL_VIEW (GTK_BIN (item)->child)))
-           {
-             gtk_widget_show (item);
-             gtk_widget_show (separator);
-           }
-       }
-      pos += 2;
-    }
-  else
-    {
-      menu = priv->popup_widget;
-      if (priv->add_tearoffs)
-       pos += 1;
-    }
-  
-  if (priv->row_separator_func)
-    is_separator = priv->row_separator_func (model, iter,
-                                             priv->row_separator_data);
-  else
-    is_separator = FALSE;
-
-  if (is_separator)
-    {
-      item = gtk_separator_menu_item_new ();
-      g_object_set_data_full (G_OBJECT (item),
-                             I_("gtk-combo-box-item-path"),
-                             gtk_tree_row_reference_new (model, path),
-                             (GDestroyNotify)gtk_tree_row_reference_free);
-    }
-  else
-    {
-      item = gtk_cell_view_menu_item_new (combo_box, model, iter);
-      
-      g_signal_connect (item, "activate",
-                       G_CALLBACK (gtk_combo_box_menu_item_activate),
-                       combo_box);
-    }
-
-  gtk_widget_show (item);
-  gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, pos);
-}
-
-static void
-gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
-                                GtkTreePath  *path,
-                                gpointer      user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkWidget *menu;
-  GtkWidget *item;
-
-  if (!priv->popup_widget)
-    return;
-
-  item = find_menu_by_path (priv->popup_widget, path, FALSE);
-  menu = gtk_widget_get_parent (item);
-  gtk_container_remove (GTK_CONTAINER (menu), item);
-
-  if (gtk_tree_path_get_depth (path) > 1)
-    {
-      GtkTreePath *parent_path;
-      GtkTreeIter iter;
-      GtkWidget *parent;
-
-      parent_path = gtk_tree_path_copy (path);
-      gtk_tree_path_up (parent_path);
-      gtk_tree_model_get_iter (model, &iter, parent_path);
-
-      if (!gtk_tree_model_iter_has_child (model, &iter))
-       {
-         parent = find_menu_by_path (priv->popup_widget, 
-                                     parent_path, FALSE);
-         gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), NULL);
-       }
-    }
-}
-
-static void
-gtk_combo_box_menu_rows_reordered  (GtkTreeModel     *model,
-                                   GtkTreePath      *path,
-                                   GtkTreeIter      *iter,
-                                   gint             *new_order,
-                                   gpointer          user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-
-  gtk_combo_box_relayout (combo_box);
-}
-                                   
-static void
-gtk_combo_box_menu_row_changed (GtkTreeModel *model,
-                                GtkTreePath  *path,
-                                GtkTreeIter  *iter,
-                                gpointer      user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkWidget *item;
-  gint width;
-  gboolean is_separator;
-
-  if (!priv->popup_widget)
-    return;
-
-  item = find_menu_by_path (priv->popup_widget, path, FALSE);
-
-  if (priv->row_separator_func)
-    is_separator = priv->row_separator_func (model, iter,
-                                             priv->row_separator_data);
-  else
-    is_separator = FALSE;
-
-  if (is_separator != GTK_IS_SEPARATOR_MENU_ITEM (item))
-    {
-      gtk_combo_box_menu_row_deleted (model, path, combo_box);
-      gtk_combo_box_menu_row_inserted (model, path, iter, combo_box);
-    }
-
-  if (priv->wrap_width && item->parent == priv->popup_widget)
-    {
-      GtkWidget *pitem = NULL;
-      GtkTreePath *prev;
-
-      prev = gtk_tree_path_copy (path);
-
-      if (gtk_tree_path_prev (prev))
-        pitem = find_menu_by_path (priv->popup_widget, prev, FALSE);
-
-      gtk_tree_path_free (prev);
-
-      /* unattach item so gtk_combo_box_relayout_item() won't spuriously
-         move it */
-      gtk_container_child_set (GTK_CONTAINER (priv->popup_widget),
-                               item, 
-                              "left-attach", -1, 
-                              "right-attach", -1,
-                               "top-attach", -1, 
-                              "bottom-attach", -1, 
-                              NULL);
-
-      gtk_combo_box_relayout_item (combo_box, item, iter, pitem);
-    }
-
-  width = gtk_combo_box_calc_requested_width (combo_box, path);
-
-  if (width > priv->width)
-    {
-      if (priv->cell_view)
-       {
-         gtk_widget_set_size_request (priv->cell_view, width, -1);
-         gtk_widget_queue_resize (priv->cell_view);
-       }
-      priv->width = width;
-    }
-}
-
 /*
  * list style
  */
@@ -3675,10 +3246,13 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
 {
   GtkComboBoxPrivate *priv = combo_box->priv;
   GtkTreeSelection *sel;
+  GtkWidget *child;
+  GtkWidget *widget = GTK_WIDGET (combo_box);
 
   priv->button = gtk_toggle_button_new ();
+  child = gtk_bin_get_child (GTK_BIN (combo_box));
   gtk_widget_set_parent (priv->button,
-                         GTK_BIN (combo_box)->child->parent);
+                         gtk_widget_get_parent (child));
   g_signal_connect (priv->button, "button-press-event",
                     G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
   g_signal_connect (priv->button, "toggled",
@@ -3691,8 +3265,19 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
 
   if (priv->cell_view)
     {
-      gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view), 
-                                         &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
+      GtkStyleContext *context;
+      GtkStateFlags state;
+      GdkRGBA *color;
+
+      context = gtk_widget_get_style_context (widget);
+      state = gtk_widget_get_state_flags (widget);
+
+      gtk_style_context_get (context, state,
+                             "background-color", &color,
+                             NULL);
+
+      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), color);
+      gdk_rgba_free (color);
 
       priv->box = gtk_event_box_new ();
       gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->box), 
@@ -3710,9 +3295,9 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
          gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->cell_view_frame), 
                                            FALSE);
        }
-      
+
       gtk_widget_set_parent (priv->cell_view_frame,
-                            GTK_BIN (combo_box)->child->parent);
+                            gtk_widget_get_parent (child));
       gtk_container_add (GTK_CONTAINER (priv->cell_view_frame), priv->box);
       gtk_widget_show_all (priv->cell_view_frame);
 
@@ -3731,21 +3316,17 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
                                      FALSE);
   gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->tree_view),
                                     TRUE);
-  if (priv->row_separator_func)
-    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (priv->tree_view), 
-                                         priv->row_separator_func, 
-                                         priv->row_separator_data, 
-                                         NULL);
+
+  gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (priv->tree_view), 
+                                       (GtkTreeViewRowSeparatorFunc)gtk_combo_box_row_separator_func,
+                                       combo_box, NULL);
+
   if (priv->model)
     gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), priv->model);
     
-  priv->column = gtk_tree_view_column_new ();
+  priv->column = gtk_tree_view_column_new_with_area (priv->area);
   gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), priv->column);
 
-  /* sync up */
-  gtk_combo_box_sync_cells (combo_box, 
-                           GTK_CELL_LAYOUT (priv->column));
-
   if (gtk_tree_row_reference_valid (priv->active_row))
     {
       GtkTreePath *path;
@@ -3890,10 +3471,10 @@ gtk_combo_box_list_button_pressed (GtkWidget      *widget,
     return FALSE;
 
   if (priv->focus_on_click && 
-      !GTK_WIDGET_HAS_FOCUS (priv->button))
+      !gtk_widget_has_focus (priv->button))
     gtk_widget_grab_focus (priv->button);
 
-  gtk_combo_box_popup (combo_box);
+  gtk_combo_box_popup_for_device (combo_box, event->device);
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), TRUE);
 
@@ -3987,12 +3568,12 @@ gtk_combo_box_menu_key_press (GtkWidget   *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
 
-  if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event))
+  if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
     {
       /* The menu hasn't managed the
        * event, forward it to the combobox
        */
-      gtk_bindings_activate_event (GTK_OBJECT (combo_box), event);
+      gtk_bindings_activate_event (G_OBJECT (combo_box), event);
     }
 
   return TRUE;
@@ -4006,8 +3587,8 @@ gtk_combo_box_list_key_press (GtkWidget   *widget,
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
   GtkTreeIter iter;
 
-  if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || event->keyval == GDK_KP_Enter ||
-      event->keyval == GDK_space || event->keyval == GDK_KP_Space) 
+  if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_ISO_Enter || event->keyval == GDK_KEY_KP_Enter ||
+      event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space) 
   {
     GtkTreeModel *model = NULL;
     
@@ -4026,12 +3607,12 @@ gtk_combo_box_list_key_press (GtkWidget   *widget,
     return TRUE;
   }
 
-  if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event))
+  if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
     {
       /* The list hasn't managed the
        * event, forward it to the combobox
        */
-      gtk_bindings_activate_event (GTK_OBJECT (combo_box), event);
+      gtk_bindings_activate_event (G_OBJECT (combo_box), event);
     }
 
   return TRUE;
@@ -4042,41 +3623,44 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box,
                                gint         x, 
                                gint         y)
 {
-  GtkWidget *tree_view = combo_box->priv->tree_view;
   GtkAdjustment *adj;
+  GtkAllocation allocation;
+  GtkWidget *tree_view = combo_box->priv->tree_view;
   gdouble value;
 
+  gtk_widget_get_allocation (tree_view, &allocation);
+
   adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
   if (adj && adj->upper - adj->lower > adj->page_size)
     {
-      if (x <= tree_view->allocation.x && 
+      if (x <= allocation.x &&
          adj->lower < adj->value)
        {
-         value = adj->value - (tree_view->allocation.x - x + 1);
-         gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size));
+         value = adj->value - (allocation.x - x + 1);
+         gtk_adjustment_set_value (adj, value);
        }
-      else if (x >= tree_view->allocation.x + tree_view->allocation.width &&
+      else if (x >= allocation.x + allocation.width &&
               adj->upper - adj->page_size > adj->value)
        {
-         value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1);
-         gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size));
+         value = adj->value + (x - allocation.x - allocation.width + 1);
+         gtk_adjustment_set_value (adj, MAX (value, 0.0));
        }
     }
 
   adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
   if (adj && adj->upper - adj->lower > adj->page_size)
     {
-      if (y <= tree_view->allocation.y && 
+      if (y <= allocation.y &&
          adj->lower < adj->value)
        {
-         value = adj->value - (tree_view->allocation.y - y + 1);
-         gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size));
+         value = adj->value - (allocation.y - y + 1);
+         gtk_adjustment_set_value (adj, value);
        }
-      else if (y >= tree_view->allocation.height &&
+      else if (y >= allocation.height &&
               adj->upper - adj->page_size > adj->value)
        {
-         value = adj->value + (y - tree_view->allocation.height + 1);
-         gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size));
+         value = adj->value + (y - allocation.height + 1);
+         gtk_adjustment_set_value (adj, MAX (value, 0.0));
        }
     }
 }
@@ -4089,7 +3673,9 @@ gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box)
 
   if (priv->auto_scroll)
     {
-      gdk_window_get_pointer (priv->tree_view->window, &x, &y, NULL);
+      gdk_window_get_device_position (gtk_widget_get_window (priv->tree_view),
+                                      priv->grab_pointer,
+                                      &x, &y, NULL);
       gtk_combo_box_list_auto_scroll (combo_box, x, y);
     }
 
@@ -4115,17 +3701,19 @@ gtk_combo_box_list_select_func (GtkTreeSelection *selection,
                                gboolean          path_currently_selected,
                                gpointer          data)
 {
-  GList *list;
+  GList *list, *columns;
   gboolean sensitive = FALSE;
 
-  for (list = selection->tree_view->priv->columns; list && !sensitive; list = list->next)
+  columns = gtk_tree_view_get_columns (gtk_tree_selection_get_tree_view (selection));
+
+  for (list = columns; list && !sensitive; list = list->next)
     {
       GList *cells, *cell;
       gboolean cell_sensitive, cell_visible;
       GtkTreeIter iter;
       GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (list->data);
 
-      if (!column->visible)
+      if (!gtk_tree_view_column_get_visible (column))
        continue;
 
       gtk_tree_model_get_iter (model, &iter, path);
@@ -4150,6 +3738,8 @@ gtk_combo_box_list_select_func (GtkTreeSelection *selection,
       sensitive = cell_sensitive;
     }
 
+  g_list_free (columns);
+
   return sensitive;
 }
 
@@ -4159,505 +3749,122 @@ gtk_combo_box_list_row_changed (GtkTreeModel *model,
                                 GtkTreeIter  *iter,
                                 gpointer      data)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  gint width;
-
-  width = gtk_combo_box_calc_requested_width (combo_box, path);
-
-  if (width > priv->width)
-    {
-      if (priv->cell_view) 
-       {
-         gtk_widget_set_size_request (priv->cell_view, width, -1);
-         gtk_widget_queue_resize (priv->cell_view);
-       }
-      priv->width = width;
-    }
+  /* XXX Do nothing ? */
 }
 
 /*
  * GtkCellLayout implementation
  */
-
-static void
-pack_start_recurse (GtkWidget       *menu,
-                   GtkCellRenderer *cell,
-                   gboolean         expand)
+GtkCellArea *
+gtk_combo_box_cell_layout_get_area (GtkCellLayout    *cell_layout)
 {
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child), 
-                                   cell, expand);
+  return GTK_COMBO_BOX (cell_layout)->priv->area;
+}
 
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       pack_start_recurse (submenu, cell, expand);
-    }
+/*
+ * public API
+ */
 
-  g_list_free (list);
+/**
+ * gtk_combo_box_new:
+ *
+ * Creates a new empty #GtkComboBox.
+ *
+ * Return value: A new #GtkComboBox.
+ *
+ * Since: 2.4
+ */
+GtkWidget *
+gtk_combo_box_new (void)
+{
+  return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
 }
 
-static void
-gtk_combo_box_cell_layout_pack_start (GtkCellLayout   *layout,
-                                      GtkCellRenderer *cell,
-                                      gboolean         expand)
+/**
+ * gtk_combo_box_new_with_area:
+ * @area: the #GtkCellArea to use to layout cell renderers
+ *
+ * Creates a new empty #GtkComboBox using @area to layout cells.
+ *
+ * Return value: A new #GtkComboBox.
+ */
+GtkWidget *
+gtk_combo_box_new_with_area (GtkCellArea  *area)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  ComboCellInfo *info;
-  GtkComboBoxPrivate *priv;
-
-  priv = combo_box->priv;
-
-  g_object_ref_sink (cell);
-
-  info = g_slice_new0 (ComboCellInfo);
-  info->cell = cell;
-  info->expand = expand;
-  info->pack = GTK_PACK_START;
-
-  priv->cells = g_slist_append (priv->cells, info);
-
-  if (priv->cell_view)
-    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view),
-                                cell, expand);
-
-  if (priv->column)
-    gtk_tree_view_column_pack_start (priv->column, cell, expand);
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    pack_start_recurse (priv->popup_widget, cell, expand);
+  return g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", area, NULL);
 }
 
-static void
-pack_end_recurse (GtkWidget       *menu,
-                 GtkCellRenderer *cell,
-                 gboolean         expand)
+/**
+ * gtk_combo_box_new_with_area_and_entry:
+ * @area: the #GtkCellArea to use to layout cell renderers
+ *
+ * Creates a new empty #GtkComboBox with an entry.
+ *
+ * The new combo box will use @area to layout cells.
+ *
+ * Return value: A new #GtkComboBox.
+ */
+GtkWidget *
+gtk_combo_box_new_with_area_and_entry (GtkCellArea *area)
 {
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child), 
-                                 cell, expand);
+  return g_object_new (GTK_TYPE_COMBO_BOX, 
+                      "has-entry", TRUE, 
+                      "cell-area", area, 
+                      NULL);
+}
 
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       pack_end_recurse (submenu, cell, expand);
-    }
 
-  g_list_free (list);
+/**
+ * gtk_combo_box_new_with_entry:
+ *
+ * Creates a new empty #GtkComboBox with an entry.
+ *
+ * Return value: A new #GtkComboBox.
+ */
+GtkWidget *
+gtk_combo_box_new_with_entry (void)
+{
+  return g_object_new (GTK_TYPE_COMBO_BOX, "has-entry", TRUE, NULL);
 }
 
-static void
-gtk_combo_box_cell_layout_pack_end (GtkCellLayout   *layout,
-                                    GtkCellRenderer *cell,
-                                    gboolean         expand)
+/**
+ * gtk_combo_box_new_with_model:
+ * @model: A #GtkTreeModel.
+ *
+ * Creates a new #GtkComboBox with the model initialized to @model.
+ *
+ * Return value: A new #GtkComboBox.
+ *
+ * Since: 2.4
+ */
+GtkWidget *
+gtk_combo_box_new_with_model (GtkTreeModel *model)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  ComboCellInfo *info;
-  GtkComboBoxPrivate *priv;
-
-  priv = combo_box->priv;
-
-  g_object_ref_sink (cell);
-
-  info = g_slice_new0 (ComboCellInfo);
-  info->cell = cell;
-  info->expand = expand;
-  info->pack = GTK_PACK_END;
-
-  priv->cells = g_slist_append (priv->cells, info);
+  GtkComboBox *combo_box;
 
-  if (priv->cell_view)
-    gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (priv->cell_view),
-                              cell, expand);
+  g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
 
-  if (priv->column)
-    gtk_tree_view_column_pack_end (priv->column, cell, expand);
+  combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL);
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    pack_end_recurse (priv->popup_widget, cell, expand);
+  return GTK_WIDGET (combo_box);
 }
 
-static GList *
-gtk_combo_box_cell_layout_get_cells (GtkCellLayout *layout)
+/**
+ * gtk_combo_box_new_with_model_and_entry:
+ * @model: A #GtkTreeModel
+ *
+ * Creates a new empty #GtkComboBox with an entry
+ * and with the model initialized to @model.
+ *
+ * Return value: A new #GtkComboBox
+ */
+GtkWidget *
+gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GSList *list;
-  GList *retval = NULL;
-
-  for (list = combo_box->priv->cells; list; list = list->next)
-    {
-      ComboCellInfo *info = (ComboCellInfo *)list->data;
-
-      retval = g_list_prepend (retval, info->cell);
-    }
-
-  return g_list_reverse (retval);
-}
-
-static void
-clear_recurse (GtkWidget *menu)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_clear (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child)); 
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       clear_recurse (submenu);
-    }
-
-  g_list_free (list);
-}
-
-static void
-gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GSList *i;
-  
-  if (priv->cell_view)
-    gtk_cell_layout_clear (GTK_CELL_LAYOUT (priv->cell_view));
-
-  if (priv->column)
-    gtk_tree_view_column_clear (priv->column);
-
-  for (i = priv->cells; i; i = i->next)
-    {
-      ComboCellInfo *info = (ComboCellInfo *)i->data;
-
-      gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
-      g_object_unref (info->cell);
-      g_slice_free (ComboCellInfo, info);
-      i->data = NULL;
-    }
-  g_slist_free (priv->cells);
-  priv->cells = NULL;
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    clear_recurse (priv->popup_widget);
-}
-
-static void
-add_attribute_recurse (GtkWidget       *menu,
-                      GtkCellRenderer *cell,
-                      const gchar     *attribute,
-                      gint             column)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
-                                      cell, attribute, column); 
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       add_attribute_recurse (submenu, cell, attribute, column);
-    }
-
-  g_list_free (list);
-}
-                      
-static void
-gtk_combo_box_cell_layout_add_attribute (GtkCellLayout   *layout,
-                                         GtkCellRenderer *cell,
-                                         const gchar     *attribute,
-                                         gint             column)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  ComboCellInfo *info;
-
-  info = gtk_combo_box_get_cell_info (combo_box, cell);
-  g_return_if_fail (info != NULL);
-
-  info->attributes = g_slist_prepend (info->attributes,
-                                      GINT_TO_POINTER (column));
-  info->attributes = g_slist_prepend (info->attributes,
-                                      g_strdup (attribute));
-
-  if (combo_box->priv->cell_view)
-    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
-                                   cell, attribute, column);
-
-  if (combo_box->priv->column)
-    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column),
-                                   cell, attribute, column);
-
-  if (GTK_IS_MENU (combo_box->priv->popup_widget))
-    add_attribute_recurse (combo_box->priv->popup_widget, cell, attribute, column);
-  gtk_widget_queue_resize (GTK_WIDGET (combo_box));
-}
-
-static void
-combo_cell_data_func (GtkCellLayout   *cell_layout,
-                     GtkCellRenderer *cell,
-                     GtkTreeModel    *tree_model,
-                     GtkTreeIter     *iter,
-                     gpointer         data)
-{
-  ComboCellInfo *info = (ComboCellInfo *)data;
-  GtkWidget *parent = NULL;
-  
-  if (!info->func)
-    return;
-
-  info->func (cell_layout, cell, tree_model, iter, info->func_data);
-
-  if (GTK_IS_WIDGET (cell_layout))
-    parent = gtk_widget_get_parent (GTK_WIDGET (cell_layout));
-  
-  if (GTK_IS_MENU_ITEM (parent) && 
-      gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)))
-    g_object_set (cell, "sensitive", TRUE, NULL);
-}
-
-
-static void 
-set_cell_data_func_recurse (GtkWidget       *menu,
-                           GtkCellRenderer *cell,
-                           ComboCellInfo   *info)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  GtkWidget *cell_view;
-  
- list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      cell_view = GTK_BIN (i->data)->child;
-      if (GTK_IS_CELL_LAYOUT (cell_view))
-       {
-         /* Override sensitivity for inner nodes; we don't
-          * want menuitems with submenus to appear insensitive 
-          */ 
-         gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view), 
-                                             cell, 
-                                             combo_cell_data_func, 
-                                             info, NULL); 
-         submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-         if (submenu != NULL)
-           set_cell_data_func_recurse (submenu, cell, info);
-       }
-    }
-
-  g_list_free (list);
-}
-
-static void
-gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout         *layout,
-                                              GtkCellRenderer       *cell,
-                                              GtkCellLayoutDataFunc  func,
-                                              gpointer               func_data,
-                                              GDestroyNotify         destroy)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  ComboCellInfo *info;
-
-  info = gtk_combo_box_get_cell_info (combo_box, cell);
-  g_return_if_fail (info != NULL);
-  
-  if (info->destroy)
-    {
-      GDestroyNotify d = info->destroy;
-
-      info->destroy = NULL;
-      d (info->func_data);
-    }
-
-  info->func = func;
-  info->func_data = func_data;
-  info->destroy = destroy;
-
-  if (priv->cell_view)
-    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->cell_view), cell, func, func_data, NULL);
-
-  if (priv->column)
-    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->column), cell, func, func_data, NULL);
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    set_cell_data_func_recurse (priv->popup_widget, cell, info);
-
-  gtk_widget_queue_resize (GTK_WIDGET (combo_box));
-}
-
-static void 
-clear_attributes_recurse (GtkWidget       *menu,
-                         GtkCellRenderer *cell)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
-                                           cell); 
-      
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       clear_attributes_recurse (submenu, cell);
-    }
-
-  g_list_free (list);
-}
-
-static void
-gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout   *layout,
-                                            GtkCellRenderer *cell)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GtkComboBoxPrivate *priv;
-  ComboCellInfo *info;
-  GSList *list;
-
-  priv = combo_box->priv;
-
-  info = gtk_combo_box_get_cell_info (combo_box, cell);
-  g_return_if_fail (info != NULL);
-
-  list = info->attributes;
-  while (list && list->next)
-    {
-      g_free (list->data);
-      list = list->next->next;
-    }
-  g_slist_free (info->attributes);
-  info->attributes = NULL;
-
-  if (priv->cell_view)
-    gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (priv->cell_view), cell);
-
-  if (priv->column)
-    gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (priv->column), cell);
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    clear_attributes_recurse (priv->popup_widget, cell);
-
-  gtk_widget_queue_resize (GTK_WIDGET (combo_box));
-}
-
-static void 
-reorder_recurse (GtkWidget             *menu,
-                GtkCellRenderer       *cell,
-                gint                   position)
-{
-  GList *i, *list;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
-       gtk_cell_layout_reorder (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
-                                cell, position); 
-      
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-       reorder_recurse (submenu, cell, position);
-    }
-
-  g_list_free (list);
-}
-
-static void
-gtk_combo_box_cell_layout_reorder (GtkCellLayout   *layout,
-                                   GtkCellRenderer *cell,
-                                   gint             position)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GtkComboBoxPrivate *priv;
-  ComboCellInfo *info;
-  GSList *link;
-
-  priv = combo_box->priv;
-
-  info = gtk_combo_box_get_cell_info (combo_box, cell);
-
-  g_return_if_fail (info != NULL);
-  g_return_if_fail (position >= 0);
-
-  link = g_slist_find (priv->cells, info);
-
-  g_return_if_fail (link != NULL);
-
-  priv->cells = g_slist_delete_link (priv->cells, link);
-  priv->cells = g_slist_insert (priv->cells, info, position);
-
-  if (priv->cell_view)
-    gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->cell_view),
-                             cell, position);
-
-  if (priv->column)
-    gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->column),
-                             cell, position);
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    reorder_recurse (priv->popup_widget, cell, position);
-
-  gtk_widget_queue_draw (GTK_WIDGET (combo_box));
-}
-
-/*
- * public API
- */
-
-/**
- * gtk_combo_box_new:
- *
- * Creates a new empty #GtkComboBox.
- *
- * Return value: A new #GtkComboBox.
- *
- * Since: 2.4
- */
-GtkWidget *
-gtk_combo_box_new (void)
-{
-  return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
-}
-
-/**
- * gtk_combo_box_new_with_model:
- * @model: A #GtkTreeModel.
- *
- * Creates a new #GtkComboBox with the model initialized to @model.
- *
- * Return value: A new #GtkComboBox.
- *
- * Since: 2.4
- */
-GtkWidget *
-gtk_combo_box_new_with_model (GtkTreeModel *model)
-{
-  GtkComboBox *combo_box;
-
-  g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
-
-  combo_box = g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL);
-
-  return GTK_WIDGET (combo_box);
+  return g_object_new (GTK_TYPE_COMBO_BOX,
+                       "has-entry", TRUE,
+                       "model", model,
+                       NULL);
 }
 
 /**
@@ -4707,7 +3914,9 @@ gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
       priv->wrap_width = width;
 
       gtk_combo_box_check_appearance (combo_box);
-      gtk_combo_box_relayout (combo_box);
+
+      if (GTK_IS_TREE_MENU (priv->popup_widget))
+       gtk_tree_menu_set_wrap_width (GTK_TREE_MENU (priv->popup_widget), priv->wrap_width);
       
       g_object_notify (G_OBJECT (combo_box), "wrap-width");
     }
@@ -4759,9 +3968,10 @@ gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
   if (row_span != priv->row_column)
     {
       priv->row_column = row_span;
-      
-      gtk_combo_box_relayout (combo_box);
+
+      if (GTK_IS_TREE_MENU (priv->popup_widget))
+       gtk_tree_menu_set_row_span_column (GTK_TREE_MENU (priv->popup_widget), priv->row_column);
+
       g_object_notify (G_OBJECT (combo_box), "row-span-column");
     }
 }
@@ -4812,9 +4022,10 @@ gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
   if (column_span != priv->col_column)
     {
       priv->col_column = column_span;
-      
-      gtk_combo_box_relayout (combo_box);
 
+      if (GTK_IS_TREE_MENU (priv->popup_widget))
+       gtk_tree_menu_set_column_span_column (GTK_TREE_MENU (priv->popup_widget), priv->col_column);
+      
       g_object_notify (G_OBJECT (combo_box), "column-span-column");
     }
 }
@@ -4965,13 +4176,15 @@ gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
 
   g_signal_emit (combo_box, combo_box_signals[CHANGED], 0);
   g_object_notify (G_OBJECT (combo_box), "active");
+  if (combo_box->priv->id_column >= 0)
+    g_object_notify (G_OBJECT (combo_box), "active-id");
 }
 
 
 /**
  * gtk_combo_box_get_active_iter:
  * @combo_box: A #GtkComboBox
- * @iter: The uninitialized #GtkTreeIter
+ * @iter: (out): The uninitialized #GtkTreeIter
  * 
  * Sets @iter to point to the current active item, if it exists.
  * 
@@ -5005,8 +4218,6 @@ gtk_combo_box_get_active_iter (GtkComboBox     *combo_box,
  * 
  * Sets the current active item to be the one referenced by @iter, or
  * unsets the active item if @iter is %NULL.
- *
- * @iter must correspond to a path of depth one, or be %NULL.
  * 
  * Since: 2.4
  */
@@ -5081,12 +4292,12 @@ gtk_combo_box_set_model (GtkComboBox  *combo_box,
                                combo_box->priv->model);
       gtk_combo_box_list_popup_resize (combo_box);
     }
-  else
+
+  if (GTK_IS_TREE_MENU (combo_box->priv->popup_widget))
     {
       /* menu mode */
-      if (combo_box->priv->popup_widget)
-       gtk_combo_box_menu_fill (combo_box);
-
+      gtk_tree_menu_set_model (GTK_TREE_MENU (combo_box->priv->popup_widget), 
+                              combo_box->priv->model);
     }
 
   if (combo_box->priv->cell_view)
@@ -5107,12 +4318,13 @@ out:
 }
 
 /**
- * gtk_combo_box_get_model
+ * gtk_combo_box_get_model:
  * @combo_box: A #GtkComboBox
  *
  * Returns the #GtkTreeModel which is acting as data source for @combo_box.
  *
- * Return value: (transfer none): A #GtkTreeModel which was passed during construction.
+ * Return value: (transfer none): A #GtkTreeModel which was passed
+ *     during construction.
  *
  * Since: 2.4
  */
@@ -5124,266 +4336,60 @@ gtk_combo_box_get_model (GtkComboBox *combo_box)
   return combo_box->priv->model;
 }
 
-
-/* convenience API for simple text combos */
-
-/**
- * gtk_combo_box_new_text:
- *
- * Convenience function which constructs a new text combo box, which is a
- * #GtkComboBox just displaying strings. If you use this function to create
- * a text combo box, you should only manipulate its data source with the
- * following convenience functions: gtk_combo_box_append_text(),
- * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
- * gtk_combo_box_remove_text().
- *
- * Return value: (transfer none): A new text combo box.
- *
- * Since: 2.4
- */
-GtkWidget *
-gtk_combo_box_new_text (void)
+static void
+gtk_combo_box_real_move_active (GtkComboBox   *combo_box,
+                                GtkScrollType  scroll)
 {
-  GtkWidget *combo_box;
-  GtkCellRenderer *cell;
-  GtkListStore *store;
-
-  store = gtk_list_store_new (1, G_TYPE_STRING);
-  combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
-  g_object_unref (store);
+  GtkTreeIter iter;
+  GtkTreeIter new_iter;
+  gboolean    active_iter;
+  gboolean    found;
 
-  cell = gtk_cell_renderer_text_new ();
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
-  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
-                                  "text", 0,
-                                  NULL);
+  if (!combo_box->priv->model)
+    {
+      gtk_widget_error_bell (GTK_WIDGET (combo_box));
+      return;
+    }
 
-  return combo_box;
-}
+  active_iter = gtk_combo_box_get_active_iter (combo_box, &iter);
 
-/**
- * gtk_combo_box_append_text:
- * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
- * @text: A string
- *
- * Appends @string to the list of strings stored in @combo_box. Note that
- * you can only use this function with combo boxes constructed with
- * gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_append_text (GtkComboBox *combo_box,
-                           const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
+  switch (scroll)
+    {
+    case GTK_SCROLL_STEP_BACKWARD:
+    case GTK_SCROLL_STEP_UP:
+    case GTK_SCROLL_STEP_LEFT:
+      if (active_iter)
+        {
+         found = tree_prev (combo_box, combo_box->priv->model,
+                            &iter, &new_iter, FALSE);
+         break;
+        }
+      /* else fall through */
 
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
+    case GTK_SCROLL_PAGE_FORWARD:
+    case GTK_SCROLL_PAGE_DOWN:
+    case GTK_SCROLL_PAGE_RIGHT:
+    case GTK_SCROLL_END:
+      found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE);
+      break;
 
-  store = GTK_LIST_STORE (combo_box->priv->model);
+    case GTK_SCROLL_STEP_FORWARD:
+    case GTK_SCROLL_STEP_DOWN:
+    case GTK_SCROLL_STEP_RIGHT:
+      if (active_iter)
+        {
+         found = tree_next (combo_box, combo_box->priv->model,
+                            &iter, &new_iter, FALSE);
+          break;
+        }
+      /* else fall through */
 
-  gtk_list_store_append (store, &iter);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_insert_text:
- * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
- * @position: An index to insert @text
- * @text: A string
- *
- * Inserts @string at @position in the list of strings stored in @combo_box.
- * Note that you can only use this function with combo boxes constructed
- * with gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_insert_text (GtkComboBox *combo_box,
-                           gint         position,
-                           const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (position >= 0);
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  gtk_list_store_insert (store, &iter, position);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_prepend_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- * @text: A string
- *
- * Prepends @string to the list of strings stored in @combo_box. Note that
- * you can only use this function with combo boxes constructed with
- * gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_prepend_text (GtkComboBox *combo_box,
-                            const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  gtk_list_store_prepend (store, &iter);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_remove_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- * @position: Index of the item to remove
- *
- * Removes the string at @position from @combo_box. Note that you can only use
- * this function with combo boxes constructed with gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_remove_text (GtkComboBox *combo_box,
-                           gint         position)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (position >= 0);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
-                                     NULL, position))
-    gtk_list_store_remove (store, &iter);
-}
-
-/**
- * gtk_combo_box_get_active_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- *
- * Returns the currently active string in @combo_box or %NULL if none
- * is selected.  Note that you can only use this function with combo
- * boxes constructed with gtk_combo_box_new_text() and with
- * #GtkComboBoxEntry<!-- -->s.
- *
- * Returns: a newly allocated string containing the currently active text.
- *     Must be freed with g_free().
- *
- * Since: 2.6
- */
-gchar *
-gtk_combo_box_get_active_text (GtkComboBox *combo_box)
-{
-  GtkComboBoxClass *class;
-
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
-
-  class = GTK_COMBO_BOX_GET_CLASS (combo_box);
-
-  if (class->get_active_text)
-    return class->get_active_text (combo_box);
-
-  return NULL;
-}
-
-static gchar *
-gtk_combo_box_real_get_active_text (GtkComboBox *combo_box)
-{
-  GtkTreeIter iter;
-  gchar *text = NULL;
-
-  g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL);
-  g_return_val_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                        == G_TYPE_STRING, NULL);
-
-  if (gtk_combo_box_get_active_iter (combo_box, &iter))
-    gtk_tree_model_get (combo_box->priv->model, &iter, 
-                       0, &text, -1);
-
-  return text;
-}
-
-static void
-gtk_combo_box_real_move_active (GtkComboBox   *combo_box,
-                                GtkScrollType  scroll)
-{
-  GtkTreeIter iter;
-  GtkTreeIter new_iter;
-  gboolean    active_iter;
-  gboolean    found;
-
-  if (!combo_box->priv->model)
-    {
-      gtk_widget_error_bell (GTK_WIDGET (combo_box));
-      return;
-    }
-
-  active_iter = gtk_combo_box_get_active_iter (combo_box, &iter);
-
-  switch (scroll)
-    {
-    case GTK_SCROLL_STEP_BACKWARD:
-    case GTK_SCROLL_STEP_UP:
-    case GTK_SCROLL_STEP_LEFT:
-      if (active_iter)
-        {
-         found = tree_prev (combo_box, combo_box->priv->model,
-                            &iter, &new_iter, FALSE);
-         break;
-        }
-      /* else fall through */
-
-    case GTK_SCROLL_PAGE_FORWARD:
-    case GTK_SCROLL_PAGE_DOWN:
-    case GTK_SCROLL_PAGE_RIGHT:
-    case GTK_SCROLL_END:
-      found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE);
-      break;
-
-    case GTK_SCROLL_STEP_FORWARD:
-    case GTK_SCROLL_STEP_DOWN:
-    case GTK_SCROLL_STEP_RIGHT:
-      if (active_iter)
-        {
-         found = tree_next (combo_box, combo_box->priv->model,
-                            &iter, &new_iter, FALSE);
-          break;
-        }
-      /* else fall through */
-
-    case GTK_SCROLL_PAGE_BACKWARD:
-    case GTK_SCROLL_PAGE_UP:
-    case GTK_SCROLL_PAGE_LEFT:
-    case GTK_SCROLL_START:
-      found = tree_first (combo_box, combo_box->priv->model, &new_iter, FALSE);
-      break;
+    case GTK_SCROLL_PAGE_BACKWARD:
+    case GTK_SCROLL_PAGE_UP:
+    case GTK_SCROLL_PAGE_LEFT:
+    case GTK_SCROLL_START:
+      found = tree_first (combo_box, combo_box->priv->model, &new_iter, FALSE);
+      break;
 
     default:
       return;
@@ -5420,7 +4426,16 @@ gtk_combo_box_mnemonic_activate (GtkWidget *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
-  gtk_widget_grab_focus (combo_box->priv->button);
+  if (combo_box->priv->has_entry)
+    {
+      GtkWidget* child;
+
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
+      if (child)
+       gtk_widget_grab_focus (child);
+    }
+  else
+    gtk_widget_grab_focus (combo_box->priv->button);
 
   return TRUE;
 }
@@ -5430,13 +4445,22 @@ gtk_combo_box_grab_focus (GtkWidget *widget)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
-  gtk_widget_grab_focus (combo_box->priv->button);
+  if (combo_box->priv->has_entry)
+    {
+      GtkWidget *child;
+
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
+      if (child)
+       gtk_widget_grab_focus (child);
+    }
+  else
+    gtk_widget_grab_focus (combo_box->priv->button);
 }
 
 static void
-gtk_combo_box_destroy (GtkObject *object)
+gtk_combo_box_destroy (GtkWidget *widget)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
   if (combo_box->priv->popup_idle_id > 0)
     {
@@ -5453,10 +4477,118 @@ gtk_combo_box_destroy (GtkObject *object)
   combo_box->priv->row_separator_data = NULL;
   combo_box->priv->row_separator_destroy = NULL;
 
-  GTK_OBJECT_CLASS (gtk_combo_box_parent_class)->destroy (object);
+  GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->destroy (widget);
   combo_box->priv->cell_view = NULL;
 }
 
+static void
+gtk_combo_box_entry_contents_changed (GtkEntry *entry,
+                                      gpointer  user_data)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+
+  /*
+   *  Fixes regression reported in bug #574059. The old functionality relied on
+   *  bug #572478.  As a bugfix, we now emit the "changed" signal ourselves
+   *  when the selection was already set to -1.
+   */
+  if (gtk_combo_box_get_active(combo_box) == -1)
+    g_signal_emit_by_name (combo_box, "changed");
+  else
+    gtk_combo_box_set_active (combo_box, -1);
+}
+
+static void
+gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
+                                    gpointer     user_data)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  if (gtk_combo_box_get_active_iter (combo_box, &iter))
+    {
+      GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box)));
+
+      if (entry)
+       {
+          GValue value = {0,};
+
+         g_signal_handlers_block_by_func (entry,
+                                          gtk_combo_box_entry_contents_changed,
+                                          combo_box);
+
+         model = gtk_combo_box_get_model (combo_box);
+
+          gtk_tree_model_get_value (model, &iter,
+                                    priv->text_column, &value);
+          g_object_set_property (G_OBJECT (entry), "text", &value);
+          g_value_unset (&value);
+
+         g_signal_handlers_unblock_by_func (entry,
+                                            gtk_combo_box_entry_contents_changed,
+                                            combo_box);
+       }
+    }
+}
+
+static GObject *
+gtk_combo_box_constructor (GType                  type,
+                          guint                  n_construct_properties,
+                          GObjectConstructParam *construct_properties)
+{
+  GObject            *object;
+  GtkComboBox        *combo_box;
+  GtkComboBoxPrivate *priv;
+  GtkStyleContext    *context;
+
+  object = G_OBJECT_CLASS (gtk_combo_box_parent_class)->constructor
+    (type, n_construct_properties, construct_properties);
+
+  combo_box = GTK_COMBO_BOX (object);
+  priv      = combo_box->priv;
+
+  if (!priv->area)
+    {
+      GtkCellArea *area = gtk_cell_area_box_new ();
+
+      priv->area = g_object_ref_sink (area);
+    }
+
+  priv->cell_view = gtk_cell_view_new_with_context (priv->area, NULL);
+  gtk_cell_view_set_fit_model (GTK_CELL_VIEW (priv->cell_view), TRUE);
+  gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model);
+  gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (combo_box));
+  _gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view);
+  gtk_widget_show (priv->cell_view);
+
+  gtk_combo_box_check_appearance (combo_box);
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (combo_box));
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
+
+  if (priv->has_entry)
+    {
+      GtkWidget *entry;
+
+      entry = gtk_entry_new ();
+      gtk_widget_show (entry);
+      gtk_container_add (GTK_CONTAINER (combo_box), entry);
+
+      priv->text_renderer = gtk_cell_renderer_text_new ();
+      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box),
+                                 priv->text_renderer, TRUE);
+
+      gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), -1);
+
+      g_signal_connect (combo_box, "changed",
+                       G_CALLBACK (gtk_combo_box_entry_active_changed), NULL);
+    }
+
+  return object;
+}
+
+
 static void
 gtk_combo_box_dispose(GObject* object)
 {
@@ -5469,46 +4601,34 @@ gtk_combo_box_dispose(GObject* object)
       combo_box->priv->popup_widget = NULL;
     }
 
-  G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
-}
+  if (combo_box->priv->area)
+    {
+      g_object_unref (combo_box->priv->area);
+      combo_box->priv->area = NULL;
+    }
 
-static void
-gtk_combo_box_finalize (GObject *object)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
-  GSList *i;
-  
   if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
     gtk_combo_box_list_destroy (combo_box);
 
   if (combo_box->priv->popup_window)
-    gtk_widget_destroy (combo_box->priv->popup_window);
-
-  gtk_combo_box_unset_model (combo_box);
-
-  for (i = combo_box->priv->cells; i; i = i->next)
     {
-      ComboCellInfo *info = (ComboCellInfo *)i->data;
-      GSList *list = info->attributes;
+      gtk_widget_destroy (combo_box->priv->popup_window);
+      combo_box->priv->popup_window = NULL;
+    }
 
-      if (info->destroy)
-       info->destroy (info->func_data);
+  gtk_combo_box_unset_model (combo_box);
 
-      while (list && list->next)
-       {
-         g_free (list->data);
-         list = list->next->next;
-       }
-      g_slist_free (info->attributes);
+  G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
+}
 
-      g_object_unref (info->cell);
-      g_slice_free (ComboCellInfo, info);
-    }
-   g_slist_free (combo_box->priv->cells);
+static void
+gtk_combo_box_finalize (GObject *object)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
 
-   g_free (combo_box->priv->tearoff_title);
+  g_free (combo_box->priv->tearoff_title);
 
-   G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
+  G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
 }
 
 static gboolean
@@ -5518,7 +4638,7 @@ gtk_cell_editable_key_press (GtkWidget   *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
 
-  if (event->keyval == GDK_Escape)
+  if (event->keyval == GDK_KEY_Escape)
     {
       g_object_set (combo_box,
                     "editing-canceled", TRUE,
@@ -5528,9 +4648,9 @@ gtk_cell_editable_key_press (GtkWidget   *widget,
       
       return TRUE;
     }
-  else if (event->keyval == GDK_Return ||
-           event->keyval == GDK_ISO_Enter ||
-           event->keyval == GDK_KP_Enter)
+  else if (event->keyval == GDK_KEY_Return ||
+           event->keyval == GDK_KEY_ISO_Enter ||
+           event->keyval == GDK_KEY_KP_Enter)
     {
       gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
       gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
@@ -5594,6 +4714,7 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
                             GdkEvent        *event)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable);
+  GtkWidget *child;
 
   combo_box->priv->is_cell_renderer = TRUE;
 
@@ -5607,12 +4728,14 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
     }
   else
     {
-      g_signal_connect_object (GTK_BIN (combo_box)->child, "key-press-event",
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
+
+      g_signal_connect_object (child, "key-press-event",
                               G_CALLBACK (gtk_cell_editable_key_press), 
                               cell_editable, 0);  
 
-      gtk_widget_grab_focus (GTK_WIDGET (GTK_BIN (combo_box)->child));
-      GTK_WIDGET_UNSET_FLAGS (combo_box->priv->button, GTK_CAN_FOCUS);
+      gtk_widget_grab_focus (child);
+      gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
     }
 
   /* we do the immediate popup only for the optionmenu-like 
@@ -5673,7 +4796,6 @@ gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
     {
       combo_box->priv->add_tearoffs = add_tearoffs;
       gtk_combo_box_check_appearance (combo_box);
-      gtk_combo_box_relayout (combo_box);
       g_object_notify (G_OBJECT (combo_box), "add-tearoffs");
     }
 }
@@ -5740,6 +4862,51 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
     }
 }
 
+
+/**
+ * gtk_combo_box_set_popup_fixed_width:
+ * @combo_box: a #GtkComboBox
+ * @fixed: whether to use a fixed popup width
+ *
+ * Specifies whether the popup's width should be a fixed width
+ * matching the allocated width of the combo box.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
+                                     gboolean     fixed)
+{
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  if (combo_box->priv->popup_fixed_width != fixed)
+    {
+      combo_box->priv->popup_fixed_width = fixed;
+
+      g_object_notify (G_OBJECT (combo_box), "popup-fixed-width");
+    }
+}
+
+/**
+ * gtk_combo_box_get_popup_fixed_width:
+ * @combo_box: a #GtkComboBox
+ *
+ * Gets whether the popup uses a fixed width matching
+ * the allocated width of the combo box.
+ *
+ * Returns: %TRUE if the popup uses a fixed width
+ *
+ * Since: 3.0
+ **/
+gboolean
+gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
+
+  return combo_box->priv->popup_fixed_width;
+}
+
+
 /**
  * gtk_combo_box_get_popup_accessible:
  * @combo_box: a #GtkComboBox
@@ -5749,7 +4916,8 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
  * This function is mostly intended for use by accessibility technologies;
  * applications should have little use for it.
  *
- * Returns: the accessible object corresponding to the combo box's popup.
+ * Returns: (transfer none): the accessible object corresponding
+ *     to the combo box's popup.
  *
  * Since: 2.6
  */
@@ -5815,11 +4983,18 @@ gtk_combo_box_set_row_separator_func (GtkComboBox                 *combo_box,
   combo_box->priv->row_separator_data = data;
   combo_box->priv->row_separator_destroy = destroy;
 
+  /* Provoke the underlying treeview/menu to rebuild themselves with the new separator func */
   if (combo_box->priv->tree_view)
-    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (combo_box->priv->tree_view), 
-                                         func, data, NULL);
+    {
+      gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), NULL);
+      gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), combo_box->priv->model);
+    }
 
-  gtk_combo_box_relayout (combo_box);
+  if (GTK_IS_TREE_MENU (combo_box->priv->popup_widget))
+    {
+      gtk_tree_menu_set_model (GTK_TREE_MENU (combo_box->priv->popup_widget), NULL);
+      gtk_tree_menu_set_model (GTK_TREE_MENU (combo_box->priv->popup_widget), combo_box->priv->model);
+    }
 
   gtk_widget_queue_draw (GTK_WIDGET (combo_box));
 }
@@ -5874,6 +5049,81 @@ gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
 }
 
 
+/**
+ * gtk_combo_box_get_has_entry:
+ * @combo_box: a #GtkComboBox
+ *
+ * Returns whether the combo box has an entry.
+ *
+ * Return Value: whether there is an entry in @combo_box.
+ *
+ * Since: 2.24
+ **/
+gboolean
+gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
+
+  return combo_box->priv->has_entry;
+}
+
+/**
+ * gtk_combo_box_set_entry_text_column:
+ * @combo_box: A #GtkComboBox
+ * @text_column: A column in @model to get the strings from for
+ *     the internal entry
+ *
+ * Sets the model column which @combo_box should use to get strings from
+ * to be @text_column. The column @text_column in the model of @combo_box
+ * must be of type %G_TYPE_STRING.
+ *
+ * This is only relevant if @combo_box has been created with
+ * #GtkComboBox:has-entry as %TRUE.
+ *
+ * Since: 2.24
+ */
+void
+gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
+                                    gint         text_column)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeModel *model;
+
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  model = gtk_combo_box_get_model (combo_box);
+
+  g_return_if_fail (text_column >= 0);
+  g_return_if_fail (model == NULL || text_column < gtk_tree_model_get_n_columns (model));
+
+  priv->text_column = text_column;
+
+  if (priv->text_renderer != NULL)
+    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
+                                    priv->text_renderer,
+                                    "text", text_column,
+                                    NULL);
+}
+
+/**
+ * gtk_combo_box_get_entry_text_column:
+ * @combo_box: A #GtkComboBox.
+ *
+ * Returns the column which @combo_box is using to get the strings
+ * from to display in the internal entry.
+ *
+ * Return value: A column in the data source model of @combo_box.
+ *
+ * Since: 2.24
+ */
+gint
+gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
+
+  return combo_box->priv->text_column;
+}
+
 /**
  * gtk_combo_box_set_focus_on_click:
  * @combo: a #GtkComboBox
@@ -5951,13 +5201,455 @@ gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
                                        const gchar  *tagname,
                                        gpointer     *data)
 {
-  if (strcmp (tagname, "attributes") == 0)
-    _gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname,
-                                              data);
+  if (!_gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname, data))
+    parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname, data);
+}
+
+static GObject *
+gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
+                                           GtkBuilder   *builder,
+                                           const gchar  *childname)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (buildable);
+
+  if (combo_box->priv->has_entry && strcmp (childname, "entry") == 0)
+    return G_OBJECT (gtk_bin_get_child (GTK_BIN (buildable)));
+
+  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
+}
+
+static void     
+gtk_combo_box_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimum_size,
+                                   gint      *natural_size)
+{
+  GtkComboBox           *combo_box = GTK_COMBO_BOX (widget);
+  GtkComboBoxPrivate    *priv = combo_box->priv;
+  gint                   focus_width, focus_pad;
+  gint                   font_size, arrow_size;
+  PangoContext          *context;
+  PangoFontMetrics      *metrics;
+  PangoFontDescription  *font_desc;
+  GtkWidget             *child;
+  gint                   minimum_width = 0, natural_width = 0;
+  gint                   child_min, child_nat;
+  GtkStyleContext       *style_context;
+  GtkStateFlags          state;
+  GtkBorder             *border;
+
+  child = gtk_bin_get_child (GTK_BIN (widget));
+  /* common */
+  gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+
+  gtk_widget_style_get (GTK_WIDGET (widget),
+                       "focus-line-width", &focus_width,
+                       "focus-padding", &focus_pad,
+                       "arrow-size", &arrow_size,
+                       NULL);
+
+  style_context = gtk_widget_get_style_context (widget);
+  state = gtk_widget_get_state_flags (widget);
+
+  gtk_style_context_get (style_context, state,
+                         "font", &font_desc,
+                        "border-width", &border,
+                         NULL);
+
+  context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
+  metrics = pango_context_get_metrics (context, font_desc,
+                                      pango_context_get_language (context));
+  font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+                           pango_font_metrics_get_descent (metrics));
+  pango_font_metrics_unref (metrics);
+  pango_font_description_free (font_desc);
+
+  arrow_size = MAX (arrow_size, font_size);
+
+  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
+
+  if (!priv->tree_view)
+    {
+      /* menu mode */    
+      if (priv->cell_view)
+        {
+          gint sep_width, arrow_width;
+          gint border_width, xpad;
+         GtkBorder button_border;
+
+         border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
+         get_widget_border (priv->button, &button_border);
+
+          gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
+          gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
+
+         xpad = 2 * (border_width + focus_width + focus_pad) +
+            button_border.left + button_border.right;
+
+          minimum_width  = child_min + sep_width + arrow_width + xpad;
+          natural_width  = child_nat + sep_width + arrow_width + xpad;
+        }
+      else
+        {
+          gint but_width, but_nat_width;
+
+          gtk_widget_get_preferred_width (priv->button, 
+                                          &but_width, &but_nat_width);
+
+          minimum_width  = child_min + but_width;
+          natural_width  = child_nat + but_nat_width;
+        }
+    }
+  else
+    {
+      /* list mode */
+      gint button_width, button_nat_width;
+
+      /* sample + frame */
+      minimum_width = child_min;
+      natural_width = child_nat;
+
+      minimum_width += 2 * focus_width;
+      natural_width += 2 * focus_width;
+      
+      if (priv->cell_view_frame)
+        {
+         if (priv->has_frame)
+           {
+             gint border_width, xpad;
+              GtkBorder frame_border;
+
+              border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
+              get_widget_border (priv->cell_view_frame, &frame_border);
+              xpad = (2 * border_width) + frame_border.left + frame_border.right;
+
+             minimum_width  += xpad;
+             natural_width  += xpad;
+           }
+        }
+
+      /* the button */
+      gtk_widget_get_preferred_width (priv->button, 
+                                      &button_width, &button_nat_width);
+
+      minimum_width += button_width;
+      natural_width += button_nat_width;
+    }
+
+  minimum_width += border->left + border->right;
+  natural_width += border->left + border->right;
+  gtk_border_free (border);
+
+  if (minimum_size)
+    *minimum_size = minimum_width;
+
+  if (natural_size)
+    *natural_size = natural_width;
+}
+
+static void
+gtk_combo_box_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum_size,
+                                    gint      *natural_size)
+{ 
+  gint min_width;
+
+  /* Combo box is height-for-width only 
+   * (so we always just reserve enough height for the minimum width) */
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, minimum_size, natural_size);
+}
+
+static void
+gtk_combo_box_get_preferred_width_for_height (GtkWidget *widget,
+                                              gint       avail_size,
+                                              gint      *minimum_size,
+                                              gint      *natural_size)
+{
+  /* Combo box is height-for-width only 
+   * (so we assume we always reserved enough height for the minimum width) */
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_size, natural_size);
+}
+
+
+static void
+gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
+                                              gint       avail_size,
+                                              gint      *minimum_size,
+                                              gint      *natural_size)
+{
+  GtkComboBox           *combo_box = GTK_COMBO_BOX (widget);
+  GtkComboBoxPrivate    *priv = combo_box->priv;
+  gint                   focus_width, focus_pad;
+  gint                   min_height = 0, nat_height = 0;
+  gint                   size;
+  GtkWidget             *child;
+  GtkBorder              border;
+
+  gtk_widget_style_get (GTK_WIDGET (widget),
+                       "focus-line-width", &focus_width,
+                       "focus-padding", &focus_pad,
+                       NULL);
+
+  child = gtk_bin_get_child (GTK_BIN (widget));
+
+  get_widget_border (widget, &border);
+  size = avail_size - border.left;
+
+  if (!priv->tree_view)
+    {
+      /* menu mode */
+      if (priv->cell_view)
+        {
+         /* calculate x/y padding and separator/arrow size */
+          gint sep_width, arrow_width, sep_height, arrow_height;
+          gint border_width, xpad, ypad;
+          GtkBorder button_border;
+
+         border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
+         get_widget_border (priv->button, &button_border);
+
+          gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
+          gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
+          gtk_widget_get_preferred_height_for_width (priv->separator, 
+                                                     sep_width, &sep_height, NULL);
+          gtk_widget_get_preferred_height_for_width (priv->arrow, 
+                                                     arrow_width, &arrow_height, NULL);
+
+         xpad = 2 * (border_width + focus_width + focus_pad) +
+           button_border.left + button_border.right;
+         ypad = 2 * (border_width + focus_width + focus_pad) +
+           button_border.top + button_border.bottom;
+
+         size -= sep_width + arrow_width + xpad;
+
+         /* Get height-for-width of the child widget, usually a GtkCellArea calculating
+          * and fitting the whole treemodel */
+         gtk_widget_get_preferred_height_for_width (child, size, &min_height, &nat_height);
+
+         arrow_height = MAX (arrow_height, sep_height);
+         min_height = MAX (min_height, arrow_height);
+         nat_height = MAX (nat_height, arrow_height);
+
+         min_height += ypad;
+         nat_height += ypad;
+        }
+      else
+        {
+         /* there is a custom child widget inside (no priv->cell_view) */
+          gint but_width, but_height;
+
+          gtk_widget_get_preferred_width (priv->button, &but_width, NULL);
+          gtk_widget_get_preferred_height_for_width (priv->button, 
+                                                     but_width, &but_height, NULL);
+
+         size -= but_width;
+
+         /* Get height-for-width of the child widget, usually a GtkCellArea calculating
+          * and fitting the whole treemodel */
+         gtk_widget_get_preferred_height_for_width (child, size, &min_height, &nat_height);
+         
+         min_height = MAX (min_height, but_height);
+         nat_height = MAX (nat_height, but_height);
+        }
+    }
   else
-    parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname,
-                                           data);
+    {
+      /* list mode */
+      gint but_width, but_height;
+      gint xpad = 0, ypad = 0;
+
+      gtk_widget_get_preferred_width (priv->button, &but_width, NULL);
+      gtk_widget_get_preferred_height_for_width (priv->button, 
+                                                 but_width, &but_height, NULL);
+      
+      if (priv->cell_view_frame && priv->has_frame)
+       {
+         GtkBorder frame_border;
+         gint border_width;
+
+          border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
+         get_widget_border (GTK_WIDGET (priv->cell_view_frame), &frame_border);
+
+         xpad = (2 * border_width) + border.left + frame_border.right;
+         ypad = (2 * border_width) + border.top + frame_border.bottom;
+       }
+
+      size -= but_width;
+      size -= 2 * focus_width;
+      size -= xpad;
+      /* Get height-for-width of the child widget, usually a GtkCellArea calculating
+       * and fitting the whole treemodel */
+      gtk_widget_get_preferred_height_for_width (child, size, &min_height, &nat_height);
+
+      min_height = MAX (min_height, but_height);
+      nat_height = MAX (nat_height, but_height);
+
+      min_height += ypad;
+      nat_height += ypad;
+    }
+
+  min_height += border.top + border.bottom;
+  nat_height += border.top + border.bottom;
+
+  if (minimum_size)
+    *minimum_size = min_height;
+
+  if (natural_size)
+    *natural_size = nat_height;
+}
+
+/**
+ * gtk_combo_box_set_id_column:
+ * @combo_box: A #GtkComboBox
+ * @id_column: A column in @model to get string IDs for values from
+ *
+ * Sets the model column which @combo_box should use to get string IDs
+ * for values from. The column @id_column in the model of @combo_box
+ * must be of type %G_TYPE_STRING.
+ *
+ * Since: 3.0
+ */
+void
+gtk_combo_box_set_id_column (GtkComboBox *combo_box,
+                             gint         id_column)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeModel *model;
+
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  if (id_column != priv->id_column)
+    {
+      model = gtk_combo_box_get_model (combo_box);
+
+      g_return_if_fail (id_column >= 0);
+      g_return_if_fail (model == NULL ||
+                        id_column < gtk_tree_model_get_n_columns (model));
+
+      priv->id_column = id_column;
+
+      g_object_notify (G_OBJECT (combo_box), "id-column");
+      g_object_notify (G_OBJECT (combo_box), "active-id");
+    }
 }
 
-#define __GTK_COMBO_BOX_C__
-#include "gtkaliasdef.c"
+/**
+ * gtk_combo_box_get_id_column:
+ * @combo_box: A #GtkComboBox
+ *
+ * Returns the column which @combo_box is using to get string IDs
+ * for values from.
+ *
+ * Return value: A column in the data source model of @combo_box.
+ *
+ * Since: 3.0
+ */
+gint
+gtk_combo_box_get_id_column (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
+
+  return combo_box->priv->id_column;
+}
+
+/**
+ * gtk_combo_box_get_active_id:
+ * @combo_box: a #GtkComboBox
+ *
+ * Returns the ID of the active row of @combo_box.  This value is taken
+ * from the active row and the column specified by the 'id-column'
+ * property of @combo_box (see gtk_combo_box_set_id_column()).
+ *
+ * The returned value is an interned string which means that you can
+ * compare the pointer by value to other interned strings and that you
+ * must not free it.
+ *
+ * If the 'id-column' property of @combo_box is not set or if no row is
+ * selected then %NULL is returned.
+ *
+ * Return value: the ID of the active row, or %NULL
+ *
+ * Since: 3.0
+ **/
+const gchar *
+gtk_combo_box_get_active_id (GtkComboBox *combo_box)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gint column;
+
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
+
+  column = combo_box->priv->id_column;
+
+  if (column < 0)
+    return NULL;
+
+  model = gtk_combo_box_get_model (combo_box);
+  g_return_val_if_fail (gtk_tree_model_get_column_type (model, column) ==
+                        G_TYPE_STRING, NULL);
+
+  if (gtk_combo_box_get_active_iter (combo_box, &iter))
+    {
+      const gchar *interned;
+      gchar *id;
+
+      gtk_tree_model_get (model, &iter, column, &id, -1);
+      interned = g_intern_string (id);
+      g_free (id);
+
+      return interned;
+    }
+
+  return NULL;
+}
+
+/**
+ * gtk_combo_box_set_active_id:
+ * @combo_box: a #GtkComboBox
+ * @active_id: the ID of the row to select
+ *
+ * Changes the active row of @combo_box to the one that has an ID equal to @id.
+ *
+ * If the 'id-column' property of @combo_box is unset or if no row has
+ * the given ID then nothing happens.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_combo_box_set_active_id (GtkComboBox *combo_box,
+                             const gchar *active_id)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gint column;
+
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  column = combo_box->priv->id_column;
+
+  if (column < 0)
+    return;
+
+  model = gtk_combo_box_get_model (combo_box);
+  g_return_if_fail (gtk_tree_model_get_column_type (model, column) ==
+                    G_TYPE_STRING);
+
+  if (gtk_tree_model_get_iter_first (model, &iter))
+    do {
+      gboolean match;
+      gchar *id;
+
+      gtk_tree_model_get (model, &iter, column, &id, -1);
+      match = strcmp (id, active_id) == 0;
+      g_free (id);
+
+      if (match)
+        {
+          gtk_combo_box_set_active_iter (combo_box, &iter);
+          break;
+        }
+    } while (gtk_tree_model_iter_next (model, &iter));
+}