]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcombobox.c
Use gtk_box_new() instead gtk_[v|h]box_new()
[~andy/gtk] / gtk / gtkcombobox.c
index 46a9b952f48895e163d7c1aa3356e467cee78acb..d36990ea8b38e280e08eff85f72dd336f27c33d4 100644 (file)
@@ -38,7 +38,6 @@
 #include "gtktreeselection.h"
 #include "gtkvseparator.h"
 #include "gtkwindow.h"
-#include "gtksizerequest.h"
 #include "gtkprivate.h"
 
 #include <gdk/gdkkeysyms.h>
 
 #include "gtktreeprivate.h"
 
+
+/**
+ * SECTION:gtkcombobox
+ * @Short_description: A widget used to choose from a list of items
+ * @Title: GtkComboBox
+ * @See_also: #GtkComboBoxText, #GtkTreeModel, #GtkCellRenderer
+ *
+ * A GtkComboBox is a widget that allows the user to choose from a list of
+ * valid choices. The GtkComboBox displays the selected choice. When
+ * activated, the GtkComboBox displays a popup which allows the user to
+ * make a new choice. The style in which the selected value is displayed,
+ * and the style of the popup is determined by the current theme. It may
+ * be similar to a Windows-style combo box.
+ *
+ * The GtkComboBox uses the model-view pattern; the list of valid choices
+ * is specified in the form of a tree model, and the display of the choices
+ * can be adapted to the data in the model by using cell renderers, as you
+ * would in a tree view. This is possible since GtkComboBox implements the
+ * #GtkCellLayout interface. The tree model holding the valid choices is
+ * not restricted to a flat list, it can be a real tree, and the popup will
+ * reflect the tree structure.
+ *
+ * For a simple list of textual choices, the model-view API of GtkComboBox
+ * can be a bit overwhelming. In this case, #GtkComboBoxText offers a
+ * simple alternative.
+ */
+
+
 /* WELCOME, to THE house of evil code */
 
 typedef struct _ComboCellInfo ComboCellInfo;
@@ -98,10 +125,10 @@ struct _GtkComboBoxPrivate
   GtkWidget *popup_window;
   GtkWidget *scrolled_window;
 
-  guint inserted_id;
-  guint deleted_id;
-  guint reordered_id;
-  guint changed_id;
+  gulong inserted_id;
+  gulong deleted_id;
+  gulong reordered_id;
+  gulong changed_id;
   guint popup_idle_id;
   guint activate_button;
   guint32 activate_time;
@@ -111,6 +138,11 @@ struct _GtkComboBoxPrivate
   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;
+
   GSList *cells;
 
   guint popup_in_progress : 1;
@@ -122,6 +154,8 @@ struct _GtkComboBoxPrivate
   guint auto_scroll : 1;
   guint focus_on_click : 1;
   guint button_sensitivity : 2;
+  guint has_entry : 1;
+  guint popup_fixed_width : 1;
 
   GtkTreeViewRowSeparatorFunc row_separator_func;
   gpointer                    row_separator_data;
@@ -208,7 +242,10 @@ enum {
   PROP_FOCUS_ON_CLICK,
   PROP_POPUP_SHOWN,
   PROP_BUTTON_SENSITIVITY,
-  PROP_EDITING_CANCELED
+  PROP_EDITING_CANCELED,
+  PROP_HAS_ENTRY,
+  PROP_ENTRY_TEXT_COLUMN,
+  PROP_POPUP_FIXED_WIDTH
 };
 
 static guint combo_box_signals[LAST_SIGNAL] = {0,};
@@ -220,9 +257,12 @@ static guint combo_box_signals[LAST_SIGNAL] = {0,};
 
 static void     gtk_combo_box_cell_layout_init     (GtkCellLayoutIface *iface);
 static void     gtk_combo_box_cell_editable_init   (GtkCellEditableIface *iface);
+static GObject *gtk_combo_box_constructor          (GType                  type,
+                                                   guint                  n_construct_properties,
+                                                   GObjectConstructParam *construct_properties);
 static void     gtk_combo_box_dispose              (GObject          *object);
 static void     gtk_combo_box_finalize             (GObject          *object);
-static void     gtk_combo_box_destroy              (GtkObject        *object);
+static void     gtk_combo_box_destroy              (GtkWidget        *widget);
 
 static void     gtk_combo_box_set_property         (GObject         *object,
                                                     guint            prop_id,
@@ -286,15 +326,14 @@ static void     gtk_combo_box_forall               (GtkContainer     *container,
                                                     gboolean          include_internals,
                                                     GtkCallback       callback,
                                                     gpointer          callback_data);
-static gboolean gtk_combo_box_expose_event         (GtkWidget        *widget,
-                                                    GdkEventExpose   *event);
+static gboolean gtk_combo_box_draw                 (GtkWidget        *widget,
+                                                    cairo_t          *cr);
 static gboolean gtk_combo_box_scroll_event         (GtkWidget        *widget,
                                                     GdkEventScroll   *event);
 static void     gtk_combo_box_set_active_internal  (GtkComboBox      *combo_box,
                                                    GtkTreePath      *path);
 
 static void     gtk_combo_box_check_appearance     (GtkComboBox      *combo_box);
-static gchar *  gtk_combo_box_real_get_active_text (GtkComboBox      *combo_box);
 static void     gtk_combo_box_real_move_active     (GtkComboBox      *combo_box,
                                                     GtkScrollType     scroll);
 static void     gtk_combo_box_real_popup           (GtkComboBox      *combo_box);
@@ -447,6 +486,13 @@ static void     gtk_combo_box_child_show                     (GtkWidget       *w
 static void     gtk_combo_box_child_hide                     (GtkWidget       *widget,
                                                              GtkComboBox     *combo_box);
 
+/* GtkComboBox:has-entry callbacks */
+static void     gtk_combo_box_entry_contents_changed         (GtkEntry        *entry,
+                                                             gpointer         user_data);
+static void     gtk_combo_box_entry_active_changed           (GtkComboBox     *combo_box,
+                                                             gpointer         user_data);
+
+
 /* GtkBuildable method implementation */
 static GtkBuildableIface *parent_buildable_iface;
 
@@ -462,23 +508,26 @@ static void     gtk_combo_box_buildable_custom_tag_end       (GtkBuildable  *bui
                                                              GObject       *child,
                                                              const gchar   *tagname,
                                                              gpointer      *data);
+static GObject *gtk_combo_box_buildable_get_internal_child   (GtkBuildable *buildable,
+                                                             GtkBuilder   *builder,
+                                                             const gchar  *childname);
+
 
 /* GtkCellEditable method implementations */
 static void     gtk_combo_box_start_editing                  (GtkCellEditable *cell_editable,
                                                              GdkEvent        *event);
 
-static void     gtk_combo_box_size_request_init              (GtkSizeRequestIface *iface);
-static void     gtk_combo_box_get_width                      (GtkSizeRequest      *widget,
+static void     gtk_combo_box_get_preferred_width            (GtkWidget           *widget,
                                                              gint                *minimum_size,
                                                              gint                *natural_size);
-static void     gtk_combo_box_get_height                     (GtkSizeRequest      *widget,
+static void     gtk_combo_box_get_preferred_height           (GtkWidget           *widget,
                                                              gint                *minimum_size,
                                                              gint                *natural_size);
-static void     gtk_combo_box_get_width_for_height           (GtkSizeRequest        *widget,
+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_height_for_width           (GtkSizeRequest        *widget,
+static void     gtk_combo_box_get_preferred_height_for_width (GtkWidget             *widget,
                                                              gint                   avail_size,
                                                              gint                  *minimum_size,
                                                              gint                  *natural_size);
@@ -490,9 +539,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
                                                gtk_combo_box_cell_editable_init)
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-                                               gtk_combo_box_buildable_init)
-                        G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
-                                               gtk_combo_box_size_request_init))
+                                               gtk_combo_box_buildable_init))
 
 
 /* common */
