[Java-gnome-developer] RE: TreeView & TreeStore and Listeners
Brought to you by:
afcowie
From: Jeff L. <jef...@ho...> - 2004-02-03 18:00:52
|
The getSelected( ) method is not implemented as you would expect. It maps to the ...is_selected( ) call in C. There is a forEach( ) mechanism that allows you to iterate over the selected rows in a TreeSelection. Mark Howard uses it in http://www.tildemh.com/sw/debbuggtk/index.shtml I think there should be an isSelected( ) mapped to ...is_selected and a getSelected( ) mapped to ...get_selected( ). I modified TreeSelection to do this, and it seemed to work. I did not try to pass back the model, as ...get_selected( ) does. There is no reverse mapping from the C GtkTreeModel handle to the Java TreeModel. Looks like this is a problem elsewhere, too. For instance, a call to Container.getChildren( ) returns a list of Widgets. New, generic Widgets. I can't do much with them because they can not be downcast to their actual types. Is there a global mapping from handle back to Widget? Couldn't find one, but it seems like this is the only real answer to wrapping API calls that return widgets. Something like (not complete): GObject.java... public GObject(int handle) { this.handle = handle; revMap.put( new Integer( handle ), this ); } Container.java... public Widget[] getChildren() { int[] hndls = gtk_container_get_children(handle); if (null == hndls) return null; Widget[] widgets = new Widget[hndls.length]; for (int i = 0; i < hndls.length; i++) { widgets[i] = (Widget)revMap( new Integer( hndls[i] ); } return widgets; } - Jeff _________________________________________________________________ Find high-speed net deals comparison-shop your local providers here. https://broadband.msn.com |