[gtk+/combo-refactor: 23/50] Implementing GtkComboBox using GtkTreeMenu !



commit 061ee99bdb97bb0387cf461a78d4119b033034dc
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Nov 24 18:14:36 2010 +0900

    Implementing GtkComboBox using GtkTreeMenu !
    
    First iteration at implementing combo box using a delegate
    treemenu, almost everything is working. Still need to finalize
    sensitivity issues in GtkTreeMenu (and should go ahead and pass
    through GtkComboBox code with a fine comb...).

 gtk/gtkcellview.c |   11 +-
 gtk/gtkcombobox.c | 4162 ++++++++++++++++++-----------------------------------
 gtk/gtktreemenu.c |   96 +-
 3 files changed, 1476 insertions(+), 2793 deletions(-)
---
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 17a8794..e2c8bed 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -829,9 +829,14 @@ row_changed_cb (GtkTreeModel         *model,
       row_path = 
 	gtk_tree_row_reference_get_path (view->priv->displayed_row);
 
-      /* Resize everything in our context if our row changed */
-      if (gtk_tree_path_compare (row_path, path) == 0)
-	gtk_cell_area_context_flush (view->priv->context);
+      if (row_path)
+	{
+	  /* Resize everything in our context if our row changed */
+	  if (gtk_tree_path_compare (row_path, path) == 0)
+	    gtk_cell_area_context_flush (view->priv->context);
+
+	  gtk_tree_path_free (row_path);
+	}
     }
 }
 
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index ebdd7f5..4261a2d 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -38,6 +38,8 @@
 #include "gtktreeselection.h"
 #include "gtkvseparator.h"
 #include "gtkwindow.h"
+#include "gtkcellareabox.h"
+#include "gtktreemenu.h"
 #include "gtkprivate.h"
 
 #include <gdk/gdkkeysyms.h>
@@ -81,94 +83,6 @@
 
 
 /* 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;
-};
-
-
-struct _GtkComboBoxPrivate
-{
-  GtkTreeModel *model;
-
-  gint col_column;
-  gint row_column;
-
-  gint wrap_width;
-  GtkShadowType shadow_type;
-
-  gint active; /* Only temporary */
-  GtkTreeRowReference *active_row;
-
-  GtkWidget *tree_view;
-  GtkTreeViewColumn *column;
-
-  GtkWidget *cell_view;
-  GtkWidget *cell_view_frame;
-
-  GtkWidget *button;
-  GtkWidget *box;
-  GtkWidget *arrow;
-  GtkWidget *separator;
-
-  GtkWidget *popup_widget;
-  GtkWidget *popup_window;
-  GtkWidget *scrolled_window;
-
-  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  minimum_width;
-  gint  natural_width;
-
-  /* For "has-entry" specific behavior we track
-   * an automated cell renderer and text column */
-  gint  text_column;
-  GtkCellRenderer *text_renderer;
-
-  gint id_column;
-
-  GSList *cells;
-
-  guint popup_in_progress : 1;
-  guint popup_shown : 1;
-  guint add_tearoffs : 1;
-  guint has_frame : 1;
-  guint is_cell_renderer : 1;
-  guint editing_canceled : 1;
-  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;
-};
-
 /* While debugging this evil code, I have learned that
  * there are actually 4 modes to this widget, which can
  * be characterized as follows
@@ -223,51 +137,12 @@ struct _GtkComboBoxPrivate
  * 
  */
 
-enum {
-  CHANGED,
-  MOVE_ACTIVE,
-  POPUP,
-  POPDOWN,
-  LAST_SIGNAL
-};
-
-enum {
-  PROP_0,
-  PROP_MODEL,
-  PROP_WRAP_WIDTH,
-  PROP_ROW_SPAN_COLUMN,
-  PROP_COLUMN_SPAN_COLUMN,
-  PROP_ACTIVE,
-  PROP_ADD_TEAROFFS,
-  PROP_TEAROFF_TITLE,
-  PROP_HAS_FRAME,
-  PROP_FOCUS_ON_CLICK,
-  PROP_POPUP_SHOWN,
-  PROP_BUTTON_SENSITIVITY,
-  PROP_EDITING_CANCELED,
-  PROP_HAS_ENTRY,
-  PROP_ENTRY_TEXT_COLUMN,
-  PROP_POPUP_FIXED_WIDTH,
-  PROP_ID_COLUMN,
-  PROP_ACTIVE_ID
-};
-
-static guint combo_box_signals[LAST_SIGNAL] = {0,};
-
-#define BONUS_PADDING 4
-#define SCROLL_TIME  100
-
-/* common */
-
-static void     gtk_combo_box_cell_layout_init     (GtkCellLayoutIface *iface);
-static void     gtk_combo_box_cell_editable_init   (GtkCellEditableIface *iface);
+/* GObjectClass */
 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              (GtkWidget        *widget);
-
 static void     gtk_combo_box_set_property         (GObject         *object,
                                                     guint            prop_id,
                                                     const GValue    *value,
@@ -277,23 +152,49 @@ static void     gtk_combo_box_get_property         (GObject         *object,
                                                     GValue          *value,
                                                     GParamSpec      *spec);
 
-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_button_toggled       (GtkWidget       *widget,
-                                                    gpointer         data);
-static void     gtk_combo_box_button_state_changed (GtkWidget       *widget,
-			                            GtkStateType     previous,
-						    gpointer         data);
+/* GtkWidgetClass */
+static void     gtk_combo_box_destroy                        (GtkWidget           *widget);
+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_size_allocate                  (GtkWidget           *widget,
+							      GtkAllocation       *allocation);
+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);
+static gboolean gtk_combo_box_draw                           (GtkWidget           *widget,
+							      cairo_t             *cr);
+static gboolean gtk_combo_box_scroll_event                   (GtkWidget           *widget,
+							      GdkEventScroll      *event);
+
+/* GtkContainerClass */
 static void     gtk_combo_box_add                  (GtkContainer    *container,
                                                     GtkWidget       *widget);
 static void     gtk_combo_box_remove               (GtkContainer    *container,
                                                     GtkWidget       *widget);
+static void     gtk_combo_box_forall               (GtkContainer    *container,
+                                                    gboolean         include_internals,
+                                                    GtkCallback      callback,
+                                                    gpointer         callback_data);
 
-static ComboCellInfo *gtk_combo_box_get_cell_info  (GtkComboBox      *combo_box,
-                                                    GtkCellRenderer  *cell);
+/* GtkComboBoxClass (binding handlers) */
+static void     gtk_combo_box_real_move_active     (GtkComboBox      *combo_box,
+                                                    GtkScrollType     scroll);
+static void     gtk_combo_box_real_popup           (GtkComboBox      *combo_box);
+static gboolean gtk_combo_box_real_popdown         (GtkComboBox      *combo_box);
 
 static void     gtk_combo_box_menu_show            (GtkWidget        *menu,
                                                     gpointer          user_data);
@@ -318,48 +219,18 @@ static void     gtk_combo_box_menu_position        (GtkMenu          *menu,
                                                     gint             *push_in,
                                                     gpointer          user_data);
 
-static void     gtk_combo_box_update_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_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_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_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 void     gtk_combo_box_real_move_active     (GtkComboBox      *combo_box,
-                                                    GtkScrollType     scroll);
-static void     gtk_combo_box_real_popup           (GtkComboBox      *combo_box);
-static gboolean gtk_combo_box_real_popdown         (GtkComboBox      *combo_box);
 
-/* listening to the model */
-static void     gtk_combo_box_model_row_inserted   (GtkTreeModel     *model,
-						    GtkTreePath      *path,
-						    GtkTreeIter      *iter,
-						    gpointer          user_data);
-static void     gtk_combo_box_model_row_deleted    (GtkTreeModel     *model,
-						    GtkTreePath      *path,
-						    gpointer          user_data);
-static void     gtk_combo_box_model_rows_reordered (GtkTreeModel     *model,
-						    GtkTreePath      *path,
-						    GtkTreeIter      *iter,
-						    gint             *new_order,
-						    gpointer          user_data);
-static void     gtk_combo_box_model_row_changed    (GtkTreeModel     *model,
-						    GtkTreePath      *path,
-						    GtkTreeIter      *iter,
-						    gpointer          data);
 static void     gtk_combo_box_model_row_expanded   (GtkTreeModel     *model,
 						    GtkTreePath      *path,
 						    GtkTreeIter      *iter,
@@ -397,94 +268,29 @@ static gboolean gtk_combo_box_list_select_func     (GtkTreeSelection *selection,
 						    gboolean          path_currently_selected,
 						    gpointer          data);
 
-static void     gtk_combo_box_list_row_changed     (GtkTreeModel     *model,
-                                                    GtkTreePath      *path,
-                                                    GtkTreeIter      *iter,
-                                                    gpointer          data);
 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 void     gtk_combo_box_update_title         (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_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 void     gtk_combo_box_menu_activate        (GtkWidget        *menu,
+						    const gchar      *path,
+						    GtkComboBox      *combo_box);
 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);
+
 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,
@@ -495,11 +301,7 @@ static void     gtk_combo_box_entry_contents_changed         (GtkEntry        *e
 							      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;
-
+/* GtkBuildableIface */
 static void     gtk_combo_box_buildable_init                 (GtkBuildableIface *iface);
 static gboolean gtk_combo_box_buildable_custom_tag_start     (GtkBuildable  *buildable,
 							      GtkBuilder    *builder,
@@ -516,25 +318,127 @@ static GObject *gtk_combo_box_buildable_get_internal_child   (GtkBuildable *buil
 							      GtkBuilder   *builder,
 							      const gchar  *childname);
 
-
-/* GtkCellEditable method implementations */
+/* GtkCellEditable  */
+static void     gtk_combo_box_cell_editable_init             (GtkCellEditableIface *iface);
 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);
+/* GtkCellLayoutIface */
+static void     gtk_combo_box_cell_layout_init               (GtkCellLayoutIface *iface);
+static GtkCellArea *gtk_combo_box_cell_layout_get_area       (GtkCellLayout         *layout);
+
+
+struct _GtkComboBoxPrivate
+{
+  GtkTreeModel *model;
+
+  /* The cell area shared with the treeview or treemenu */
+  GtkCellArea *area;
+
+  gint col_column;
+  gint row_column;
+  gint id_column;
+
+  gint wrap_width;
+  GtkShadowType shadow_type;
+
+  gint active; /* Only temporary */
+  GtkTreeRowReference *active_row;
+
+
+  /* The cellview displayed on the button */
+  GtkWidget *cell_view;
+  GtkWidget *cell_view_frame;
+
+  /* The treeview & column for list mode */
+  GtkWidget         *tree_view;
+  GtkTreeViewColumn *column;
+
+  GtkWidget *button;
+  GtkWidget *box;
+  GtkWidget *arrow;
+  GtkWidget *separator;
+
+  GtkWidget *popup_widget;
+  GtkWidget *popup_window;
+  GtkWidget *scrolled_window;
+
+  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;
+
+  /* For "has-entry" specific behavior we track
+   * an automated cell renderer and text column */
+  gint             text_column;
+  GtkCellRenderer *text_renderer;
+
+  guint popup_in_progress : 1;
+  guint popup_shown : 1;
+  guint add_tearoffs : 1;
+  guint has_frame : 1;
+  guint is_cell_renderer : 1;
+  guint editing_canceled : 1;
+  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;
+};
+
+
+enum {
+  CHANGED,
+  MOVE_ACTIVE,
+  POPUP,
+  POPDOWN,
+  LAST_SIGNAL
+};
+
+enum {
+  PROP_0,
+  PROP_MODEL,
+  PROP_WRAP_WIDTH,
+  PROP_ROW_SPAN_COLUMN,
+  PROP_COLUMN_SPAN_COLUMN,
+  PROP_ACTIVE,
+  PROP_ADD_TEAROFFS,
+  PROP_TEAROFF_TITLE,
+  PROP_HAS_FRAME,
+  PROP_FOCUS_ON_CLICK,
+  PROP_POPUP_SHOWN,
+  PROP_BUTTON_SENSITIVITY,
+  PROP_EDITING_CANCELED,
+  PROP_HAS_ENTRY,
+  PROP_ENTRY_TEXT_COLUMN,
+  PROP_POPUP_FIXED_WIDTH,
+  PROP_ID_COLUMN,
+  PROP_ACTIVE_ID,
+  PROP_CELL_AREA
+};
+
+#define BONUS_PADDING 4
+#define SCROLL_TIME  100
+
+static guint combo_box_signals[LAST_SIGNAL] = {0,};
+
+
+/* GtkBuildable method implementation */
+static GtkBuildableIface *parent_buildable_iface;
 
 
 G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
@@ -555,31 +459,31 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   GtkWidgetClass *widget_class;
   GtkBindingSet *binding_set;
 
-  container_class = (GtkContainerClass *)klass;
-  container_class->forall = gtk_combo_box_forall;
-  container_class->add = gtk_combo_box_add;
-  container_class->remove = gtk_combo_box_remove;
+  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;
+  object_class->get_property = gtk_combo_box_get_property;
 
   widget_class = (GtkWidgetClass *)klass;
-  widget_class->size_allocate = gtk_combo_box_size_allocate;
   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->state_changed = gtk_combo_box_state_changed;
+  widget_class->size_allocate = gtk_combo_box_size_allocate;
   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;
-  object_class->get_property = gtk_combo_box_get_property;
+  container_class = (GtkContainerClass *)klass;
+  container_class->forall = gtk_combo_box_forall;
+  container_class->add = gtk_combo_box_add;
+  container_class->remove = gtk_combo_box_remove;
 
   /* signals */
   /**
@@ -983,6 +887,20 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                          P_("The value of the id column "
                                                          "for the active row"),
                                                          NULL, 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));
 
    /**
     * GtkComboBox:popup-fixed-width:
@@ -1047,35 +965,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
 }
 
 static void
-gtk_combo_box_buildable_init (GtkBuildableIface *iface)
-{
-  parent_buildable_iface = g_type_interface_peek_parent (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;
-}
-
-static void
-gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface)
-{
-  iface->start_editing = gtk_combo_box_start_editing;
-}
-
-static void
 gtk_combo_box_init (GtkComboBox *combo_box)
 {
   GtkComboBoxPrivate *priv;
@@ -1085,14 +974,6 @@ gtk_combo_box_init (GtkComboBox *combo_box)
                                                  GtkComboBoxPrivate);
   priv = combo_box->priv;
 
-  priv->cell_view = gtk_cell_view_new ();
-  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);
-
-  priv->minimum_width = 0;
-  priv->natural_width = 0;
-
   priv->wrap_width = 0;
 
   priv->active = -1;
@@ -1114,8 +995,97 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   priv->text_column = -1;
   priv->text_renderer = NULL;
   priv->id_column = -1;
+}
+
+/******************************************************
+ *                    GObjectClass                    *
+ ******************************************************/
+static GObject *
+gtk_combo_box_constructor (GType                  type,
+			   guint                  n_construct_properties,
+			   GObjectConstructParam *construct_properties)
+{
+  GObject            *object;
+  GtkComboBox        *combo_box;
+  GtkComboBoxPrivate *priv;
+
+  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);
+    }
+
+  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);
+    }
+  else
+    {
+      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_container_add (GTK_CONTAINER (combo_box), priv->cell_view);
+      gtk_widget_show (priv->cell_view);
+    }
 
   gtk_combo_box_check_appearance (combo_box);