@@ -500,13 +547,10 @@ static void
 gtk_combo_box_class_init (GtkComboBoxClass *klass)
 {
   GObjectClass *object_class;
-  GtkObjectClass *gtk_object_class;
   GtkContainerClass *container_class;
   GtkWidgetClass *widget_class;
   GtkBindingSet *binding_set;
 
-  klass->get_active_text = gtk_combo_box_real_get_active_text;
-
   container_class = (GtkContainerClass *)klass;
   container_class->forall = gtk_combo_box_forall;
   container_class->add = gtk_combo_box_add;
@@ -514,17 +558,20 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
 
   widget_class = (GtkWidgetClass *)klass;
   widget_class->size_allocate = gtk_combo_box_size_allocate;
-  widget_class->expose_event = gtk_combo_box_expose_event;
+  widget_class->draw = gtk_combo_box_draw;
   widget_class->scroll_event = gtk_combo_box_scroll_event;
   widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
   widget_class->grab_focus = gtk_combo_box_grab_focus;
   widget_class->style_set = gtk_combo_box_style_set;
   widget_class->state_changed = gtk_combo_box_state_changed;
-
-  gtk_object_class = (GtkObjectClass *)klass;
-  gtk_object_class->destroy = gtk_combo_box_destroy;
+  widget_class->get_preferred_width = gtk_combo_box_get_preferred_width;
+  widget_class->get_preferred_height = gtk_combo_box_get_preferred_height;
+  widget_class->get_preferred_height_for_width = gtk_combo_box_get_preferred_height_for_width;
+  widget_class->get_preferred_width_for_height = gtk_combo_box_get_preferred_width_for_height;
+  widget_class->destroy = gtk_combo_box_destroy;
 
   object_class = (GObjectClass *)klass;
+  object_class->constructor = gtk_combo_box_constructor;
   object_class->dispose = gtk_combo_box_dispose;
   object_class->finalize = gtk_combo_box_finalize;
   object_class->set_property = gtk_combo_box_set_property;
@@ -537,10 +584,10 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
    * 
    * The changed signal is emitted when the active
    * item is changed. The can be due to the user selecting
-   * a different item from the list, or due to a 
+   * a different item from the list, or due to a
    * call to gtk_combo_box_set_active_iter().
-   * It will also be emitted while typing into a GtkComboBoxEntry, 
-   * as well as when selecting an item from the GtkComboBoxEntry's list.
+   * It will also be emitted while typing into the entry of a combo box
+   * with an entry.
    *
    * Since: 2.4
    */
@@ -617,53 +664,53 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   /* key bindings */
   binding_set = gtk_binding_set_by_class (widget_class);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Down, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
                                "popup", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, GDK_MOD1_MASK,
                                "popup", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
                                "popdown", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, GDK_MOD1_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, GDK_MOD1_MASK,
                                "popdown", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
                                "popdown", 0);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_Page_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Up, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Up, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
-  gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Home, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Home, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_Page_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Page_Down, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Down, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
-  gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_End, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_End, 0,
                                "move-active", 1,
                                GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
 
@@ -868,6 +915,57 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
                                                        GTK_SENSITIVITY_AUTO,
                                                        GTK_PARAM_READWRITE));
 
