Disclaimer: This is a personal web page. Contents written here do not represent the position of my employer.

Tuesday, June 10, 2008

 

WTF

How can I clear the list of elements of a Gtk.ComboBox??? It doesn't seem to be a way, but maybe if I'm able to get the number of elements... After an hour searching, when I was going to give up, I just found this:


combo_box =
GTK_COMBO_BOX (NAUTILUS_NAVIGATION_WINDOW (window)->view_as_combo_box);
/* Clear the contents of ComboBox in a wacky way because there
* is no function to clear all items and also no function to obtain
* the number of items in a combobox.
*/
model = gtk_combo_box_get_model (combo_box);
g_return_if_fail (GTK_IS_LIST_STORE (model));
store = GTK_LIST_STORE (model);
gtk_list_store_clear (store);


Clearly, we need some improvements in Gtk+ API. I'd bet it's much easier with MWF unfortunately. At least, the developer that coded this was kind enough to file a bug, which BTW is 3 years old and, of course, still not fixed.

Labels: , , , ,


Comments:
gint rows;
rows = gtk_tree_model_iter_n_children (store, NULL);

should work. Check out http://library.gnome.org/devel/gtk/unstable/GtkTreeModel.html#gtk-tree-model-iter-n-children.
 
I use Gtk# (Mono) not Gtk in C. But Holly Widgets available on Google code make all this much nicer; they do a better job of hiding the treeview guts of the various Gtk list oriented widgets.
 
Brad: thanks, but what I really needed was to clear the elements (I've changed this in the blog entry). And anyway, there should be direct API for this, without the need of casting.

Whitemice: Well, I'm using Mono too, but for looking at the API it's better to see C examples.

Regards and thanks for your comments.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?

Categories

RSS of the category Gnome
RSS of the category Mono
RSS of the category C#
RSS of the category Programming
RSS of the category Mozilla
RSS of the category Web Development
RSS of the category Security
RSS of the category Open Source
RSS of the category Engineering
RSS of the category Misc
RSS of the category Politics

Contact with me:
aaragonesNOSPAMes@gnNOSPAMome.org

Archive
My Photo
Name:
Location: Hong Kong, Hong Kong
Follow me on Twitter