+
+  return object;
+}
+
+static void
+gtk_combo_box_dispose(GObject* object)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+
+  if (GTK_IS_MENU (combo_box->priv->popup_widget))
+    {
+      gtk_combo_box_menu_destroy (combo_box);
+      gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
+      combo_box->priv->popup_widget = NULL;
+    }
+
+  g_object_unref (combo_box->priv->area);
+  combo_box->priv->area = NULL;
+
+  G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
+}
+
+static void
+gtk_combo_box_finalize (GObject *object)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+  
+  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);
+
+  g_free (combo_box->priv->tearoff_title);
+
+  G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
 }
 
 static void
@@ -1125,6 +1095,7 @@ gtk_combo_box_set_property (GObject      *object,
                             GParamSpec   *pspec)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+  GtkCellArea *area;
 
   switch (prop_id)
     {
@@ -1213,6 +1184,14 @@ gtk_combo_box_set_property (GObject      *object,
       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;
@@ -1298,12 +1277,362 @@ gtk_combo_box_get_property (GObject    *object,
         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;
     }
 }
 
+/******************************************************
+ *                    GtkWidgetClass                  *
+ ******************************************************/
+static gboolean
+gtk_combo_box_draw (GtkWidget *widget,
+                    cairo_t   *cr)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+  GtkComboBoxPrivate *priv = combo_box->priv;
+
+  if (priv->shadow_type != GTK_SHADOW_NONE)
+    {
+      gtk_paint_shadow (gtk_widget_get_style (widget),
+                        cr,
+                        GTK_STATE_NORMAL, priv->shadow_type,
+                        widget, "combobox",
+                        0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
+    }
+
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+				priv->button, cr);
+
+  if (priv->tree_view && priv->cell_view_frame)
+    {
+      gtk_container_propagate_draw (GTK_CONTAINER (widget),
+				    priv->cell_view_frame, cr);
+    }
+
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                                gtk_bin_get_child (GTK_BIN (widget)),
+                                cr);
+
+  return FALSE;
+}
+
+
+typedef struct {
+  GtkComboBox *combo;
+  GtkTreePath *path;
+  GtkTreeIter iter;
+  gboolean found;
+  gboolean set;
+  gboolean visible;
+} SearchData;
+
+static gboolean
+path_visible (GtkTreeView *view,
+	      GtkTreePath *path)
+{
+  GtkRBTree *tree;
+  GtkRBNode *node;
+  
+  /* Note that we rely on the fact that collapsed rows don't have nodes 
+   */
+  return _gtk_tree_view_find_node (view, path, &tree, &node);
+}
+
+static gboolean
+tree_column_row_is_sensitive (GtkComboBox *combo_box,
+			      GtkTreeIter *iter)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GList *cells, *list;
+  gboolean sensitive;
+
+  if (!priv->column)
+    return TRUE;
+
+  if (priv->row_separator_func)
+    {
+      if (priv->row_separator_func (priv->model, iter,
+                                    priv->row_separator_data))
+	return FALSE;
+    }
+
+  gtk_tree_view_column_cell_set_cell_data (priv->column,
+					   priv->model,
+					   iter, FALSE, FALSE);
+
+  cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->column));
+
+  sensitive = FALSE;
+  for (list = cells; list; list = list->next)
+    {
+      g_object_get (list->data, "sensitive", &sensitive, NULL);
+      
+      if (sensitive)
+	break;
+    }
+  g_list_free (cells);
+
+  return sensitive;
+}
+
+static gboolean
+tree_next_func (GtkTreeModel *model,
+		GtkTreePath  *path,
+		GtkTreeIter  *iter,
+		gpointer      data)
+{
+  SearchData *search_data = (SearchData *)data;
+
+  if (search_data->found) 
+    {
+      if (!tree_column_row_is_sensitive (search_data->combo, iter))
+	return FALSE;
+      
+      if (search_data->visible &&
+	  !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
+	return FALSE;
+
+      search_data->set = TRUE;
+      search_data->iter = *iter;
+
+      return TRUE;
+    }
+ 
+  if (gtk_tree_path_compare (path, search_data->path) == 0)
+    search_data->found = TRUE;
+  
+  return FALSE;
+}
+
+static gboolean
+tree_next (GtkComboBox  *combo,
+	   GtkTreeModel *model,
+	   GtkTreeIter  *iter,
+	   GtkTreeIter  *next,
+	   gboolean      visible)
+{
+  SearchData search_data;
+
+  search_data.combo = combo;
+  search_data.path = gtk_tree_model_get_path (model, iter);
+  search_data.visible = visible;
+  search_data.found = FALSE;
+  search_data.set = FALSE;
+
+  gtk_tree_model_foreach (model, tree_next_func, &search_data);
+  
+  *next = search_data.iter;
+
+  gtk_tree_path_free (search_data.path);
+
+  return search_data.set;
+}
+
+static gboolean
+tree_prev_func (GtkTreeModel *model,
+		GtkTreePath  *path,
+		GtkTreeIter  *iter,
+		gpointer      data)
+{
+  SearchData *search_data = (SearchData *)data;
+
+  if (gtk_tree_path_compare (path, search_data->path) == 0)
+    {
+      search_data->found = TRUE;
+      return TRUE;
+    }
+  
+  if (!tree_column_row_is_sensitive (search_data->combo, iter))
+    return FALSE;
+      
+  if (search_data->visible &&
+      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
+    return FALSE; 
+  
+  search_data->set = TRUE;
+  search_data->iter = *iter;
+  
+  return FALSE; 
+}
+
+static gboolean
+tree_prev (GtkComboBox  *combo,
+	   GtkTreeModel *model,
+	   GtkTreeIter  *iter,
+	   GtkTreeIter  *prev,
+	   gboolean      visible)
+{
+  SearchData search_data;
+
+  search_data.combo = combo;
+  search_data.path = gtk_tree_model_get_path (model, iter);
+  search_data.visible = visible;
+  search_data.found = FALSE;
+  search_data.set = FALSE;
+
+  gtk_tree_model_foreach (model, tree_prev_func, &search_data);
+  
+  *prev = search_data.iter;
+
+  gtk_tree_path_free (search_data.path);
+
+  return search_data.set;
+}
+
+static gboolean
+tree_last_func (GtkTreeModel *model,
+		GtkTreePath  *path,
+		GtkTreeIter  *iter,
+		gpointer      data)
+{
+  SearchData *search_data = (SearchData *)data;
+
+  if (!tree_column_row_is_sensitive (search_data->combo, iter))
+    return FALSE;
+      
+  /* Note that we rely on the fact that collapsed rows don't have nodes 
+   */
+  if (search_data->visible &&
+      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
+    return FALSE; 
+  
+  search_data->set = TRUE;
+  search_data->iter = *iter;
+  
+  return FALSE; 
+}
+
+static gboolean
+tree_last (GtkComboBox  *combo,
+	   GtkTreeModel *model,
+	   GtkTreeIter  *last,
+	   gboolean      visible)
+{
+  SearchData search_data;
+
+  search_data.combo = combo;
+  search_data.visible = visible;
+  search_data.set = FALSE;
+
+  gtk_tree_model_foreach (model, tree_last_func, &search_data);
+  
+  *last = search_data.iter;
+
+  return search_data.set;  
+}
+
+
+static gboolean
+tree_first_func (GtkTreeModel *model,
+		 GtkTreePath  *path,
+		 GtkTreeIter  *iter,
+		 gpointer      data)
+{
+  SearchData *search_data = (SearchData *)data;
+
+  if (!tree_column_row_is_sensitive (search_data->combo, iter))
+    return FALSE;
+  
+  if (search_data->visible &&
+      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
+    return FALSE;
+  
+  search_data->set = TRUE;
+  search_data->iter = *iter;
+  
+  return TRUE;
+}
+
+static gboolean
+tree_first (GtkComboBox  *combo,
+	    GtkTreeModel *model,
+	    GtkTreeIter  *first,
+	    gboolean      visible)
+{
+  SearchData search_data;
+  
+  search_data.combo = combo;
+  search_data.visible = visible;
+  search_data.set = FALSE;
+
+  gtk_tree_model_foreach (model, tree_first_func, &search_data);
+  
+  *first = search_data.iter;
+
+  return search_data.set;  
+}
+
+static gboolean
+gtk_combo_box_scroll_event (GtkWidget          *widget,
+                            GdkEventScroll     *event)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+  gboolean found;
+  GtkTreeIter iter;
+  GtkTreeIter new_iter;
+
+  if (!gtk_combo_box_get_active_iter (combo_box, &iter))
+    return TRUE;
+  
+  if (event->direction == GDK_SCROLL_UP)
+    found = tree_prev (combo_box, combo_box->priv->model, 
+		       &iter, &new_iter, FALSE);
+  else
+    found = tree_next (combo_box, combo_box->priv->model, 
+		       &iter, &new_iter, FALSE);
+  
+  if (found)
+    gtk_combo_box_set_active_iter (combo_box, &new_iter);
+
+  return TRUE;
+}
+
+
+static gboolean
+gtk_combo_box_mnemonic_activate (GtkWidget *widget,
+				 gboolean   group_cycling)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+
+  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;
+}
+
+static void
+gtk_combo_box_grab_focus (GtkWidget *widget)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
+
+  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_state_changed (GtkWidget    *widget,
 			     GtkStateType  previous)
@@ -1365,7 +1694,7 @@ gtk_combo_box_check_appearance (GtkComboBox *combo_box)
     {
       /* Destroy all the menu mode widgets, if they exist. */
       if (GTK_IS_MENU (priv->popup_widget))
-	gtk_combo_box_menu_destroy (combo_box);
+      	gtk_combo_box_menu_destroy (combo_box);
 
       /* Create the list mode widgets, if they don't already exist. */
       if (!GTK_IS_TREE_VIEW (priv->tree_view))
@@ -1409,20 +1738,33 @@ gtk_combo_box_style_set (GtkWidget *widget,
 }
 
 static void
-gtk_combo_box_button_toggled (GtkWidget *widget,
-                              gpointer   data)
+gtk_combo_box_destroy (GtkWidget *widget)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+  if (combo_box->priv->popup_idle_id > 0)
     {
-      if (!combo_box->priv->popup_in_progress)
-        gtk_combo_box_popup (combo_box);
+      g_source_remove (combo_box->priv->popup_idle_id);
+      combo_box->priv->popup_idle_id = 0;
     }
-  else
-    gtk_combo_box_popdown (combo_box);
+
+  gtk_combo_box_popdown (combo_box);
+
+  if (combo_box->priv->row_separator_destroy)
+    combo_box->priv->row_separator_destroy (combo_box->priv->row_separator_data);
+
+  combo_box->priv->row_separator_func = NULL;
+  combo_box->priv->row_separator_data = NULL;
+  combo_box->priv->row_separator_destroy = NULL;
+
+  GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->destroy (widget);
+  combo_box->priv->cell_view = NULL;
 }
 
+/******************************************************
+ *                  GtkContainerClass                 *
+ ******************************************************/
+
 static void
 gtk_combo_box_add (GtkContainer *container,
                    GtkWidget    *widget)
@@ -1441,11 +1783,10 @@ gtk_combo_box_add (GtkContainer *container,
   if (priv->cell_view &&
       gtk_widget_get_parent (priv->cell_view))
     {
-      gtk_widget_unparent (priv->cell_view);
-      _gtk_bin_set_child (GTK_BIN (container), NULL);
+      gtk_container_remove (container, priv->cell_view);
       gtk_widget_queue_resize (GTK_WIDGET (container));
     }
-  
+
   gtk_widget_set_parent (widget, GTK_WIDGET (container));
   _gtk_bin_set_child (GTK_BIN (container), widget);
 
@@ -1473,6 +1814,10 @@ gtk_combo_box_add (GtkContainer *container,
 
   if (priv->has_entry)
     {
+      /* this flag is a hack to tell the entry to fill its allocation.
+       */
+      GTK_ENTRY (widget)->is_cell_renderer = TRUE;
+
       g_signal_connect (widget, "changed",
 			G_CALLBACK (gtk_combo_box_entry_contents_changed),
 			combo_box);
@@ -1500,14 +1845,14 @@ gtk_combo_box_remove (GtkContainer *container,
 	  g_signal_handlers_disconnect_by_func (widget,
 						gtk_combo_box_entry_contents_changed,
 						container);
+	  GTK_ENTRY (widget)->is_cell_renderer = FALSE;
 	}
     }
 
   if (widget == priv->cell_view)
     priv->cell_view = NULL;
 
-  gtk_widget_unparent (widget);
-  _gtk_bin_set_child (GTK_BIN (container), NULL);
+  GTK_CONTAINER_CLASS (gtk_combo_box_parent_class)->remove (container, widget);
 
   if (gtk_widget_in_destruction (GTK_WIDGET (combo_box)))
     return;
@@ -1530,17 +1875,15 @@ gtk_combo_box_remove (GtkContainer *container,
 
   if (!priv->cell_view)
     {
-      priv->cell_view = gtk_cell_view_new ();
-      gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (container));
-      _gtk_bin_set_child (GTK_BIN (container), priv->cell_view);
+      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_CONTAINER_CLASS (gtk_combo_box_parent_class)->add (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));
+      gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model);
     }
 
-
   if (appears_as_list)
     gtk_combo_box_list_setup (combo_box); 
   else
@@ -1556,21 +1899,169 @@ 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)
+static void
+gtk_combo_box_forall (GtkContainer *container,
+                      gboolean      include_internals,
+                      GtkCallback   callback,
+                      gpointer      callback_data)
 {
-  GSList *i;
+  GtkComboBox *combo_box = GTK_COMBO_BOX (container);
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkWidget *child;
 
-  for (i = combo_box->priv->cells; i; i = i->next)
+  if (include_internals)
     {
-      ComboCellInfo *info = (ComboCellInfo *)i->data;
+      if (priv->button)
+	(* callback) (priv->button, callback_data);
+      if (priv->cell_view_frame)
+	(* callback) (priv->cell_view_frame, callback_data);
+    }
+
+  child = gtk_bin_get_child (GTK_BIN (container));
+  if (child)
+    (* callback) (child, callback_data);
+}
 
-      if (info && info->cell == cell)
-        return info;
+
+/******************************************************
+ *        GtkComboBoxClass (binding methods)          *
+ ******************************************************/
+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;
     }
 