+   /**
+    * GtkComboBox:has-entry:
+    *
+    * Whether the combo box has an entry.
+    *
+    * Since: 2.24
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_HAS_ENTRY,
+                                    g_param_spec_boolean ("has-entry",
+                                                         P_("Has Entry"),
+                                                         P_("Whether combo box has an entry"),
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+   /**
+    * GtkComboBox:entry-text-column:
+    *
+    * The column in the combo box's model to associate with strings from the entry
+    * if the combo was created with #GtkComboBox:has-entry = %TRUE.
+    *
+    * Since: 2.24
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_ENTRY_TEXT_COLUMN,
+                                    g_param_spec_int ("entry-text-column",
+                                                     P_("Entry Text Column"),
+                                                     P_("The column in the combo box's model to associate "
+                                                        "with strings from the entry if the combo was "
+                                                        "created with #GtkComboBox:has-entry = %TRUE"),
+                                                     -1, G_MAXINT, -1,
+                                                     GTK_PARAM_READWRITE));
+
+   /**
+    * GtkComboBox:popup-fixed-width:
+    *
+    * Whether the popup's width should be a fixed width matching the
+    * allocated width of the combo box.
+    *
+    * Since: 3.0
+    */
+   g_object_class_install_property (object_class,
+                                    PROP_POPUP_FIXED_WIDTH,
+                                    g_param_spec_boolean ("popup-fixed-width",
+                                                         P_("Popup Fixed Width"),
+                                                         P_("Whether the popup's width should be a "
+                                                            "fixed width matching the allocated width "
+                                                            "of the combo box"),
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE));
+
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_boolean ("appears-as-list",
                                                                  P_("Appears as list"),
@@ -919,6 +1017,7 @@ gtk_combo_box_buildable_init (GtkBuildableIface *iface)
   iface->add_child = _gtk_cell_layout_buildable_add_child;
   iface->custom_tag_start = gtk_combo_box_buildable_custom_tag_start;
   iface->custom_tag_end = gtk_combo_box_buildable_custom_tag_end;
+  iface->get_internal_child = gtk_combo_box_buildable_get_internal_child;
 }
 
 static void
@@ -973,6 +1072,11 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   priv->auto_scroll = FALSE;
   priv->focus_on_click = TRUE;
   priv->button_sensitivity = GTK_SENSITIVITY_AUTO;
+  priv->has_entry = FALSE;
+  priv->popup_fixed_width = TRUE;
+
+  priv->text_column = -1;
+  priv->text_renderer = NULL;
 
   gtk_combo_box_check_appearance (combo_box);
 }
