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:
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.
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: CSharp, General, Mono, Programacion, SoftwareLibre
Comments:
<< Home
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.
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
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.
<< Home