-  return NULL;
+  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;
+
+    default:
+      return;
+    }
+
+  if (found && active_iter)
+    {
+      GtkTreePath *old_path;
+      GtkTreePath *new_path;
+
+      old_path = gtk_tree_model_get_path (combo_box->priv->model, &iter);
+      new_path = gtk_tree_model_get_path (combo_box->priv->model, &new_iter);
+
+      if (gtk_tree_path_compare (old_path, new_path) == 0)
+        found = FALSE;
+
+      gtk_tree_path_free (old_path);
+      gtk_tree_path_free (new_path);
+    }
+
+  if (found)
+    {
+      gtk_combo_box_set_active_iter (combo_box, &new_iter);
+    }
+  else
+    {
+      gtk_widget_error_bell (GTK_WIDGET (combo_box));
+    }
+}
+
+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
+gtk_combo_box_real_popdown (GtkComboBox *combo_box)
+{
+  if (combo_box->priv->popup_shown)
+    {
+      gtk_combo_box_popdown (combo_box);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+
+
+static void
+gtk_combo_box_button_toggled (GtkWidget *widget,
+                              gpointer   data)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
+
+  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+    {
+      if (!combo_box->priv->popup_in_progress)
+        gtk_combo_box_popup (combo_box);
+    }
+  else
+    gtk_combo_box_popdown (combo_box);
 }
 
 static void
@@ -1951,9 +2442,8 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
     }
   else
     {
-      gtk_combo_box_remeasure (combo_box);
-
-      if (priv->natural_width > *width)
+      /* XXX Here we need the GtkCellAreaContext shared with the treemenu/treeviewcolumn */
+      if (1/* XXX */ > *width)
 	{
 	  hpolicy = GTK_POLICY_NEVER;
 	  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
@@ -1969,7 +2459,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
 	   * treeviews are left ellipsizing) , however it this all should be
 	   * removed with height-for-width treeviews.
 	   */
-	  gtk_widget_set_size_request (priv->tree_view, priv->natural_width + 5, -1);
+	  gtk_widget_set_size_request (priv->tree_view, 1 /* XXX */ + 5, -1);
 	  gtk_widget_get_preferred_size (priv->scrolled_window, NULL, &popup_req);
 
 	  *width = popup_req.width;
@@ -2014,111 +2504,6 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
     }
 } 
 
-static gboolean
-cell_view_is_sensitive (GtkCellView *cell_view)
-{
-  GList *cells, *list;
-  gboolean sensitive;
-  
-  cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (cell_view));
-
-  sensitive = FALSE;
-  for (list = cells; list; list = list->next)
-    {
-      g_object_get (list->data, "sensitive", &sensitive, NULL);
-      
-      if (sensitive)
-	break;
-    }
-  g_list_free (cells);
-
-  return sensitive;
-}
-
-static gboolean
-tree_column_row_is_sensitive (GtkComboBox *combo_box,
-			      GtkTreeIter *iter)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GList *cells, *list;
-  gboolean sensitive;
-
-  if (!priv->column)
-    return TRUE;
-
-  if (priv->row_separator_func)
-    {
-      if (priv->row_separator_func (priv->model, iter,
-                                    priv->row_separator_data))
-	return FALSE;
-    }
-
-  gtk_tree_view_column_cell_set_cell_data (priv->column,
-					   priv->model,
-					   iter, FALSE, FALSE);
-
-  cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->column));
-
-  sensitive = FALSE;
-  for (list = cells; list; list = list->next)
-    {
-      g_object_get (list->data, "sensitive", &sensitive, NULL);
-      
-      if (sensitive)
-	break;
-    }
-  g_list_free (cells);
-
-  return sensitive;
-}
-
-static void
-update_menu_sensitivity (GtkComboBox *combo_box,
-			 GtkWidget   *menu)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GList *children, *child;
-  GtkWidget *item, *submenu, *separator;
-  GtkWidget *cell_view;
-  gboolean sensitive;
-
-  if (!priv->model)
-    return;
-
-  children = gtk_container_get_children (GTK_CONTAINER (menu));
-
-  for (child = children; child; child = child->next)
-    {
-      item = GTK_WIDGET (child->data);
-      cell_view = gtk_bin_get_child (GTK_BIN (item));
-
-      if (!GTK_IS_CELL_VIEW (cell_view))
-	continue;
-      
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item));
-      if (submenu != NULL)
-	{
-	  gtk_widget_set_sensitive (item, TRUE);
-	  update_menu_sensitivity (combo_box, submenu);
-	}
-      else
-	{
-	  sensitive = cell_view_is_sensitive (GTK_CELL_VIEW (cell_view));
-
-	  if (menu != priv->popup_widget && child == children)
-	    {
-	      separator = GTK_WIDGET (child->next->data);
-	      g_object_set (item, "visible", sensitive, NULL);
-	      g_object_set (separator, "visible", sensitive, NULL);
-	    }
-	  else
-	    gtk_widget_set_sensitive (item, sensitive);
-	}
-    }
-
-  g_list_free (children);
-}
-
 static void 
 gtk_combo_box_menu_popup (GtkComboBox *combo_box,
 			  guint        button, 
@@ -2129,8 +2514,6 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
   gint active_item;
   gint width, min_width, nat_width;
   
-  update_menu_sensitivity (combo_box, priv->popup_widget);
-
   active_item = -1;
   if (gtk_tree_row_reference_valid (priv->active_row))
     {
@@ -2197,242 +2580,282 @@ popup_grab_on_window (GdkWindow *window,
   return TRUE;
 }
 
-/**
- * gtk_combo_box_popup:
- * @combo_box: a #GtkComboBox
- * 
- * Pops up the menu or dropdown list of @combo_box. 
- *
- * This function is mostly intended for use by accessibility technologies;
- * applications should have little use for it.
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_popup (GtkComboBox *combo_box)
+static void     
+gtk_combo_box_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimum_size,
+                                   gint      *natural_size)
 {
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+  GtkComboBox           *combo_box = GTK_COMBO_BOX (widget);
+  GtkComboBoxPrivate    *priv = combo_box->priv;
+  GtkStyle              *style;
+  gint                   focus_width, focus_pad;
+  gint                   font_size, arrow_size;
+  PangoContext          *context;
+  PangoFontMetrics      *metrics;
+  PangoFontDescription  *font_desc;
+  GtkWidget             *child;
+  gint                   minimum_width, natural_width;
+  gint                   child_min, child_nat;
 
-  g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
-}
+  child = gtk_bin_get_child (GTK_BIN (widget));
+ 
+  /* common */
+  gtk_widget_get_preferred_width (child, &child_min, &child_nat);
 
-/**
- * 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;
+  gtk_widget_style_get (GTK_WIDGET (widget),
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"arrow-size", &arrow_size,
+			NULL);
 
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GDK_IS_DEVICE (device));
+  font_desc = gtk_widget_get_style (child)->font_desc;
+  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);
 
-  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
-    return;
+  arrow_size = MAX (arrow_size, font_size);
 
-  if (gtk_widget_get_mapped (priv->popup_widget))
-    return;
+  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
 
-  if (priv->grab_pointer && priv->grab_keyboard)
-    return;
+  if (!priv->tree_view)
+    {
+      /* menu mode */	  
+      if (priv->cell_view)
+        {
+          gint sep_width, arrow_width;
+          gint border_width, xthickness, xpad;
 
-  time = gtk_get_current_event_time ();
+	  border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
+          xthickness   = gtk_widget_get_style (priv->button)->xthickness;
 
-  if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
-    {
-      keyboard = device;
-      pointer = gdk_device_get_associated_device (device);
+          gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
+          gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
+
+	  xpad = 2*(border_width + xthickness + focus_width + focus_pad);
+
+          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
     {
-      pointer = device;
-      keyboard = gdk_device_get_associated_device (device);
-    }
+      /* list mode */
+      gint button_width, button_nat_width;
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    {
-      gtk_combo_box_menu_popup (combo_box, 
-                                priv->activate_button,
-                                priv->activate_time);
-      return;
-    }
+      /* sample + frame */
+      minimum_width = child_min;
+      natural_width = child_nat;
 
-  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
-  if (GTK_IS_WINDOW (toplevel))
-    gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), 
-				 GTK_WINDOW (priv->popup_window));
+      minimum_width += 2 * focus_width;
+      natural_width += 2 * focus_width;
+      
+      if (priv->cell_view_frame)
+        {
+	  if (priv->has_frame)
+	    {
+	      gint border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
+	      gint xpad         = 2 * (border_width + gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame))->xthickness);
 
-  gtk_widget_show_all (priv->scrolled_window);
-  gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
-  
-  gtk_widget_set_size_request (priv->popup_window, width, height);  
-  gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
+	      minimum_width  += xpad;
+	      natural_width  += xpad;
+	    }
+        }
 