@@ -1013,6 +1117,17 @@ gtk_combo_box_set_property (GObject      *object,
 
     case PROP_HAS_FRAME:
       combo_box->priv->has_frame = g_value_get_boolean (value);
+
+      if (combo_box->priv->has_entry)
+        {
+          GtkWidget *child;
+
+          child = gtk_bin_get_child (GTK_BIN (combo_box));
+
+          gtk_entry_set_has_frame (GTK_ENTRY (child),
+                                   combo_box->priv->has_frame);
+        }
+
       break;
 
     case PROP_FOCUS_ON_CLICK:
@@ -1036,10 +1151,23 @@ gtk_combo_box_set_property (GObject      *object,
                                             g_value_get_enum (value));
       break;
 
+    case PROP_POPUP_FIXED_WIDTH:
+      gtk_combo_box_set_popup_fixed_width (combo_box,
+                                          g_value_get_boolean (value));
+      break;
+
     case PROP_EDITING_CANCELED:
       combo_box->priv->editing_canceled = g_value_get_boolean (value);
       break;
 
+    case PROP_HAS_ENTRY:
+      combo_box->priv->has_entry = g_value_get_boolean (value);
+      break;
+
+    case PROP_ENTRY_TEXT_COLUMN:
+      gtk_combo_box_set_entry_text_column (combo_box, g_value_get_int (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1101,10 +1229,22 @@ gtk_combo_box_get_property (GObject    *object,
         g_value_set_enum (value, combo_box->priv->button_sensitivity);
         break;
 
+      case PROP_POPUP_FIXED_WIDTH:
+        g_value_set_boolean (value, combo_box->priv->popup_fixed_width);
+        break;
+
       case PROP_EDITING_CANCELED:
         g_value_set_boolean (value, priv->editing_canceled);
         break;
 
+      case PROP_HAS_ENTRY:
+       g_value_set_boolean (value, priv->has_entry);
+       break;
+
+      case PROP_ENTRY_TEXT_COLUMN:
+       g_value_set_int (value, priv->text_column);
+       break;
+
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -1237,6 +1377,14 @@ gtk_combo_box_add (GtkContainer *container,
   GtkComboBox *combo_box = GTK_COMBO_BOX (container);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
+  if (priv->has_entry && !GTK_IS_ENTRY (widget))
+    {
+      g_warning ("Attempting to add a widget with type %s to a GtkComboBox that needs an entry "
+                "(need an instance of GtkEntry or of a subclass)",
+                 G_OBJECT_TYPE_NAME (widget));
+      return;
+    }
+
   if (priv->cell_view &&
       gtk_widget_get_parent (priv->cell_view))
     {
@@ -1269,6 +1417,19 @@ gtk_combo_box_add (GtkContainer *container,
           priv->box = NULL;
         }
     }
+
+  if (priv->has_entry)
+    {
+      /* this flag is a hack to tell the entry to fill its allocation.
+       */
+      GTK_ENTRY (widget)->is_cell_renderer = TRUE;
+
+      g_signal_connect (widget, "changed",
+                       G_CALLBACK (gtk_combo_box_entry_contents_changed),
+                       combo_box);
+
+      gtk_entry_set_has_frame (GTK_ENTRY (widget), priv->has_frame);
+    }
 }
 
 static void
@@ -1280,13 +1441,27 @@ gtk_combo_box_remove (GtkContainer *container,
   GtkTreePath *path;
   gboolean appears_as_list;
 
+  if (priv->has_entry)
+    {
+      GtkWidget *child_widget;
+
+      child_widget = gtk_bin_get_child (GTK_BIN (container));
+      if (widget && widget == child_widget)
+       {
+         g_signal_handlers_disconnect_by_func (widget,
+                                               gtk_combo_box_entry_contents_changed,
+                                               container);
+         GTK_ENTRY (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);
 
-  if (GTK_OBJECT_FLAGS (combo_box) & GTK_IN_DESTRUCTION)
+  if (gtk_widget_in_destruction (GTK_WIDGET (combo_box)))
     return;
 
   gtk_widget_queue_resize (GTK_WIDGET (container));
@@ -1529,7 +1704,10 @@ gtk_combo_box_menu_position_below (GtkMenu  *menu,
   if (GTK_SHADOW_NONE != combo_box->priv->shadow_type)
     sx -= gtk_widget_get_style (GTK_WIDGET (combo_box))->xthickness;
 
-  gtk_widget_size_request (GTK_WIDGET (menu), &req);
+  if (combo_box->priv->popup_fixed_width)
+    gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+  else
+    gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
 
   if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
     *x = sx;
@@ -1588,7 +1766,10 @@ gtk_combo_box_menu_position_over (GtkMenu  *menu,
   menu_xpos = allocation.x;
   menu_ypos = allocation.y + allocation.height / 2 - 2;
 
-  gtk_size_request_get_width (GTK_SIZE_REQUEST (menu), &menu_width, NULL);
+  if (combo_box->priv->popup_fixed_width)
+    gtk_widget_get_preferred_width (GTK_WIDGET (menu), &menu_width, NULL);
+  else
+    gtk_widget_get_preferred_width (GTK_WIDGET (menu), NULL, &menu_width);
 
   if (active != NULL)
     {
@@ -1646,7 +1827,6 @@ gtk_combo_box_menu_position (GtkMenu  *menu,
   GtkComboBoxPrivate *priv = combo_box->priv;
   GtkWidget *menu_item;
 
-
   if (priv->wrap_width > 0 || priv->cell_view == NULL) 
     gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
   else
@@ -1705,14 +1885,47 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
   hpolicy = vpolicy = GTK_POLICY_NEVER;
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
                                  hpolicy, vpolicy);
-  gtk_widget_size_request (priv->scrolled_window, &popup_req);
 
-  if (popup_req.width > *width)
+  /* XXX This set_size_request call is part of the hack outlined below and can 
+   * go away once height-for-width is implemented on treeviews. */
+  gtk_widget_set_size_request (priv->tree_view, -1, -1);
+
+  if (combo_box->priv->popup_fixed_width)
     {
-      hpolicy = GTK_POLICY_ALWAYS;
-      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
-                                     hpolicy, vpolicy);
-      gtk_widget_size_request (priv->scrolled_window, &popup_req);
+      gtk_widget_get_preferred_size (priv->scrolled_window, &popup_req, NULL);
+
+      if (popup_req.width > *width)
+       {
+         hpolicy = GTK_POLICY_ALWAYS;
+         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
+                                         hpolicy, vpolicy);
+       }
+    }
+  else
+    {
+      gtk_combo_box_remeasure (combo_box);
+
+      if (priv->natural_width > *width)
+       {
+         hpolicy = GTK_POLICY_NEVER;
+         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
+                                         hpolicy, vpolicy);
+
+
+         /* XXX Currently we set the size-request on the internal treeview to be
+          * the natural width of the cells, this hack can go away once our
+          * treeview does height-for-width properly (i.e. just adjust *width
+          * here to be the natural width request of the scrolled-window). 
+          *
+          * I can't tell why the magic number 5 is needed here (i.e. without it 
+          * 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_get_preferred_size (priv->scrolled_window, NULL, &popup_req);
+
+         *width = popup_req.width;
+       }
     }
 
   *height = popup_req.height;
@@ -1721,6 +1934,9 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
   monitor_num = gdk_screen_get_monitor_at_window (screen, window);
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
+  if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_RTL)
+    *x = *x + allocation.width - *width;
+
   if (*x < monitor.x)
     *x = monitor.x;
   else if (*x + *width > monitor.x + monitor.width)
@@ -1863,7 +2079,7 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
   GtkComboBoxPrivate *priv = combo_box->priv;
   GtkTreePath *path;
   gint active_item;
-  gint width, min_width;
+  gint width, min_width, nat_width;
   
   update_menu_sensitivity (combo_box, priv->popup_widget);
 
@@ -1888,10 +2104,14 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
       gtk_widget_get_allocation (GTK_WIDGET (combo_box), &allocation);
       width = allocation.width;
       gtk_widget_set_size_request (priv->popup_widget, -1, -1);
-      gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL);
-      
-      gtk_widget_set_size_request (priv->popup_widget,
-                                  MAX (width, min_width), -1);
+      gtk_widget_get_preferred_width (priv->popup_widget, &min_width, &nat_width);
+
+      if (combo_box->priv->popup_fixed_width)
+       width = MAX (width, min_width);
+      else
+       width = MAX (width, nat_width);
+
+      gtk_widget_set_size_request (priv->popup_widget, width, -1);
     }
   
   gtk_menu_popup (GTK_MENU (priv->popup_widget),
@@ -2120,7 +2340,7 @@ gtk_combo_box_popdown (GtkComboBox *combo_box)
     return;
 
   gtk_device_grab_remove (priv->popup_window, priv->grab_pointer);
-  gtk_widget_hide_all (priv->popup_window);
+  gtk_widget_hide (priv->popup_window);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
                                 FALSE);
 
@@ -2168,7 +2388,8 @@ gtk_combo_box_update_requested_width (GtkComboBox *combo_box,
 }
 
 #define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON                                     \
-  gtk_widget_size_request (combo_box->priv->button, &req);                     \
+  gtk_widget_get_preferred_size (combo_box->priv->button,                      \
+                                 &req, NULL);                                  \
                                                                                \
   if (is_rtl)                                                                  \
     child.x = allocation->x + shadow_width;                                    \
@@ -2254,7 +2475,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
 
 
           /* handle the children */
-          gtk_widget_size_request (priv->arrow, &req);
+          gtk_widget_get_preferred_size (priv->arrow, &req, NULL);
           child.width = req.width;
           if (!is_rtl)
             child.x += width - req.width;
@@ -2263,7 +2484,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
           gtk_widget_size_allocate (priv->arrow, &child);
           if (is_rtl)
             child.x += req.width;
-          gtk_widget_size_request (priv->separator, &req);
+          gtk_widget_get_preferred_size (priv->separator, &req, NULL);
           child.width = req.width;
           if (!is_rtl)
             child.x -= req.width;
@@ -2288,7 +2509,7 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
 
           if (gtk_widget_get_visible (priv->popup_widget))
             {
-              gint width, min_width;
+              gint width, menu_width;
 
               if (priv->wrap_width == 0)
                 {
@@ -2297,9 +2518,14 @@ gtk_combo_box_size_allocate (GtkWidget     *widget,
                   gtk_widget_get_allocation (GTK_WIDGET (combo_box), &combo_box_allocation);
                   width = combo_box_allocation.width;
                   gtk_widget_set_size_request (priv->popup_widget, -1, -1);
-                  gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL);
+
+                 if (combo_box->priv->popup_fixed_width)
+                   gtk_widget_get_preferred_width (priv->popup_widget, &menu_width, NULL);
+                 else
+                   gtk_widget_get_preferred_width (priv->popup_widget, NULL, &menu_width);
+
                   gtk_widget_set_size_request (priv->popup_widget,
-                    MAX (width, min_width), -1);
+                                              MAX (width, menu_width), -1);
                }
 
               /* reposition the menu after giving it a new width */
@@ -2480,39 +2706,35 @@ gtk_combo_box_child_hide (GtkWidget *widget,
 }
 
 static gboolean
-gtk_combo_box_expose_event (GtkWidget      *widget,
-                            GdkEventExpose *event)
+gtk_combo_box_draw (GtkWidget *widget,
+                    cairo_t   *cr)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
   GtkComboBoxPrivate *priv = combo_box->priv;
 
-  if (gtk_widget_is_drawable (widget) &&
-      GTK_SHADOW_NONE != priv->shadow_type)
+  if (priv->shadow_type != GTK_SHADOW_NONE)
     {
-      GtkAllocation allocation;
-
-      gtk_widget_get_allocation (widget, &allocation);
-
       gtk_paint_shadow (gtk_widget_get_style (widget),
-                        gtk_widget_get_window (widget),
+                        cr,
                         GTK_STATE_NORMAL, priv->shadow_type,
-                        NULL, widget, "combobox",
-                        allocation.x, allocation.y,
-                        allocation.width, allocation.height);
+                        widget, "combobox",
+                        0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
     }
 
-  gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                 priv->button, event);
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                               priv->button, cr);
 
   if (priv->tree_view && priv->cell_view_frame)
     {
-      gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                     priv->cell_view_frame, event);
+      gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                                   priv->cell_view_frame, cr);
     }
 
-  gtk_container_propagate_expose (GTK_CONTAINER (widget),
-                                  gtk_bin_get_child (GTK_BIN (widget)),
-                                  event);
+  gtk_container_propagate_draw (GTK_CONTAINER (widget),
+                                gtk_bin_get_child (GTK_BIN (widget)),
+                                cr);
 
   return FALSE;
 }
@@ -2808,10 +3030,10 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
       gtk_widget_set_parent (priv->button,
                              gtk_widget_get_parent (child));
 
-      priv->box = gtk_hbox_new (FALSE, 0);
+      priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
       gtk_container_add (GTK_CONTAINER (priv->button), priv->box);
 
-      priv->separator = gtk_vseparator_new ();
+      priv->separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
       gtk_container_add (GTK_CONTAINER (priv->box), priv->separator);
 
       priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
@@ -2910,7 +3132,7 @@ gtk_cell_view_menu_item_new (GtkComboBox  *combo_box,
   gtk_tree_path_free (path);
 
   gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (cell_view));
-  gtk_widget_size_request (cell_view, &req);
+  gtk_widget_get_preferred_size (cell_view, &req, NULL);
   gtk_widget_show (cell_view);
   
   return item;
@@ -3967,12 +4189,12 @@ gtk_combo_box_menu_key_press (GtkWidget   *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
 
-  if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event))
+  if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
     {
       /* The menu hasn't managed the
        * event, forward it to the combobox
        */
-      gtk_bindings_activate_event (GTK_OBJECT (combo_box), event);
+      gtk_bindings_activate_event (G_OBJECT (combo_box), event);
     }
 
   return TRUE;
@@ -3986,8 +4208,8 @@ gtk_combo_box_list_key_press (GtkWidget   *widget,
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
   GtkTreeIter iter;
 
-  if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || event->keyval == GDK_KP_Enter ||
-      event->keyval == GDK_space || event->keyval == GDK_KP_Space) 
+  if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_ISO_Enter || event->keyval == GDK_KEY_KP_Enter ||
+      event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space) 
   {
     GtkTreeModel *model = NULL;
     
@@ -4006,12 +4228,12 @@ gtk_combo_box_list_key_press (GtkWidget   *widget,
     return TRUE;
   }
 
-  if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event))
+  if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
     {
       /* The list hasn't managed the
        * event, forward it to the combobox
        */
-      gtk_bindings_activate_event (GTK_OBJECT (combo_box), event);
+      gtk_bindings_activate_event (G_OBJECT (combo_box), event);
     }
 
   return TRUE;
@@ -4625,6 +4847,19 @@ gtk_combo_box_new (void)
   return g_object_new (GTK_TYPE_COMBO_BOX, NULL);
 }
 
