Re: gtk_combo_box_new_text() API



On Tue, 2011-02-22 at 08:51 -0700, Kevin DeKorte wrote:

On 02/22/2011 08:46 AM, Allin Cottrell wrote:

It seems that you are in fact OK using the GtkComboBox API for
this purpose, as in

void depopulate_combo_box (GtkComboBox *box)
{
    GtkTreeModel *model = gtk_combo_box_get_model(box);
    GtkTreeIter iter;

    while (gtk_tree_model_get_iter_first(model, &iter)) {
        gtk_combo_box_remove_text(box, 0);
    }
}

Allin Cottrell
_______________________________________________

If your going to use the model, then perhaps this will work...

gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box))));

Yes, I can do that. But I think it's a bug in the API if I have to rely
on a specific implementation of an API function to do something that
simple. Why isn't there a funtion like 

guint gtk_combo_box_text_num_elements()

which returns the number of the remaining elements in the list? Because
as of now it would be perfectly legal to _not_ use a GtkTreeModel to
store list entries in case the ComboBox was created with the _text_
convenience functions.
Or the API specs should say that a combo box created with the
convenience functions will always result in normal combo box with a
GtkTreeModel and thus all functions are usable.

Regards,
Timo


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]