mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 06:10:21 +00:00
Don't add a second cell renderer
When has-entry is TRUE, GtkComboBox already adds a cell renderer for the text column, so avoid adding a second one in GtkComboBoxText. https://bugzilla.gnome.org/show_bug.cgi?id=632381
This commit is contained in:
parent
8d456e3c50
commit
b613cc6478
@ -43,28 +43,50 @@
|
|||||||
|
|
||||||
G_DEFINE_TYPE (GtkComboBoxText, gtk_combo_box_text, GTK_TYPE_COMBO_BOX);
|
G_DEFINE_TYPE (GtkComboBoxText, gtk_combo_box_text, GTK_TYPE_COMBO_BOX);
|
||||||
|
|
||||||
static void
|
static GObject *
|
||||||
gtk_combo_box_text_class_init (GtkComboBoxTextClass *klass)
|
gtk_combo_box_text_constructor (GType type,
|
||||||
|
guint n_construct_properties,
|
||||||
|
GObjectConstructParam *construct_properties)
|
||||||
{
|
{
|
||||||
|
GObject *object;
|
||||||
|
|
||||||
|
object = G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructor
|
||||||
|
(type, n_construct_properties, construct_properties);
|
||||||
|
|
||||||
|
if (!gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)))
|
||||||
|
{
|
||||||
|
GtkCellRenderer *cell;
|
||||||
|
|
||||||
|
cell = gtk_cell_renderer_text_new ();
|
||||||
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell, TRUE);
|
||||||
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell,
|
||||||
|
"text", 0,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_combo_box_text_init (GtkComboBoxText *combo_box)
|
gtk_combo_box_text_init (GtkComboBoxText *combo_box)
|
||||||
{
|
{
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkCellRenderer *cell;
|
|
||||||
|
|
||||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
|
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
|
||||||
g_object_unref (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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_combo_box_text_class_init (GtkComboBoxTextClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
|
|
||||||
|
object_class = (GObjectClass *)klass;
|
||||||
|
object_class->constructor = gtk_combo_box_text_constructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_combo_box_text_new:
|
* gtk_combo_box_text_new:
|
||||||
*
|
*
|
||||||
@ -83,7 +105,6 @@ gtk_combo_box_text_new (void)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_combo_box_text_new_with_entry:
|
* gtk_combo_box_text_new_with_entry:
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user