From 62c43aac4399f60b41efcbf3c824d5d47dc2a652 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 28 Jul 2015 18:57:48 +0200 Subject: combobox: Create cell view identically ... in the two places it can be created. --- gtk/gtkcombobox.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'gtk/gtkcombobox.c') diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index a079158b2a..3d5545a5b4 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -1522,6 +1522,19 @@ gtk_combo_box_button_toggled (GtkWidget *widget, gtk_combo_box_popdown (combo_box); } +static void +gtk_combo_box_create_cell_view (GtkComboBox *combo_box) +{ + GtkComboBoxPrivate *priv = combo_box->priv; + + priv->cell_view = gtk_cell_view_new_with_context (priv->area, NULL); + gtk_cell_view_set_fit_model (GTK_CELL_VIEW (priv->cell_view), TRUE); + gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model); + gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (combo_box)); + _gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view); + gtk_widget_show (priv->cell_view); +} + static void gtk_combo_box_add (GtkContainer *container, GtkWidget *widget) @@ -1618,16 +1631,7 @@ 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); - - gtk_widget_show (priv->cell_view); - gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), - priv->model); - } - + gtk_combo_box_create_cell_view (combo_box); if (appears_as_list) gtk_combo_box_list_setup (combo_box); @@ -4556,7 +4560,6 @@ gtk_combo_box_format_entry_text (GtkComboBox *combo_box, return text; } - static void gtk_combo_box_constructed (GObject *object) { @@ -4571,12 +4574,7 @@ gtk_combo_box_constructed (GObject *object) g_object_ref_sink (priv->area); } - priv->cell_view = gtk_cell_view_new_with_context (priv->area, NULL); - gtk_cell_view_set_fit_model (GTK_CELL_VIEW (priv->cell_view), TRUE); - gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model); - gtk_widget_set_parent (priv->cell_view, GTK_WIDGET (combo_box)); - _gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view); - gtk_widget_show (priv->cell_view); + gtk_combo_box_create_cell_view (combo_box); gtk_combo_box_check_appearance (combo_box); -- cgit v1.2.1