-  if (gtk_tree_row_reference_valid (priv->active_row))
-    {
-      path = gtk_tree_row_reference_get_path (priv->active_row);
-      ppath = gtk_tree_path_copy (path);
-      if (gtk_tree_path_up (ppath))
-	gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->tree_view),
-				      ppath);
-      gtk_tree_path_free (ppath);
+      /* the button */
+      gtk_widget_get_preferred_width (priv->button, 
+                                      &button_width, &button_nat_width);
+
+      minimum_width += button_width;
+      natural_width += button_nat_width;
     }
-  gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view), 
-				  TRUE);
-  
-  /* popup */
-  gtk_widget_show (priv->popup_window);
 
-  if (path)
+  if (GTK_SHADOW_NONE != priv->shadow_type)
     {
-      gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
-				path, NULL, FALSE);
-      gtk_tree_path_free (path);
+      style = gtk_widget_get_style (GTK_WIDGET (widget));
+
+      minimum_width  += 2 * style->xthickness;
+      natural_width  += 2 * style->xthickness;
     }
 
-  gtk_widget_grab_focus (priv->popup_window);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
-                                TRUE);
+  if (minimum_size)
+    *minimum_size = minimum_width;
 
-  if (!gtk_widget_has_focus (priv->tree_view))
-    gtk_widget_grab_focus (priv->tree_view);
+  if (natural_size)
+    *natural_size = natural_width;
+}
 
-  if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window),
-			     keyboard, pointer, time))
-    {
-      gtk_widget_hide (priv->popup_window);
-      return;
-    }
+static void
+gtk_combo_box_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum_size,
+                                    gint      *natural_size)
+{ 
+  gint min_width;
 
-  gtk_device_grab_add (priv->popup_window, pointer, TRUE);
-  priv->grab_pointer = pointer;
-  priv->grab_keyboard = keyboard;
+  /* 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_real_popup (GtkComboBox *combo_box)
+gtk_combo_box_get_preferred_width_for_height (GtkWidget *widget,
+                                              gint       avail_size,
+                                              gint      *minimum_size,
+                                              gint      *natural_size)
 {
-  GdkDevice *device;
+  /* 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);
+}
 
-  device = gtk_get_current_event_device ();
 
-  if (!device)
-    {
-      GdkDeviceManager *device_manager;
-      GdkDisplay *display;
-      GList *devices;
+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;
+  GtkStyle              *style;
+  gint                   focus_width, focus_pad;
+  gint                   min_height, nat_height;
+  gint                   size;
+  GtkWidget             *child;
 
-      display = gtk_widget_get_display (GTK_WIDGET (combo_box));
-      device_manager = gdk_display_get_device_manager (display);
+  gtk_widget_style_get (GTK_WIDGET (widget),
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			NULL);
 
-      /* 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);
-    }
+  size = avail_size;
 
-  gtk_combo_box_popup_for_device (combo_box, device);
-}
+  child = gtk_bin_get_child (GTK_BIN (widget));
 
-static gboolean
-gtk_combo_box_real_popdown (GtkComboBox *combo_box)
-{
-  if (combo_box->priv->popup_shown)
+  if (GTK_SHADOW_NONE != priv->shadow_type)
+    size -= gtk_widget_get_style (GTK_WIDGET (widget))->xthickness;
+
+  if (!priv->tree_view)
     {
-      gtk_combo_box_popdown (combo_box);
-      return TRUE;
-    }
+      /* menu mode */
+      if (priv->cell_view)
+        {
+          GtkStyle *button_style;
+	  /* calculate x/y padding and separator/arrow size */
+          gint sep_width, arrow_width, sep_height, arrow_height;
+          gint border_width, xthickness, ythickness, xpad, ypad;
 
-  return FALSE;
-}
+	  border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
+          button_style = gtk_widget_get_style (priv->button);
 
-/**
- * gtk_combo_box_popdown:
- * @combo_box: a #GtkComboBox
- * 
- * Hides the menu or dropdown list of @combo_box.
- *
- * This function is mostly intended for use by accessibility technologies;
- * applications should have little use for it.
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_popdown (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
+          xthickness = button_style->xthickness;
+          ythickness = button_style->ythickness;
 
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+          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);
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    {
-      gtk_menu_popdown (GTK_MENU (priv->popup_widget));
-      return;
-    }
+	  xpad = 2*(border_width + xthickness + focus_width + focus_pad);
+	  ypad = 2*(border_width + ythickness + focus_width + focus_pad);
 
-  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
-    return;
+	  size -= sep_width + arrow_width + xpad;
 
-  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);
+	  /* 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);
 
-  priv->grab_pointer = NULL;
-  priv->grab_keyboard = NULL;
-}
+	  arrow_height = MAX (arrow_height, sep_height);
+	  min_height = MAX (min_height, arrow_height);
+	  nat_height = MAX (nat_height, arrow_height);
 
-static void
-gtk_combo_box_update_requested_width (GtkComboBox *combo_box,
-				      GtkTreePath *path)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  gint                padding, min_width, nat_width;
+	  min_height += ypad;
+	  nat_height += ypad;
+        }
+      else
+        {
+	  /* there is a custom child widget inside (no priv->cell_view) */
+          gint but_width, but_height;
 
-  if (priv->cell_view)
-    gtk_widget_style_get (priv->cell_view,
-                          "focus-line-width", &padding,
-                          NULL);
-  else
-    padding = 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);
 
-  /* add some pixels for good measure */
-  padding += BONUS_PADDING;
+	  size -= but_width;
 
-  if (priv->cell_view)
-    gtk_cell_view_get_desired_width_of_row (GTK_CELL_VIEW (priv->cell_view),
-					    path, &min_width, &nat_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
-    min_width = nat_width = 0;
-
-  min_width += padding;
-  nat_width += padding;
-
-  if (min_width > priv->minimum_width || nat_width > priv->natural_width)
     {
-      priv->minimum_width = MAX (priv->minimum_width, min_width);
-      priv->natural_width = MAX (priv->natural_width, nat_width);
+      /* list mode */
+      gint but_width, but_height;
+      gint xpad = 0, ypad = 0;
 
-      if (priv->cell_view)
+      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)
 	{
-	  gtk_widget_set_size_request (priv->cell_view, min_width, -1);
-	  gtk_widget_queue_resize (priv->cell_view);
+          GtkStyle *cell_style;
+	  gint border_width;
+
+          border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
+          cell_style = gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame));
+
+	  xpad = 2 * (border_width + cell_style->xthickness);
+	  ypad = 2 * (border_width + cell_style->ythickness);
 	}
+
+      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;
+    }
+
+  if (GTK_SHADOW_NONE != priv->shadow_type)
+    {
+      style = gtk_widget_get_style (GTK_WIDGET (widget));
+
+      min_height += 2 * style->ythickness;
+      nat_height += 2 * style->ythickness;
     }
+
+  if (minimum_size)
+    *minimum_size = min_height;
+
+  if (natural_size)
+    *natural_size = nat_height;
 }
 
 #define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON 					\
@@ -2676,26 +3099,6 @@ gtk_combo_box_unset_model (GtkComboBox *combo_box)
 
   if (priv->model)
     {
-      g_signal_handler_disconnect (priv->model,
-				   priv->inserted_id);
-      g_signal_handler_disconnect (priv->model,
-				   priv->deleted_id);
-      g_signal_handler_disconnect (priv->model,
-				   priv->reordered_id);
-      g_signal_handler_disconnect (priv->model,
-				   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);
       priv->model = NULL;
     }
@@ -2710,29 +3113,6 @@ gtk_combo_box_unset_model (GtkComboBox *combo_box)
     gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), NULL);
 }
 
-static void
-gtk_combo_box_forall (GtkContainer *container,
-                      gboolean      include_internals,
-                      GtkCallback   callback,
-                      gpointer      callback_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (container);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkWidget *child;
-
-  if (include_internals)
-    {
-      if (priv->button)
-	(* callback) (priv->button, callback_data);
-      if (priv->cell_view_frame)
-	(* callback) (priv->cell_view_frame, callback_data);
-    }
-
-  child = gtk_bin_get_child (GTK_BIN (container));
-  if (child)
-    (* callback) (child, callback_data);
-}
-
 static void 
 gtk_combo_box_child_show (GtkWidget *widget,
                           GtkComboBox *combo_box)
@@ -2753,308 +3133,47 @@ gtk_combo_box_child_hide (GtkWidget *widget,
   g_object_notify (G_OBJECT (combo_box), "popup-shown");
 }
 