+/**
+ * gtk_combo_box_new_with_entry:
+ *
+ * Creates a new empty #GtkComboBox with an entry.
+ *
+ * Return value: A new #GtkComboBox.
+ */
+GtkWidget *
+gtk_combo_box_new_with_entry (void)
+{
+  return g_object_new (GTK_TYPE_COMBO_BOX, "has-entry", TRUE, NULL);
+}
+
 /**
  * gtk_combo_box_new_with_model:
  * @model: A #GtkTreeModel.
@@ -4647,6 +4882,23 @@ gtk_combo_box_new_with_model (GtkTreeModel *model)
   return GTK_WIDGET (combo_box);
 }
 
+/**
+ * gtk_combo_box_new_with_model_and_entry:
+ *
+ * Creates a new empty #GtkComboBox with an entry
+ * and with the model initialized to @model.
+ *
+ * Return value: A new #GtkComboBox
+ */
+GtkWidget *
+gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
+{
+  return g_object_new (GTK_TYPE_COMBO_BOX,
+                       "has-entry", TRUE,
+                       "model", model,
+                       NULL);
+}
+
 /**
  * gtk_combo_box_get_wrap_width:
  * @combo_box: A #GtkComboBox
@@ -4992,8 +5244,6 @@ gtk_combo_box_get_active_iter (GtkComboBox     *combo_box,
  * 
  * Sets the current active item to be the one referenced by @iter, or
  * unsets the active item if @iter is %NULL.
- *
- * @iter must correspond to a path of depth one, or be %NULL.
  * 
  * Since: 2.4
  */
