* The entry itself can be accessed by calling gtk_bin_get_child() on the
* combo box.
*
+ * You should not call gtk_combo_box_set_model() or attempt to pack more cells
+ * into this combo box via its GtkCellLayout interface.
+ *
* <refsect2 id="GtkComboBoxText-BUILDER-UI">
* <title>GtkComboBoxText as GtkBuildable</title>
* <para>
* The GtkComboBoxText implementation of the GtkBuildable interface
- * supports adding items directly using the <items> element
- * and specifying <item> elements for each item. Each <item>
+ * supports adding items directly using the <items> element
+ * and specifying <item> elements for each item. Each <item>
* element supports the regular translation attributes "translatable",
* "context" and "comments".
*
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
- GObject *object;
+ GObject *object;
+ const gint text_column = 0;
object = G_OBJECT_CLASS (gtk_combo_box_text_parent_class)->constructor
(type, n_construct_properties, construct_properties);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object), text_column);
+ gtk_combo_box_set_id_column (GTK_COMBO_BOX (object), 1);
+
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,
+ "text", text_column,
NULL);
}
GtkBuilder *builder;
GObject *object;
const gchar *domain;
+ gchar *id;
GString *string;
}
else if (strcmp (names[i], "context") == 0)
data->context = g_strdup (values[i]);
+ else if (strcmp (names[i], "id") == 0)
+ data->id = g_strdup (values[i]);
else
g_warning ("Unknown custom combo box item attribute: %s", names[i]);
}
g_string_append (data->string, translated);
}
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (data->object), data->string->str);
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (data->object), data->id, data->string->str);
}
data->translatable = FALSE;
g_string_set_size (data->string, 0);
g_free (data->context);
data->context = NULL;
+ g_free (data->id);
+ data->id = NULL;
data->is_text = FALSE;
}
* gtk_combo_box_text_new:
*
* Creates a new #GtkComboBoxText, which is a #GtkComboBox just displaying
- * strings. See gtk_combo_box_entry_new_with_text().
+ * strings.
*
* Return value: A new #GtkComboBoxText
*
gtk_combo_box_text_new (void)
{
return g_object_new (GTK_TYPE_COMBO_BOX_TEXT,
- "entry-text-column", 0,
- "id-column", 1,
NULL);
}
{
return g_object_new (GTK_TYPE_COMBO_BOX_TEXT,
"has-entry", TRUE,
- "entry-text-column", 0,
- "id-column", 1,
NULL);
}
*
* Inserts @text at @position in the list of strings stored in @combo_box.
* If @id is non-%NULL then it is used as the ID of the row. See
- * #GtkComboBox::id-column.
+ * #GtkComboBox:id-column.
*
* If @position is negative then @text is appended.
*
* function will return its contents (which will not necessarily
* be an item from the list).
*
- * Returns: a newly allocated string containing the currently
- * active text. Must be freed with g_free().
+ * Returns: (transfer full): a newly allocated string containing the
+ * currently active text. Must be freed with g_free().
*
* Since: 2.24
*/