-static gboolean
-gtk_combo_box_draw (GtkWidget *widget,
-                    cairo_t   *cr)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-
-  if (priv->shadow_type != GTK_SHADOW_NONE)
-    {
-      gtk_paint_shadow (gtk_widget_get_style (widget),
-                        cr,
-                        GTK_STATE_NORMAL, priv->shadow_type,
-                        widget, "combobox",
-                        0, 0,
-                        gtk_widget_get_allocated_width (widget),
-                        gtk_widget_get_allocated_height (widget));
-    }
-
-  gtk_container_propagate_draw (GTK_CONTAINER (widget),
-				priv->button, cr);
-
-  if (priv->tree_view && priv->cell_view_frame)
-    {
-      gtk_container_propagate_draw (GTK_CONTAINER (widget),
-				    priv->cell_view_frame, cr);
-    }
-
-  gtk_container_propagate_draw (GTK_CONTAINER (widget),
-                                gtk_bin_get_child (GTK_BIN (widget)),
-                                cr);
-
-  return FALSE;
-}
-
-typedef struct {
-  GtkComboBox *combo;
-  GtkTreePath *path;
-  GtkTreeIter iter;
-  gboolean found;
-  gboolean set;
-  gboolean visible;
-} SearchData;
-
-static gboolean
-path_visible (GtkTreeView *view,
-	      GtkTreePath *path)
-{
-  GtkRBTree *tree;
-  GtkRBNode *node;
-  
-  /* Note that we rely on the fact that collapsed rows don't have nodes 
-   */
-  return _gtk_tree_view_find_node (view, path, &tree, &node);
-}
+/*
+ * menu style
+ */
 
-static gboolean
-tree_next_func (GtkTreeModel *model,
-		GtkTreePath  *path,
-		GtkTreeIter  *iter,
-		gpointer      data)
+static gboolean 
+gtk_combo_box_row_separator_func (GtkTreeModel      *model,
+				  GtkTreeIter       *iter,
+				  GtkComboBox       *combo)
 {
-  SearchData *search_data = (SearchData *)data;
+  GtkComboBoxPrivate *priv = combo->priv;
 
-  if (search_data->found) 
-    {
-      if (!tree_column_row_is_sensitive (search_data->combo, iter))
-	return FALSE;
-      
-      if (search_data->visible &&
-	  !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
-	return FALSE;
-
-      search_data->set = TRUE;
-      search_data->iter = *iter;
+  if (priv->row_separator_func)
+    return priv->row_separator_func (model, iter, priv->row_separator_data);
 
-      return TRUE;
-    }
- 
-  if (gtk_tree_path_compare (path, search_data->path) == 0)
-    search_data->found = TRUE;
-  
   return FALSE;
 }
 
-static gboolean
-tree_next (GtkComboBox  *combo,
-	   GtkTreeModel *model,
-	   GtkTreeIter  *iter,
-	   GtkTreeIter  *next,
-	   gboolean      visible)
-{
-  SearchData search_data;
-
-  search_data.combo = combo;
-  search_data.path = gtk_tree_model_get_path (model, iter);
-  search_data.visible = visible;
-  search_data.found = FALSE;
-  search_data.set = FALSE;
-
-  gtk_tree_model_foreach (model, tree_next_func, &search_data);
-  
-  *next = search_data.iter;
-
-  gtk_tree_path_free (search_data.path);
-
-  return search_data.set;
-}
-
-static gboolean
-tree_prev_func (GtkTreeModel *model,
-		GtkTreePath  *path,
-		GtkTreeIter  *iter,
-		gpointer      data)
-{
-  SearchData *search_data = (SearchData *)data;
-
-  if (gtk_tree_path_compare (path, search_data->path) == 0)
-    {
-      search_data->found = TRUE;
-      return TRUE;
-    }
-  
-  if (!tree_column_row_is_sensitive (search_data->combo, iter))
-    return FALSE;
-      
-  if (search_data->visible &&
-      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
-    return FALSE; 
-  
-  search_data->set = TRUE;
-  search_data->iter = *iter;
-  
-  return FALSE; 
-}
-
-static gboolean
-tree_prev (GtkComboBox  *combo,
-	   GtkTreeModel *model,
-	   GtkTreeIter  *iter,
-	   GtkTreeIter  *prev,
-	   gboolean      visible)
-{
-  SearchData search_data;
-
-  search_data.combo = combo;
-  search_data.path = gtk_tree_model_get_path (model, iter);
-  search_data.visible = visible;
-  search_data.found = FALSE;
-  search_data.set = FALSE;
-
-  gtk_tree_model_foreach (model, tree_prev_func, &search_data);
-  
-  *prev = search_data.iter;
-
-  gtk_tree_path_free (search_data.path);
-
-  return search_data.set;
-}
-
-static gboolean
-tree_last_func (GtkTreeModel *model,
-		GtkTreePath  *path,
-		GtkTreeIter  *iter,
-		gpointer      data)
-{
-  SearchData *search_data = (SearchData *)data;
-
-  if (!tree_column_row_is_sensitive (search_data->combo, iter))
-    return FALSE;
-      
-  /* Note that we rely on the fact that collapsed rows don't have nodes 
-   */
-  if (search_data->visible &&
-      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
-    return FALSE; 
-  
-  search_data->set = TRUE;
-  search_data->iter = *iter;
-  
-  return FALSE; 
-}
-
-static gboolean
-tree_last (GtkComboBox  *combo,
-	   GtkTreeModel *model,
-	   GtkTreeIter  *last,
-	   gboolean      visible)
-{
-  SearchData search_data;
-
-  search_data.combo = combo;
-  search_data.visible = visible;
-  search_data.set = FALSE;
-
-  gtk_tree_model_foreach (model, tree_last_func, &search_data);
-  
-  *last = search_data.iter;
-
-  return search_data.set;  
-}
-
-
-static gboolean
-tree_first_func (GtkTreeModel *model,
-		 GtkTreePath  *path,
-		 GtkTreeIter  *iter,
-		 gpointer      data)
-{
-  SearchData *search_data = (SearchData *)data;
-
-  if (!tree_column_row_is_sensitive (search_data->combo, iter))
-    return FALSE;
-  
-  if (search_data->visible &&
-      !path_visible (GTK_TREE_VIEW (search_data->combo->priv->tree_view), path))
-    return FALSE;
-  
-  search_data->set = TRUE;
-  search_data->iter = *iter;
-  
-  return TRUE;
-}
-
-static gboolean
-tree_first (GtkComboBox  *combo,
-	    GtkTreeModel *model,
-	    GtkTreeIter  *first,
-	    gboolean      visible)
-{
-  SearchData search_data;
-  
-  search_data.combo = combo;
-  search_data.visible = visible;
-  search_data.set = FALSE;
-
-  gtk_tree_model_foreach (model, tree_first_func, &search_data);
-  
-  *first = search_data.iter;
-
-  return search_data.set;  
-}
-
-static gboolean
-gtk_combo_box_scroll_event (GtkWidget          *widget,
-                            GdkEventScroll     *event)
+static gboolean 
+gtk_combo_box_header_func (GtkTreeModel      *model,
+			   GtkTreeIter       *iter,
+			   GtkComboBox       *combo)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-  gboolean found;
-  GtkTreeIter iter;
-  GtkTreeIter new_iter;
-
-  if (!gtk_combo_box_get_active_iter (combo_box, &iter))
-    return TRUE;
-  
-  if (event->direction == GDK_SCROLL_UP)
-    found = tree_prev (combo_box, combo_box->priv->model, 
-		       &iter, &new_iter, FALSE);
-  else
-    found = tree_next (combo_box, combo_box->priv->model, 
-		       &iter, &new_iter, FALSE);
-  
-  if (found)
-    gtk_combo_box_set_active_iter (combo_box, &new_iter);
-
+  /* 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;
 }
 
-/*
- * menu style
- */
-
 static void
-gtk_combo_box_sync_cells (GtkComboBox   *combo_box,
-			  GtkCellLayout *cell_layout)
+gtk_combo_box_menu_activate (GtkWidget   *menu,
+			     const gchar *path,
+			     GtkComboBox *combo_box)
 {
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GSList *k;
-
-  for (k = priv->cells; k; k = k->next)
-    {
-      GSList *j;
-      ComboCellInfo *info = (ComboCellInfo *)k->data;
-
-      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);
+  GtkTreeIter iter;
 
-      gtk_cell_layout_set_cell_data_func (cell_layout,
-                                          info->cell,
-                                          combo_cell_data_func, info, NULL);
+  if (gtk_tree_model_get_iter_from_string (combo_box->priv->model, &iter, path))
+    gtk_combo_box_set_active_iter (combo_box, &iter);
 
-      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));
-        }
-    }
+  g_object_set (combo_box,
+                "editing-canceled", FALSE,
+                NULL);
 }
 
 static void
@@ -3113,153 +3232,34 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
 		    combo_box);
 
   /* create our funky menu */
-  menu = gtk_menu_new ();
-  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);
-}
+  menu = gtk_tree_menu_new_with_area (priv->area);
+  gtk_tree_menu_set_model (GTK_TREE_MENU (menu), priv->model);
 
-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_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_get_preferred_size (cell_view, &req, NULL);
-  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
@@ -3275,139 +3275,24 @@ gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
                                         G_SIGNAL_MATCH_DATA,
                                         0, 0, NULL,
                                         gtk_combo_box_button_state_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,
@@ -3433,34 +3318,6 @@ gtk_combo_box_menu_button_press (GtkWidget      *widget,
 }
 
 static void
-gtk_combo_box_menu_item_activate (GtkWidget *item,
-                                  gpointer   user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkWidget *cell_view;
-  GtkTreePath *path;
-  GtkTreeIter iter;
-
-  cell_view = gtk_bin_get_child (GTK_BIN (item));
-
-  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);
-
-  g_object_set (combo_box,
-                "editing-canceled", FALSE,
-                NULL);
-}
-
-static void
 gtk_combo_box_update_sensitivity (GtkComboBox *combo_box)
 {
   GtkTreeIter iter;
@@ -3504,10 +3361,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);
 }
 
 static void
@@ -3527,10 +3380,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);
 }
 
 static void
@@ -3542,36 +3391,8 @@ gtk_combo_box_model_rows_reordered (GtkTreeModel    *model,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
 
+  /* XXX Is this needed ??? */
   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
-gtk_combo_box_model_row_changed (GtkTreeModel     *model,
-				 GtkTreePath      *path,
-				 GtkTreeIter      *iter,
-				 gpointer          user_data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkTreePath *active_path;
-
-  /* FIXME this belongs to GtkCellView */
-  if (gtk_tree_row_reference_valid (priv->active_row))
-    {
-      active_path = gtk_tree_row_reference_get_path (priv->active_row);
-      if (gtk_tree_path_compare (path, active_path) == 0 &&
-	  priv->cell_view)
-	gtk_widget_queue_resize (GTK_WIDGET (priv->cell_view));
-      gtk_tree_path_free (active_path);
-    }
-      
-  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
@@ -3615,302 +3436,6 @@ gtk_combo_box_model_row_expanded (GtkTreeModel     *model,
   gtk_combo_box_list_popup_resize (combo_box);
 }
 
-
-static GtkWidget *
-find_menu_by_path (GtkWidget   *menu,
-		   GtkTreePath *path,
-		   gboolean     skip_first)
-{
-  GList *i, *list;
-  GtkWidget *child;
-  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)
-    {
-      child = gtk_bin_get_child (i->data);
-      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 (child))
-	{
-	  if (skip)
-	    {
-	      skip = FALSE;
-	      continue;
-	    }
-
-	  mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (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_get_child (GTK_BIN (item)))))
-	    {
-	      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;
-  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 &&
-      gtk_widget_get_parent (item) == 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);
-    }
-
-  gtk_combo_box_update_requested_width (combo_box, path);
-}
-
 /*
  * list style
  */
@@ -3981,21 +3506,16 @@ 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 ();
   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;
@@ -4408,472 +3928,221 @@ gtk_combo_box_list_select_func (GtkTreeSelection *selection,
   return sensitive;
 }
 
-static void
-gtk_combo_box_list_row_changed (GtkTreeModel *model,
-                                GtkTreePath  *path,
-                                GtkTreeIter  *iter,
-                                gpointer      data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
-
-  gtk_combo_box_update_requested_width (combo_box, path);
-}
 
 /*
- * GtkCellLayout implementation
+ * GtkCellEditable implementation
  */
 
 static void
-pack_start_recurse (GtkWidget       *menu,
-		    GtkCellRenderer *cell,
-		    gboolean         expand)
+gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface)
 {
-  GList *i, *list;
-  GtkWidget *child;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (child),
-                                    cell, expand);
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-	pack_start_recurse (submenu, cell, expand);
-    }
-
-  g_list_free (list);
+  iface->start_editing = gtk_combo_box_start_editing;
 }
 