@@ -5094,12 +5344,13 @@ out:
 }
 
 /**
- * gtk_combo_box_get_model
+ * gtk_combo_box_get_model:
  * @combo_box: A #GtkComboBox
  *
  * Returns the #GtkTreeModel which is acting as data source for @combo_box.
  *
- * Return value: (transfer none): A #GtkTreeModel which was passed during construction.
+ * Return value: (transfer none): A #GtkTreeModel which was passed
+ *     during construction.
  *
  * Since: 2.4
  */
@@ -5111,212 +5362,6 @@ gtk_combo_box_get_model (GtkComboBox *combo_box)
   return combo_box->priv->model;
 }
 
-
-/* convenience API for simple text combos */
-
-/**
- * gtk_combo_box_new_text:
- *
- * Convenience function which constructs a new text combo box, which is a
- * #GtkComboBox just displaying strings. If you use this function to create
- * a text combo box, you should only manipulate its data source with the
- * following convenience functions: gtk_combo_box_append_text(),
- * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
- * gtk_combo_box_remove_text().
- *
- * Return value: (transfer none): A new text combo box.
- *
- * Since: 2.4
- */
-GtkWidget *
-gtk_combo_box_new_text (void)
-{
-  GtkWidget *combo_box;
-  GtkCellRenderer *cell;
-  GtkListStore *store;
-
-  store = gtk_list_store_new (1, G_TYPE_STRING);
-  combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
-  g_object_unref (store);
-
-  cell = gtk_cell_renderer_text_new ();
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
-  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
-                                  "text", 0,
-                                  NULL);
-
-  return combo_box;
-}
-
-/**
- * gtk_combo_box_append_text:
- * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
- * @text: A string
- *
- * Appends @string to the list of strings stored in @combo_box. Note that
- * you can only use this function with combo boxes constructed with
- * gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_append_text (GtkComboBox *combo_box,
-                           const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  gtk_list_store_append (store, &iter);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_insert_text:
- * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text()
- * @position: An index to insert @text
- * @text: A string
- *
- * Inserts @string at @position in the list of strings stored in @combo_box.
- * Note that you can only use this function with combo boxes constructed
- * with gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_insert_text (GtkComboBox *combo_box,
-                           gint         position,
-                           const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (position >= 0);
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  gtk_list_store_insert (store, &iter, position);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_prepend_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- * @text: A string
- *
- * Prepends @string to the list of strings stored in @combo_box. Note that
- * you can only use this function with combo boxes constructed with
- * gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_prepend_text (GtkComboBox *combo_box,
-                            const gchar *text)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (text != NULL);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  gtk_list_store_prepend (store, &iter);
-  gtk_list_store_set (store, &iter, 0, text, -1);
-}
-
-/**
- * gtk_combo_box_remove_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- * @position: Index of the item to remove
- *
- * Removes the string at @position from @combo_box. Note that you can only use
- * this function with combo boxes constructed with gtk_combo_box_new_text().
- *
- * Since: 2.4
- */
-void
-gtk_combo_box_remove_text (GtkComboBox *combo_box,
-                           gint         position)
-{
-  GtkTreeIter iter;
-  GtkListStore *store;
-
-  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
-  g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
-  g_return_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                   == G_TYPE_STRING);
-  g_return_if_fail (position >= 0);
-
-  store = GTK_LIST_STORE (combo_box->priv->model);
-
-  if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
-                                     NULL, position))
-    gtk_list_store_remove (store, &iter);
-}
-
-/**
- * gtk_combo_box_get_active_text:
- * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text()
- *
- * Returns the currently active string in @combo_box or %NULL if none
- * is selected.  Note that you can only use this function with combo
- * boxes constructed with gtk_combo_box_new_text() and with
- * #GtkComboBoxEntry<!-- -->s.
- *
- * Returns: a newly allocated string containing the currently active text.
- *     Must be freed with g_free().
- *
- * Since: 2.6
- */
-gchar *
-gtk_combo_box_get_active_text (GtkComboBox *combo_box)
-{
-  GtkComboBoxClass *class;
-
-  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
-
-  class = GTK_COMBO_BOX_GET_CLASS (combo_box);
-
-  if (class->get_active_text)
-    return class->get_active_text (combo_box);
-
-  return NULL;
-}
-
-static gchar *
-gtk_combo_box_real_get_active_text (GtkComboBox *combo_box)
-{
-  GtkTreeIter iter;
-  gchar *text = NULL;
-
-  g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL);
-  g_return_val_if_fail (gtk_tree_model_get_column_type (combo_box->priv->model, 0)
-                        == G_TYPE_STRING, NULL);
-
-  if (gtk_combo_box_get_active_iter (combo_box, &iter))
-    gtk_tree_model_get (combo_box->priv->model, &iter, 
-                       0, &text, -1);
-
-  return text;
-}
-
 static void
 gtk_combo_box_real_move_active (GtkComboBox   *combo_box,
                                 GtkScrollType  scroll)
@@ -5407,7 +5452,16 @@ gtk_combo_box_mnemonic_activate (GtkWidget *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
-  gtk_widget_grab_focus (combo_box->priv->button);
+  if (combo_box->priv->has_entry)
+    {
+      GtkWidget* child;
+
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
+      if (child)
+       gtk_widget_grab_focus (child);
+    }
+  else
+    gtk_widget_grab_focus (combo_box->priv->button);
 
   return TRUE;
 }
@@ -5417,13 +5471,22 @@ gtk_combo_box_grab_focus (GtkWidget *widget)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
-  gtk_widget_grab_focus (combo_box->priv->button);
+  if (combo_box->priv->has_entry)
+    {
+      GtkWidget *child;
+
+      child = gtk_bin_get_child (GTK_BIN (combo_box));
+      if (child)
+       gtk_widget_grab_focus (child);
+    }
+  else
+    gtk_widget_grab_focus (combo_box->priv->button);
 }
 
 static void
