GNOME Bugzilla – Bug 579989
Add gtk_combo_box_clear_text function to simple (text) API
Last modified: 2009-04-28 20:28:06 UTC
Using simple (text) API functions, there is no easy way of removing all items at once (one has to loop through the items and remove one at a time using gtk_combo_box_remove_text). In order to be useful, I wrote a function for this (I haven't created a patch, since this is a simple task of inserting function in the right spot inside gtkcombobox.c file - the right spot being maintainer dependent - and modifying corresponding header file). -- CODE -- /** * gtk_combo_box_clear_text: * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text() * * Clears all text strings stored in @combo_box. You can only use this * function with combo boxes constructed with gtk_combo_box_new_text(). */ void gtk_combo_box_clear_text (GtkComboBox *combo_box) { GtkListStore *store; g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); /* Is next test needed? */ g_return_if_fail (gtk_tree_model_get_type (combo_box->priv->model, 0) == G_TYPE_STRING); gtk_list_store_clear (GTK_LIST_STORE (combo_box->priv->model)); } -- /CODE --
I just found out that a bug for this already exists in bugzilla (324899), so I'm marking this bug as duplicate of it. I'm sorry for spamming. *** This bug has been marked as a duplicate of 324899 ***