-static void
-gtk_combo_box_cell_layout_pack_start (GtkCellLayout   *layout,
-                                      GtkCellRenderer *cell,
-                                      gboolean         expand)
+static gboolean
+gtk_cell_editable_key_press (GtkWidget   *widget,
+			     GdkEventKey *event,
+			     gpointer     data)
 {
-  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);
+  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
 
-  if (priv->cell_view)
+  if (event->keyval == GDK_KEY_Escape)
     {
-      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view),
-				  cell, expand);
-
+      g_object_set (combo_box,
+                    "editing-canceled", TRUE,
+                    NULL);
+      gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
+      gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
+      
+      return TRUE;
     }
-
-  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);
-}
-
-static void
-pack_end_recurse (GtkWidget       *menu,
-		  GtkCellRenderer *cell,
-		  gboolean         expand)
-{
-  GList *i, *list;
-  GtkWidget *child;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
+  else if (event->keyval == GDK_KEY_Return ||
+           event->keyval == GDK_KEY_ISO_Enter ||
+           event->keyval == GDK_KEY_KP_Enter)
     {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (child),
-                                  cell, expand);
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-	pack_end_recurse (submenu, cell, expand);
+      gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
+      gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
+      
+      return TRUE;
     }
 
-  g_list_free (list);
-}
-
-static void
-gtk_combo_box_cell_layout_pack_end (GtkCellLayout   *layout,
-                                    GtkCellRenderer *cell,
-                                    gboolean         expand)
-{
-  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);
-
-  if (priv->cell_view)
-    gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (priv->cell_view),
-                              cell, expand);
-
-  if (priv->column)
-    gtk_tree_view_column_pack_end (priv->column, cell, expand);
-
-  if (GTK_IS_MENU (priv->popup_widget))
-    pack_end_recurse (priv->popup_widget, cell, expand);
+  return FALSE;
 }
 
-static GList *
-gtk_combo_box_cell_layout_get_cells (GtkCellLayout *layout)
+static gboolean
+popdown_idle (gpointer data)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (layout);
-  GSList *list;
-  GList *retval = NULL;
+  GtkComboBox *combo_box;
 
-  for (list = combo_box->priv->cells; list; list = list->next)
-    {
-      ComboCellInfo *info = (ComboCellInfo *)list->data;
+  combo_box = GTK_COMBO_BOX (data);
+  
+  gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
+  gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
 
-      retval = g_list_prepend (retval, info->cell);
-    }
+  g_object_unref (combo_box);
 
-  return g_list_reverse (retval);
+  return FALSE;
 }
 
 static void
-clear_recurse (GtkWidget *menu)
+popdown_handler (GtkWidget *widget,
+		 gpointer   data)
 {
-  GList *i, *list;
-  GtkWidget *child;
-  GtkWidget *submenu;    
-  
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_clear (GTK_CELL_LAYOUT (child));
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-	clear_recurse (submenu);
-    }
-
-  g_list_free (list);
+  gdk_threads_add_idle (popdown_idle, g_object_ref (data));
 }
 
-static void
-gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
+static gboolean
+popup_idle (gpointer data)
 {
-  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));
+  GtkComboBox *combo_box;
 
-  if (priv->column)
-    gtk_tree_view_column_clear (priv->column);
+  combo_box = GTK_COMBO_BOX (data);
 
-  for (i = priv->cells; i; i = i->next)
-    {
-      ComboCellInfo *info = (ComboCellInfo *)i->data;
+  if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
+      combo_box->priv->cell_view)
+    g_signal_connect_object (combo_box->priv->popup_widget,
+			     "unmap", G_CALLBACK (popdown_handler),
+			     combo_box, 0);
+  
+  /* we unset this if a menu item is activated */
+  g_object_set (combo_box,
+                "editing-canceled", TRUE,
+                NULL);
+  gtk_combo_box_popup (combo_box);
 
-      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;
+  combo_box->priv->popup_idle_id = 0;
+  combo_box->priv->activate_button = 0;
+  combo_box->priv->activate_time = 0;
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    clear_recurse (priv->popup_widget);
+  return FALSE;
 }
 
 static void
-add_attribute_recurse (GtkWidget       *menu,
-		       GtkCellRenderer *cell,
-		       const gchar     *attribute,
-		       gint             column)
+gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
+			     GdkEvent        *event)
 {
-  GList *i, *list;
+  GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable);
   GtkWidget *child;
-  GtkWidget *submenu;    
-
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (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));
+  combo_box->priv->is_cell_renderer = TRUE;
 
   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_get_child (GTK_BIN (i->data));
-      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;
+      g_signal_connect_object (combo_box->priv->button, "key-press-event",
+			       G_CALLBACK (gtk_cell_editable_key_press), 
+			       cell_editable, 0);  
 
-      info->destroy = NULL;
-      d (info->func_data);
+      gtk_widget_grab_focus (combo_box->priv->button);
     }
+  else
+    {
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
 
-  info->func = func;
-  info->func_data = func_data;
-  info->destroy = destroy;
+      g_signal_connect_object (child, "key-press-event",
+			       G_CALLBACK (gtk_cell_editable_key_press), 
+			       cell_editable, 0);  
 
-  if (priv->cell_view)
-    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->cell_view), cell, func, func_data, NULL);
+      gtk_widget_grab_focus (child);
+      gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
+    }
 
-  if (priv->column)
-    gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->column), cell, func, func_data, NULL);
+  /* we do the immediate popup only for the optionmenu-like 
+   * appearance 
+   */  
+  if (combo_box->priv->is_cell_renderer && 
+      combo_box->priv->cell_view && !combo_box->priv->tree_view)
+    {
+      if (event && event->type == GDK_BUTTON_PRESS)
+        {
+          GdkEventButton *event_button = (GdkEventButton *)event;
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    set_cell_data_func_recurse (priv->popup_widget, cell, info);
+          combo_box->priv->activate_button = event_button->button;
+          combo_box->priv->activate_time = event_button->time;
+        }
 
-  gtk_widget_queue_resize (GTK_WIDGET (combo_box));
+      combo_box->priv->popup_idle_id = 
+          gdk_threads_add_idle (popup_idle, combo_box);
+    }
 }
 
-static void 
-clear_attributes_recurse (GtkWidget       *menu,
-			  GtkCellRenderer *cell)
-{
-  GList *i, *list;
-  GtkWidget *submenu;
-  GtkWidget *child;
 
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (child), cell);
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-	clear_attributes_recurse (submenu, cell);
-    }
+/*
+ * GtkCellLayout implementation
+ */
 
-  g_list_free (list);
+static void
+gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
+{
+  iface->get_area = gtk_combo_box_cell_layout_get_area;
 }
 
-static void
-gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout   *layout,
-                                            GtkCellRenderer *cell)
+static GtkCellArea *
+gtk_combo_box_cell_layout_get_area (GtkCellLayout *layout)
 {
   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);
+  return priv->area;
+}
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    clear_attributes_recurse (priv->popup_widget, cell);
+/*
+ * GtkBuildable implementation
+ */
 
-  gtk_widget_queue_resize (GTK_WIDGET (combo_box));
+static void
+gtk_combo_box_buildable_init (GtkBuildableIface *iface)
+{
+  parent_buildable_iface = g_type_interface_peek_parent (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 
-reorder_recurse (GtkWidget             *menu,
-		 GtkCellRenderer       *cell,
-		 gint                   position)
+static gboolean
+gtk_combo_box_buildable_custom_tag_start (GtkBuildable  *buildable,
+					  GtkBuilder    *builder,
+					  GObject       *child,
+					  const gchar   *tagname,
+					  GMarkupParser *parser,
+					  gpointer      *data)
 {
-  GList *i, *list;
-  GtkWidget *child;
-  GtkWidget *submenu;    
-
-  list = gtk_container_get_children (GTK_CONTAINER (menu));
-  for (i = list; i; i = i->next)
-    {
-      child = gtk_bin_get_child (GTK_BIN (i->data));
-      if (GTK_IS_CELL_LAYOUT (child))
-        gtk_cell_layout_reorder (GTK_CELL_LAYOUT (child),
-                                 cell, position);
-
-      submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
-      if (submenu != NULL)
-	reorder_recurse (submenu, cell, position);
-    }
+  if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
+						tagname, parser, data))
+    return TRUE;
 
-  g_list_free (list);
+  return _gtk_cell_layout_buildable_custom_tag_start (buildable, builder, child,
+						      tagname, parser, data);
 }
 
 static void
-gtk_combo_box_cell_layout_reorder (GtkCellLayout   *layout,
-                                   GtkCellRenderer *cell,
-                                   gint             position)
+gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
+					GtkBuilder   *builder,
+					GObject      *child,
+					const gchar  *tagname,
+					gpointer     *data)
 {
-  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 (strcmp (tagname, "attributes") == 0 || strcmp (tagname, "cell-packing"))
+    _gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname,
+					       data);
+  else
+    parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname,
+					    data);
+}
 
-  if (priv->column)
-    gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->column),
-                             cell, position);
+static GObject *
+gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
+					    GtkBuilder   *builder,
+					    const gchar  *childname)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (buildable);
 
-  if (GTK_IS_MENU (priv->popup_widget))
-    reorder_recurse (priv->popup_widget, cell, position);
+  if (combo_box->priv->has_entry && strcmp (childname, "entry") == 0)
+    return G_OBJECT (gtk_bin_get_child (GTK_BIN (buildable)));
 
-  gtk_widget_queue_draw (GTK_WIDGET (combo_box));
+  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
 }
 
 /*
@@ -4995,7 +4264,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");
     }
@@ -5047,8 +4318,9 @@ 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");
     }
@@ -5100,9 +4372,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");
     }
 }
@@ -5344,23 +4617,6 @@ gtk_combo_box_set_model (GtkComboBox  *combo_box,
 
   combo_box->priv->model = model;
   g_object_ref (combo_box->priv->model);
-
-  combo_box->priv->inserted_id =
-    g_signal_connect (combo_box->priv->model, "row-inserted",
-		      G_CALLBACK (gtk_combo_box_model_row_inserted),
-		      combo_box);
-  combo_box->priv->deleted_id =
-    g_signal_connect (combo_box->priv->model, "row-deleted",
-		      G_CALLBACK (gtk_combo_box_model_row_deleted),
-		      combo_box);
-  combo_box->priv->reordered_id =
-    g_signal_connect (combo_box->priv->model, "rows-reordered",
-		      G_CALLBACK (gtk_combo_box_model_rows_reordered),
-		      combo_box);
-  combo_box->priv->changed_id =
-    g_signal_connect (combo_box->priv->model, "row-changed",
-		      G_CALLBACK (gtk_combo_box_model_row_changed),
-		      combo_box);
       
   if (combo_box->priv->tree_view)
     {
@@ -5369,12 +4625,13 @@ 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);
+      /* XXX Resize ?? */
     }
 
   if (combo_box->priv->cell_view)
@@ -5389,8 +4646,6 @@ gtk_combo_box_set_model (GtkComboBox  *combo_box,
     }
 
 out:
-  gtk_combo_box_update_sensitivity (combo_box);
-
   g_object_notify (G_OBJECT (combo_box), "model");
 }
 
@@ -5414,151 +4669,6 @@ gtk_combo_box_get_model (GtkComboBox *combo_box)
 }
 
 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;
