After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 579989 - Add gtk_combo_box_clear_text function to simple (text) API
Add gtk_combo_box_clear_text function to simple (text) API
Status: RESOLVED DUPLICATE of bug 324899
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-04-23 16:42 UTC by Tadej Borovšak
Modified: 2009-04-28 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tadej Borovšak 2009-04-23 16:42:53 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 --
Comment 1 Tadej Borovšak 2009-04-28 20:28:06 UTC
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 ***