-gtk_combo_box_destroy (GtkObject *object)
+gtk_combo_box_destroy (GtkWidget *widget)
 {
-  GtkComboBox *combo_box = GTK_COMBO_BOX (object);
+  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
 
   if (combo_box->priv->popup_idle_id > 0)
     {
@@ -5440,10 +5503,98 @@ gtk_combo_box_destroy (GtkObject *object)
   combo_box->priv->row_separator_data = NULL;
   combo_box->priv->row_separator_destroy = NULL;
 
-  GTK_OBJECT_CLASS (gtk_combo_box_parent_class)->destroy (object);
+  GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->destroy (widget);
   combo_box->priv->cell_view = NULL;
 }
 
+static void
+gtk_combo_box_entry_contents_changed (GtkEntry *entry,
+                                      gpointer  user_data)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+
+  /*
+   *  Fixes regression reported in bug #574059. The old functionality relied on
+   *  bug #572478.  As a bugfix, we now emit the "changed" signal ourselves
+   *  when the selection was already set to -1.
+   */
+  if (gtk_combo_box_get_active(combo_box) == -1)
+    g_signal_emit_by_name (combo_box, "changed");
+  else
+    gtk_combo_box_set_active (combo_box, -1);
+}
+
+static void
+gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
+                                    gpointer     user_data)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  if (gtk_combo_box_get_active_iter (combo_box, &iter))
+    {
+      GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box)));
+
+      if (entry)
+       {
+          GValue value = {0,};
+
+         g_signal_handlers_block_by_func (entry,
+                                          gtk_combo_box_entry_contents_changed,
+                                          combo_box);
+
+         model = gtk_combo_box_get_model (combo_box);
+
+          gtk_tree_model_get_value (model, &iter,
+                                    priv->text_column, &value);
+          g_object_set_property (G_OBJECT (entry), "text", &value);
+          g_value_unset (&value);
+
+         g_signal_handlers_unblock_by_func (entry,
+                                            gtk_combo_box_entry_contents_changed,
+                                            combo_box);
+       }
+    }
+}
+
+static GObject *
+gtk_combo_box_constructor (GType                  type,
+                          guint                  n_construct_properties,
+                          GObjectConstructParam *construct_properties)
+{
+  GObject            *object;
+  GtkComboBox        *combo_box;
+  GtkComboBoxPrivate *priv;
+
+  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)
 {
@@ -5498,6 +5649,7 @@ gtk_combo_box_finalize (GObject *object)
    G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object);
 }
 
+
 static gboolean
 gtk_cell_editable_key_press (GtkWidget   *widget,
                             GdkEventKey *event,
@@ -5505,7 +5657,7 @@ gtk_cell_editable_key_press (GtkWidget   *widget,
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (data);
 
-  if (event->keyval == GDK_Escape)
+  if (event->keyval == GDK_KEY_Escape)
     {
       g_object_set (combo_box,
                     "editing-canceled", TRUE,
@@ -5515,9 +5667,9 @@ gtk_cell_editable_key_press (GtkWidget   *widget,
       
       return TRUE;
     }
-  else if (event->keyval == GDK_Return ||
-           event->keyval == GDK_ISO_Enter ||
-           event->keyval == GDK_KP_Enter)
+  else if (event->keyval == GDK_KEY_Return ||
+           event->keyval == GDK_KEY_ISO_Enter ||
+           event->keyval == GDK_KEY_KP_Enter)
     {
       gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (combo_box));
       gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (combo_box));
@@ -5730,6 +5882,51 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
     }
 }
 
+
+/**
+ * gtk_combo_box_set_popup_fixed_width:
+ * @combo_box: a #GtkComboBox
+ * @fixed: whether to use a fixed popup width
+ *
+ * Specifies whether the popup's width should be a fixed width
+ * matching the allocated width of the combo box.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
+                                     gboolean     fixed)
+{
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  if (combo_box->priv->popup_fixed_width != fixed)
+    {
+      combo_box->priv->popup_fixed_width = fixed;
+
+      g_object_notify (G_OBJECT (combo_box), "popup-fixed-width");
+    }
+}
+
+/**
+ * gtk_combo_box_get_popup_fixed_width:
+ * @combo_box: a #GtkComboBox
+ *
+ * Gets whether the popup uses a fixed width matching
+ * the allocated width of the combo box.
+ *
+ * Returns: %TRUE if the popup uses a fixed width
+ *
+ * Since: 3.0
+ **/
+gboolean
+gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
+
+  return combo_box->priv->popup_fixed_width;
+}
+
+
 /**
  * gtk_combo_box_get_popup_accessible:
  * @combo_box: a #GtkComboBox
@@ -5739,7 +5936,8 @@ gtk_combo_box_set_title (GtkComboBox *combo_box,
  * This function is mostly intended for use by accessibility technologies;
  * applications should have little use for it.
  *
- * Returns: the accessible object corresponding to the combo box's popup.
+ * Returns: (transfer none): the accessible object corresponding
+ *     to the combo box's popup.
  *
  * Since: 2.6
  */
@@ -5864,6 +6062,81 @@ gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
 }
 
 