-
-    default:
-      return;
-    }
-
-  if (found && active_iter)
-    {
-      GtkTreePath *old_path;
-      GtkTreePath *new_path;
-
-      old_path = gtk_tree_model_get_path (combo_box->priv->model, &iter);
-      new_path = gtk_tree_model_get_path (combo_box->priv->model, &new_iter);
-
-      if (gtk_tree_path_compare (old_path, new_path) == 0)
-        found = FALSE;
-
-      gtk_tree_path_free (old_path);
-      gtk_tree_path_free (new_path);
-    }
-
-  if (found)
-    {
-      gtk_combo_box_set_active_iter (combo_box, &new_iter);
-    }
-  else
-    {
-      gtk_widget_error_bell (GTK_WIDGET (combo_box));
-    }
-}
-
-static gboolean
-gtk_combo_box_mnemonic_activate (GtkWidget *widget,
-				 gboolean   group_cycling)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-
-  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;
-}
-
-static void
-gtk_combo_box_grab_focus (GtkWidget *widget)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-
-  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 (GtkWidget *widget)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-
-  if (combo_box->priv->popup_idle_id > 0)
-    {
-      g_source_remove (combo_box->priv->popup_idle_id);
-      combo_box->priv->popup_idle_id = 0;
-    }
-
-  gtk_combo_box_popdown (combo_box);
-
-  if (combo_box->priv->row_separator_destroy)
-    combo_box->priv->row_separator_destroy (combo_box->priv->row_separator_data);
-
-  combo_box->priv->row_separator_func = NULL;
-  combo_box->priv->row_separator_data = NULL;
-  combo_box->priv->row_separator_destroy = NULL;
-
-  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)
 {
@@ -5609,225 +4719,6 @@ gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
     }
 }
 
-static GObject *
-gtk_combo_box_constructor (GType                  type,
-			   guint                  n_construct_properties,
-			   GObjectConstructParam *construct_properties)
-{
-  GObject            *object;
-  GtkComboBox        *combo_box;
-  GtkComboBoxPrivate *priv;
-
-  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->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)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
-
-  if (GTK_IS_MENU (combo_box->priv->popup_widget))
-    {
-      gtk_combo_box_menu_destroy (combo_box);
-      gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
-      combo_box->priv->popup_widget = NULL;
-    }
-
-  G_OBJECT_CLASS (gtk_combo_box_parent_class)->dispose (object);
-}
-
-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;
-
-      if (info->destroy)
-	info->destroy (info->func_data);
-
-      while (list && list->next)
-	{
-	  g_free (list->data);
-	  list = list->next->next;
-	}
-      g_slist_free (info->attributes);
-
-      g_object_unref (info->cell);
-      g_slice_free (ComboCellInfo, info);
-    }
-   g_slist_free (combo_box->priv->cells);
-
-   g_free (combo_box->priv->tearoff_title);
-
-   G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
-}
-
-
-static gboolean
-gtk_cell_editable_key_press (GtkWidget   *widget,
-			     GdkEventKey *event,
-			     gpointer     data)
-{
-  GtkComboBox *combo_box = GTK_COMBO_BOX (data);
-
-  if (event->keyval == GDK_KEY_Escape)
-    {
-      g_object_set (combo_box,
-                    "editing-canceled", TRUE,
-                    NULL);
-      gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
-      gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
-      
-      return TRUE;
-    }
-  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));
-      
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
-static gboolean
-popdown_idle (gpointer data)
-{
-  GtkComboBox *combo_box;
-
-  combo_box = GTK_COMBO_BOX (data);
-  
-  gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
-  gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
-
-  g_object_unref (combo_box);
-
-  return FALSE;
-}
-
-static void
-popdown_handler (GtkWidget *widget,
-		 gpointer   data)
-{
-  gdk_threads_add_idle (popdown_idle, g_object_ref (data));
-}
-
-static gboolean
-popup_idle (gpointer data)
-{
-  GtkComboBox *combo_box;
-
-  combo_box = GTK_COMBO_BOX (data);
-
-  if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
-      combo_box->priv->cell_view)
-    g_signal_connect_object (combo_box->priv->popup_widget,
-			     "unmap", G_CALLBACK (popdown_handler),
-			     combo_box, 0);
-  
-  /* we unset this if a menu item is activated */
-  g_object_set (combo_box,
-                "editing-canceled", TRUE,
-                NULL);
-  gtk_combo_box_popup (combo_box);
-
-  combo_box->priv->popup_idle_id = 0;
-  combo_box->priv->activate_button = 0;
-  combo_box->priv->activate_time = 0;
-
-  return FALSE;
-}
-
-static void
-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;
-
-  if (combo_box->priv->cell_view)
-    {
-      g_signal_connect_object (combo_box->priv->button, "key-press-event",
-			       G_CALLBACK (gtk_cell_editable_key_press), 
-			       cell_editable, 0);  
-
-      gtk_widget_grab_focus (combo_box->priv->button);
-    }
-  else
-    {
-      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 (child);
-      gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
-    }
-
-  /* we do the immediate popup only for the optionmenu-like 
-   * appearance 
-   */  
-  if (combo_box->priv->is_cell_renderer && 
-      combo_box->priv->cell_view && !combo_box->priv->tree_view)
-    {
-      if (event && event->type == GDK_BUTTON_PRESS)
-        {
-          GdkEventButton *event_button = (GdkEventButton *)event;
-
-          combo_box->priv->activate_button = event_button->button;
-          combo_box->priv->activate_time = event_button->time;
-        }
-
-      combo_box->priv->popup_idle_id = 
-          gdk_threads_add_idle (popup_idle, combo_box);
-    }
-}
-
-
 /**
  * gtk_combo_box_get_add_tearoffs:
  * @combo_box: a #GtkComboBox
@@ -5865,8 +4756,15 @@ gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
   if (combo_box->priv->add_tearoffs != add_tearoffs)
     {
       combo_box->priv->add_tearoffs = add_tearoffs;
-      gtk_combo_box_check_appearance (combo_box);
-      gtk_combo_box_relayout (combo_box);
+
+      if (GTK_IS_TREE_MENU (combo_box->priv->popup_widget))
+	{
+	  /* menu mode */
+	  gtk_tree_menu_set_tearoff (GTK_TREE_MENU (combo_box->priv->popup_widget), 
+				     combo_box->priv->add_tearoffs);
+	  /* XXX Resize ?? */
+	}
+
       g_object_notify (G_OBJECT (combo_box), "add-tearoffs");
     }
 }
@@ -6055,10 +4953,16 @@ gtk_combo_box_set_row_separator_func (GtkComboBox                 *combo_box,
   combo_box->priv->row_separator_destroy = destroy;
 
   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));
 }
@@ -6242,406 +5146,166 @@ gtk_combo_box_get_focus_on_click (GtkComboBox *combo_box)
 }
 
 
-static gboolean
-gtk_combo_box_buildable_custom_tag_start (GtkBuildable  *buildable,
-					  GtkBuilder    *builder,
-					  GObject       *child,
-					  const gchar   *tagname,
-					  GMarkupParser *parser,
-					  gpointer      *data)
+/**
+ * gtk_combo_box_popup:
+ * @combo_box: a #GtkComboBox
+ * 
+ * Pops up the menu or dropdown list of @combo_box. 
+ *
+ * This function is mostly intended for use by accessibility technologies;
+ * applications should have little use for it.
+ *
+ * Since: 2.4
+ */
+void
+gtk_combo_box_popup (GtkComboBox *combo_box)
 {
-  if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
-						tagname, parser, data))
-    return TRUE;
-
-  return _gtk_cell_layout_buildable_custom_tag_start (buildable, builder, child,
-						      tagname, parser, data);
-}
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
 
-static void
-gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
-					GtkBuilder   *builder,
-					GObject      *child,
-					const gchar  *tagname,
-					gpointer     *data)
-{
-  if (strcmp (tagname, "attributes") == 0)
-    _gtk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname,
-					       data);
-  else
-    parent_buildable_iface->custom_tag_end (buildable, builder, child, tagname,
-					    data);
+  g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
 }
 
-static GObject *
-gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
-					    GtkBuilder   *builder,
-					    const gchar  *childname)
+/**
+ * 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)
 {
-  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)));
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  gint x, y, width, height;
+  GtkTreePath *path = NULL, *ppath;
+  GtkWidget *toplevel;
+  GdkDevice *keyboard, *pointer;
+  guint32 time;
 
-  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
-}
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+  g_return_if_fail (GDK_IS_DEVICE (device));
 
-static void
-gtk_combo_box_remeasure (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkTreeIter iter;
-  GtkTreePath *path;
+  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
+    return;
 
-  if (!priv->model ||
-      !gtk_tree_model_get_iter_first (priv->model, &iter))
+  if (gtk_widget_get_mapped (priv->popup_widget))
     return;
 
-  priv->minimum_width = priv->natural_width = 0;
+  if (priv->grab_pointer && priv->grab_keyboard)
+    return;
 
-  path = gtk_tree_path_new_from_indices (0, -1);
+  time = gtk_get_current_event_time ();
 
-  do
+  if (device->source == GDK_SOURCE_KEYBOARD)
     {
-      gint row_min = 0, row_nat = 0;
-
-      if (priv->cell_view)
-	gtk_cell_view_get_desired_width_of_row (GTK_CELL_VIEW (priv->cell_view), 
-						path, &row_min, &row_nat);
-
-      priv->minimum_width = MAX (priv->minimum_width, row_min);
-      priv->natural_width = MAX (priv->natural_width, row_nat);
-
-      gtk_tree_path_next (path);
+      keyboard = device;
+      pointer = gdk_device_get_associated_device (device);
     }
-  while (gtk_tree_model_iter_next (priv->model, &iter));
-
-  gtk_tree_path_free (path);
-}
-
-
-static void
-gtk_combo_box_measure_height_for_width (GtkComboBox *combo_box,
-					gint         avail_width, 
-					gint        *min_height, 
-					gint        *nat_height)
-{
-  GtkWidget             *child;
-  GtkComboBoxPrivate    *priv = combo_box->priv;
-  GtkTreeIter            iter;
-  GtkTreePath           *path;
-  gint                   child_min, child_nat;
-
-  child = gtk_bin_get_child (GTK_BIN (combo_box));
-
-  gtk_widget_get_preferred_height_for_width (child, avail_width,
-                                             &child_min, &child_nat);
-
-  if (!priv->model ||
-      !gtk_tree_model_get_iter_first (priv->model, &iter))
-    goto out;
-
-  path = gtk_tree_path_new_from_indices (0, -1);
-
-  do
+  else
     {
-      gint row_min = 0, row_nat = 0;
-
-      if (priv->cell_view)
-	gtk_cell_view_get_desired_height_for_width_of_row (GTK_CELL_VIEW (priv->cell_view), 
-							   path, avail_width, 
-							   &row_min, &row_nat);
-
-      child_min = MAX (child_min, row_min);
-      child_nat = MAX (child_nat, row_nat);
-
-      gtk_tree_path_next (path);
+      pointer = device;
+      keyboard = gdk_device_get_associated_device (device);
     }
-  while (gtk_tree_model_iter_next (priv->model, &iter));
-
-  gtk_tree_path_free (path);
-
- out:
-
-  if (min_height)
-    *min_height = child_min;
-  if (nat_height)
-    *nat_height = child_nat;
-}
-
-
-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;
-  GtkStyle              *style;
-  gint                   focus_width, focus_pad;
-  gint                   font_size, arrow_size;
-  PangoContext          *context;
-  PangoFontMetrics      *metrics;
-  PangoFontDescription  *font_desc;
-  GtkWidget             *child;
-  gint                   minimum_width, natural_width;
-  gint                   child_min, child_nat;
-
-  child = gtk_bin_get_child (GTK_BIN (widget));
- 
-  /* common */
-  gtk_widget_get_preferred_width (child, &child_min, &child_nat);
-  gtk_combo_box_remeasure (combo_box);
-
-  child_min  = MAX (child_min,  priv->minimum_width);
-  child_nat  = MAX (child_nat,  priv->natural_width);
-
-  gtk_widget_style_get (GTK_WIDGET (widget),
-			"focus-line-width", &focus_width,
-			"focus-padding", &focus_pad,
-			"arrow-size", &arrow_size,
-			NULL);
 
