All I can figure out is something to do with the ComboBox.GetEnumerator or something like that.
I would like to do something like:
System.Collections
I had a similar problem and this answer in C# was helpful, but the end solution in C looks very different. I'm posting here because it was the first for google searches on it.
Basically if you are looking in a GTK ComboBox and using the GTK Tree Model and you hope to get the information out, you have to use the iter pattern just right. The wrappers for other languages like Python and C# have made it quite a bit easier, but for those still using C with GTK, here is the solution:
Assuming you have a flat gtk combobox and you just need to get something out of it, you can use something like this for c:
int set_combo_box_text(GtkComboBox * box, char * txt)
{
GtkTreeIter iter;
GtkListStore * list_store;
int valid;
int i;
list_store = gtk_combo_box_get_model(box);
// Go through model's list and find the text that matches, then set it active
i = 0;
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(list_store), &iter);
while (valid) {
gchar *item_text;
gtk_tree_model_get (GTK_TREE_MODEL(list_store), &iter, 0, &item_text, -1);
printf("item_text: %s\n", item_text);
if (strcmp(item_text, txt) == 0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(box), i);
return true;
//break;
}
i++;
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list_store), &iter);
}
printf("failed to find the text in the entry list for the combo box\n");
}
If you are storing more information in each combobox line, you can get more info out of the iter using something like this:
valid = gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 0, &item_0, 1, &item_1, 2, &item_2, ... , -1);
Hope that helps.