+/**
+ * gtk_combo_box_get_has_entry:
+ * @combo_box: a #GtkComboBox
+ *
+ * Returns whether the combo box has an entry.
+ *
+ * Return Value: whether there is an entry in @combo_box.
+ *
+ * Since: 2.24
+ **/
+gboolean
+gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
+
+  return combo_box->priv->has_entry;
+}
+
+/**
+ * gtk_combo_box_set_entry_text_column:
+ * @combo_box: A #GtkComboBox
+ * @text_column: A column in @model to get the strings from for
+ *     the internal entry
+ *
+ * Sets the model column which @combo_box should use to get strings from
+ * to be @text_column. The column @text_column in the model of @combo_box
+ * must be of type %G_TYPE_STRING.
+ *
+ * This is only relevant if @combo_box has been created with
+ * #GtkComboBox:has-entry as %TRUE.
+ *
+ * Since: 2.24
+ */
+void
+gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
+                                    gint         text_column)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeModel *model;
+
+  g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+  model = gtk_combo_box_get_model (combo_box);
+
+  g_return_if_fail (text_column >= 0);
+  g_return_if_fail (model == NULL || text_column < gtk_tree_model_get_n_columns (model));
+
+  priv->text_column = text_column;
+
+  if (priv->text_renderer != NULL)
+    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
+                                    priv->text_renderer,
+                                    "text", text_column,
+                                    NULL);
+}
+
+/**
+ * gtk_combo_box_get_entry_text_column:
+ * @combo_box: A #GtkComboBox.
+ *
+ * Returns the column which @combo_box is using to get the strings
+ * from to display in the internal entry.
+ *
+ * Return value: A column in the data source model of @combo_box.
+ *
+ * Since: 2.24
+ */
+gint
+gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box)
+{
+  g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
+
+  return combo_box->priv->text_column;
+}
+
 /**
  * gtk_combo_box_set_focus_on_click:
  * @combo: a #GtkComboBox
@@ -5949,14 +6222,17 @@ gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
                                            data);
 }
 
-
-static void
-gtk_combo_box_size_request_init (GtkSizeRequestIface *iface)
+static GObject *
+gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
+                                           GtkBuilder   *builder,
+                                           const gchar  *childname)
 {
-  iface->get_width            = gtk_combo_box_get_width;
-  iface->get_height           = gtk_combo_box_get_height;
-  iface->get_height_for_width = gtk_combo_box_get_height_for_width;
-  iface->get_width_for_height = gtk_combo_box_get_width_for_height;
+  GtkComboBox *combo_box = GTK_COMBO_BOX (buildable);
+
+  if (combo_box->priv->has_entry && strcmp (childname, "entry") == 0)
+    return G_OBJECT (gtk_bin_get_child (GTK_BIN (buildable)));
+
+  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
 }
 
 static void
@@ -6007,8 +6283,8 @@ gtk_combo_box_measure_height_for_width (GtkComboBox *combo_box,
 
   child = gtk_bin_get_child (GTK_BIN (combo_box));
 
-  gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child), avail_width,
-                                        &child_min, &child_nat);
+  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))
@@ -6044,9 +6320,9 @@ gtk_combo_box_measure_height_for_width (GtkComboBox *combo_box,
 
 
 static void     
-gtk_combo_box_get_width (GtkSizeRequest      *widget,
-                        gint                *minimum_size,
-                        gint                *natural_size)
+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;
@@ -6063,7 +6339,7 @@ gtk_combo_box_get_width (GtkSizeRequest      *widget,
   child = gtk_bin_get_child (GTK_BIN (widget));
  
   /* common */
-  gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+  gtk_widget_get_preferred_width (child, &child_min, &child_nat);
   gtk_combo_box_remeasure (combo_box);
 
   child_min  = MAX (child_min,  priv->minimum_width);
@@ -6099,8 +6375,8 @@ gtk_combo_box_get_width (GtkSizeRequest      *widget,
          border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
           xthickness   = gtk_widget_get_style (priv->button)->xthickness;
 
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL);
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL);
+          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);
 
@@ -6111,8 +6387,8 @@ gtk_combo_box_get_width (GtkSizeRequest      *widget,
         {
           gint but_width, but_nat_width;
 
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button)
-                                     &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;
@@ -6143,8 +6419,8 @@ gtk_combo_box_get_width (GtkSizeRequest      *widget,
         }
 
       /* the button */
-      gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button)
-                                 &button_width, &button_nat_width);
+      gtk_widget_get_preferred_width (priv->button
+                                      &button_width, &button_nat_width);
 
       minimum_width += button_width;
       natural_width += button_nat_width;
@@ -6166,35 +6442,35 @@ gtk_combo_box_get_width (GtkSizeRequest      *widget,
 }
 
 static void
-gtk_combo_box_get_height (GtkSizeRequest      *widget,
-                         gint                *minimum_size,
-                         gint                *natural_size)
+gtk_combo_box_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum_size,
+                                    gint      *natural_size)
 { 
   gint min_width;
 
   /* Combo box is height-for-width only 
    * (so we always just reserve enough height for the minimum width) */
-  gtk_size_request_get_width (widget, &min_width, NULL);
-  gtk_size_request_get_height_for_width (widget, min_width, minimum_size, natural_size);
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, minimum_size, natural_size);
 }
 
 static void
-gtk_combo_box_get_width_for_height (GtkSizeRequest        *widget,
-                                   gint                   avail_size,
-                                   gint                  *minimum_size,
-                                   gint                  *natural_size)
+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_size_request_get_width (widget, minimum_size, natural_size);
+  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_size, natural_size);
 }
 
 
 static void
-gtk_combo_box_get_height_for_width (GtkSizeRequest        *widget,
-                                   gint                   avail_size,
-                                   gint                  *minimum_size,
-                                   gint                  *natural_size)
+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;
@@ -6229,12 +6505,12 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest        *widget,
           xthickness = button_style->xthickness;
           ythickness = button_style->ythickness;
 
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL);
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL);
-          gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->separator)
-                                                sep_width, &sep_height, NULL);
-          gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->arrow)
-                                                arrow_width, &arrow_height, NULL);
+          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);
@@ -6255,9 +6531,9 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest        *widget,
          /* there is a custom child widget inside (no priv->cell_view) */
           gint but_width, but_height;
 
-          gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button), &but_width, NULL);
-          gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->button)
-                                                but_width, &but_height, NULL);
+          gtk_widget_get_preferred_width (priv->button, &but_width, NULL);
+          gtk_widget_get_preferred_height_for_width (priv->button
+                                                     but_width, &but_height, NULL);
 
          size -= but_width;
 
@@ -6273,9 +6549,9 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest        *widget,
       gint but_width, but_height;
       gint xpad = 0, ypad = 0;
 
-      gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button), &but_width, NULL);
-      gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->button)
-                                            but_width, &but_height, NULL);
+      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)
        {
@@ -6294,7 +6570,7 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest        *widget,
       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);