-  font_desc = gtk_widget_get_style (child)->font_desc;
-  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);
-
-  arrow_size = MAX (arrow_size, font_size);
-
-  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
-
-  if (!priv->tree_view)
+  if (GTK_IS_MENU (priv->popup_widget))
     {
-      /* menu mode */
-	  
-      if (priv->cell_view)
-        {
-          gint sep_width, arrow_width;
-          gint border_width, xthickness, xpad;
-
-	  border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
-          xthickness   = gtk_widget_get_style (priv->button)->xthickness;
-
-          gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
-          gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
-
-	  xpad = 2*(border_width + xthickness + focus_width + focus_pad);
-
-          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;
-        }
+      gtk_combo_box_menu_popup (combo_box, 
+                                priv->activate_button,
+                                priv->activate_time);
+      return;
     }
-  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 = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
-	      gint xpad         = 2 * (border_width + gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame))->xthickness);
 
-	      minimum_width  += xpad;
-	      natural_width  += xpad;
-	    }
-        }
+  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
+  if (GTK_IS_WINDOW (toplevel))
+    gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), 
+				 GTK_WINDOW (priv->popup_window));
 
-      /* the button */
-      gtk_widget_get_preferred_width (priv->button, 
-                                      &button_width, &button_nat_width);
+  gtk_widget_show_all (priv->scrolled_window);
+  gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
+  
+  gtk_widget_set_size_request (priv->popup_window, width, height);  
+  gtk_window_move (GTK_WINDOW (priv->popup_window), x, y);
 
-      minimum_width += button_width;
-      natural_width += button_nat_width;
+  if (gtk_tree_row_reference_valid (priv->active_row))
+    {
+      path = gtk_tree_row_reference_get_path (priv->active_row);
+      ppath = gtk_tree_path_copy (path);
+      if (gtk_tree_path_up (ppath))
+	gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->tree_view),
+				      ppath);
+      gtk_tree_path_free (ppath);
     }
+  gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (priv->tree_view), 
+				  TRUE);
+  
+  /* popup */
+  gtk_widget_show (priv->popup_window);
 
-  if (GTK_SHADOW_NONE != priv->shadow_type)
+  if (path)
     {
-      style = gtk_widget_get_style (GTK_WIDGET (widget));
-
-      minimum_width  += 2 * style->xthickness;
-      natural_width  += 2 * style->xthickness;
+      gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->tree_view),
+				path, NULL, FALSE);
+      gtk_tree_path_free (path);
     }
 
-  if (minimum_size)
-    *minimum_size = minimum_width;
-
-  if (natural_size)
-    *natural_size = natural_width;
-}
+  gtk_widget_grab_focus (priv->popup_window);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
+                                TRUE);
 
-static void
-gtk_combo_box_get_preferred_height (GtkWidget *widget,
-                                    gint      *minimum_size,
-                                    gint      *natural_size)
-{ 
-  gint min_width;
+  if (!gtk_widget_has_focus (priv->tree_view))
+    gtk_widget_grab_focus (priv->tree_view);
 
-  /* 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);
-}
+  if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window),
+			     keyboard, pointer, time))
+    {
+      gtk_widget_hide (priv->popup_window);
+      return;
+    }
 
-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);
+  gtk_device_grab_add (priv->popup_window, pointer, TRUE);
+  priv->grab_pointer = pointer;
+  priv->grab_keyboard = keyboard;
 }
 
-
-static void
-gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
-                                              gint       avail_size,
-                                              gint      *minimum_size,
-                                              gint      *natural_size)
+/**
+ * gtk_combo_box_popdown:
+ * @combo_box: a #GtkComboBox
+ * 
+ * Hides the menu or dropdown list of @combo_box.
+ *
+ * This function is mostly intended for use by accessibility technologies;
+ * applications should have little use for it.
+ *
+ * Since: 2.4
+ */
+void
+gtk_combo_box_popdown (GtkComboBox *combo_box)
 {
-  GtkComboBox           *combo_box = GTK_COMBO_BOX (widget);
-  GtkComboBoxPrivate    *priv = combo_box->priv;
-  GtkStyle              *style;
-  gint                   focus_width, focus_pad;
-  gint                   min_height, nat_height;
-  gint                   size;
-
-  gtk_widget_style_get (GTK_WIDGET (widget),
-			"focus-line-width", &focus_width,
-			"focus-padding", &focus_pad,
-			NULL);
-
-  size = avail_size;
-
-  if (GTK_SHADOW_NONE != priv->shadow_type)
-    size -= gtk_widget_get_style (GTK_WIDGET (widget))->xthickness;
-
-  if (!priv->tree_view)
-    {
-      /* menu mode */
-      if (priv->cell_view)
-        {
-          GtkStyle *button_style;
-	  /* calculate x/y padding and separator/arrow size */
-          gint sep_width, arrow_width, sep_height, arrow_height;
-          gint border_width, xthickness, ythickness, xpad, ypad;
-
-	  border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
-          button_style = gtk_widget_get_style (priv->button);
-
-          xthickness = button_style->xthickness;
-          ythickness = button_style->ythickness;
-
-          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 + xthickness + focus_width + focus_pad);
-	  ypad = 2*(border_width + ythickness + focus_width + focus_pad);
-
-	  size -= sep_width + arrow_width + xpad;
-
-	  gtk_combo_box_measure_height_for_width (combo_box, 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);
+  GtkComboBoxPrivate *priv = combo_box->priv;
 
-	  size -= but_width;
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
 
-	  gtk_combo_box_measure_height_for_width (combo_box, size, &min_height, &nat_height);
-	  
-	  min_height = MAX (min_height, but_height);
-	  nat_height = MAX (nat_height, but_height);
-        }
-    }
-  else
+  if (GTK_IS_MENU (priv->popup_widget))
     {
-      /* 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)
-	{
-          GtkStyle *cell_style;
-	  gint border_width;
-
-          border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
-          cell_style = gtk_widget_get_style (GTK_WIDGET (priv->cell_view_frame));
-
-	  xpad = 2 * (border_width + cell_style->xthickness);
-	  ypad = 2 * (border_width + cell_style->ythickness);
-	}
-
-      size -= but_width;
-      size -= 2 * focus_width;
-      size -= xpad;
-
-      gtk_combo_box_measure_height_for_width (combo_box, 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;
+      gtk_menu_popdown (GTK_MENU (priv->popup_widget));
+      return;
     }
 
-  if (GTK_SHADOW_NONE != priv->shadow_type)
-    {
-      style = gtk_widget_get_style (GTK_WIDGET (widget));
-
-      min_height += 2 * style->ythickness;
-      nat_height += 2 * style->ythickness;
-    }
+  if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
+    return;
 
-  if (minimum_size)
-    *minimum_size = min_height;
+  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);
 
-  if (natural_size)
-    *natural_size = nat_height;
+  priv->grab_pointer = NULL;
+  priv->grab_keyboard = NULL;
 }
 
 /**
diff --git a/gtk/gtktreemenu.c b/gtk/gtktreemenu.c
index 7212087..db970c9 100644
--- a/gtk/gtktreemenu.c
+++ b/gtk/gtktreemenu.c
@@ -115,6 +115,8 @@ static void       item_activated_cb                           (GtkMenuItem
 static void       submenu_activated_cb                        (GtkTreeMenu          *submenu,
 							       const gchar          *path,
 							       GtkTreeMenu          *menu);
+static void       gtk_tree_menu_set_model_internal            (GtkTreeMenu          *menu,
+							       GtkTreeModel         *model);
 
 
 
@@ -828,7 +830,7 @@ row_changed_cb (GtkTreeModel         *model,
       GtkTreePath *root_path =
 	gtk_tree_row_reference_get_path (priv->root);
       
-      if (gtk_tree_path_compare (root_path, path) == 0)
+      if (root_path && gtk_tree_path_compare (root_path, path) == 0)
 	{
 	  if (priv->header_func)
 	    has_header = 
@@ -853,9 +855,9 @@ row_changed_cb (GtkTreeModel         *model,
 
 	      priv->menu_with_header = FALSE;
 	    }
+
+	  gtk_tree_path_free (root_path);
 	}
-      
-      gtk_tree_path_free (root_path);
     }
   
   if (item)
@@ -940,7 +942,7 @@ area_apply_attributes_cb (GtkCellArea          *area,
 
       /* If there is no submenu, go ahead and update item sensitivity,
        * items with submenus are always sensitive */
-      if (!gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)))
+      if (item && !gtk_menu_item_get_submenu (GTK_MENU_ITEM (item)))
 	{
 	  sensitive = area_is_sensitive (priv->area);
 
@@ -1100,6 +1102,7 @@ gtk_tree_menu_create_item (GtkTreeMenu *menu,
   if (is_separator)
     {
       item = gtk_separator_menu_item_new ();
+      gtk_widget_show (item);
 
       g_object_set_qdata_full (G_OBJECT (item),
 			       tree_menu_path_quark,
@@ -1138,9 +1141,8 @@ gtk_tree_menu_create_item (GtkTreeMenu *menu,
 					 priv->header_data,
 					 priv->header_destroy);
 
-	  gtk_tree_menu_set_model (GTK_TREE_MENU (submenu), priv->model);
+	  gtk_tree_menu_set_model_internal (GTK_TREE_MENU (submenu), priv->model);
 	  gtk_tree_menu_set_root (GTK_TREE_MENU (submenu), path);
-
 	  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
 
 	  g_signal_connect (submenu, "menu-activate", 
@@ -1274,44 +1276,15 @@ submenu_activated_cb (GtkTreeMenu          *submenu,
   g_signal_emit (menu, tree_menu_signals[SIGNAL_MENU_ACTIVATE], 0, path);
 }
 
-/****************************************************************
- *                            API                               *
- ****************************************************************/
-GtkWidget *
-gtk_tree_menu_new (void)
-{
-  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, NULL);
-}
-
-GtkWidget *
-gtk_tree_menu_new_with_area (GtkCellArea    *area)
-{
-  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, 
-				    "cell-area", area, 
-				    NULL);
-}
-
-GtkWidget *
-gtk_tree_menu_new_full (GtkCellArea         *area,
-			GtkTreeModel        *model,
-			GtkTreePath         *root)
-{
-  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, 
-				    "cell-area", area, 
-				    "model", model,
-				    "root", root,
-				    NULL);
-}
-
-void
-gtk_tree_menu_set_model (GtkTreeMenu  *menu,
-			 GtkTreeModel *model)
+/* Sets the model without rebuilding the menu, prevents
+ * infinite recursion while building submenus (we wait
+ * until the root is set and then build the menu) */
+static void
+gtk_tree_menu_set_model_internal (GtkTreeMenu  *menu,
+				  GtkTreeModel *model)
 {
   GtkTreeMenuPrivate *priv;
 
-  g_return_if_fail (GTK_IS_TREE_MENU (menu));
-  g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
-
   priv = menu->priv;
 
   if (priv->model != model)
@@ -1354,6 +1327,47 @@ gtk_tree_menu_set_model (GtkTreeMenu  *menu,
     }
 }
 
+/****************************************************************
+ *                            API                               *
+ ****************************************************************/
+GtkWidget *
+gtk_tree_menu_new (void)
+{
+  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, NULL);
+}
+
+GtkWidget *
+gtk_tree_menu_new_with_area (GtkCellArea    *area)
+{
+  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, 
+				    "cell-area", area, 
+				    NULL);
+}
+
+GtkWidget *
+gtk_tree_menu_new_full (GtkCellArea         *area,
+			GtkTreeModel        *model,
+			GtkTreePath         *root)
+{
+  return (GtkWidget *)g_object_new (GTK_TYPE_TREE_MENU, 
+				    "cell-area", area, 
+				    "model", model,
+				    "root", root,
+				    NULL);
+}
+
+void
+gtk_tree_menu_set_model (GtkTreeMenu  *menu,
+			 GtkTreeModel *model)
+{
+  g_return_if_fail (GTK_IS_TREE_MENU (menu));
+  g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
+
+  gtk_tree_menu_set_model_internal (menu, model);
+
+  rebuild_menu (menu);
+}
+
 GtkTreeModel *
 gtk_tree_menu_get_model (GtkTreeMenu *menu)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]