View previous topic :: View next topic |
Author |
Message |
eldar
Joined: 14 Jun 2008 Posts: 101 Location: Ufa, Russia
|
Posted: Thu Aug 21, 2008 8:09 am Post subject: |
|
|
Sorry for my inatention. But I found another usage of C-pointers in CustomList.d demo file:
Code: |
int* indices;
int n, depth;
indices = path.getIndices();
depth = path.getDepth();
/* we do not allow children */
if (depth != 1)
return false;//throw new Exception("We only except lists");
n = indices[0]; /* the n-th top level row */
|
Here is used getIndices method which returns C-array: int* indices;
In gtk# it is done as a property of TreeIter class which is native C# array of ints.
Code: |
public int [] Indices {
get {
IntPtr ptr = gtk_tree_path_get_indices(Handle);
int [] arr = new int [Depth];
Marshal.Copy (ptr, arr, 0, Depth);
return arr;
}
}
|
We can make similar property in D, which will convert C-array to D-array, so the client-side code will be a bit more beautiful) |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Thu Aug 21, 2008 12:29 pm Post subject: |
|
|
I missed that one.
getIndices isn't wrapped correctly yet. like other functions with arrays, out and ref parameters. Some of the functions are added manually to bypass the wrapper witch could be done for this function.
Getting the wrapper to handle these cases correctly is on the todo list though. |
|
Back to top |
|
|
eldar
Joined: 14 Jun 2008 Posts: 101 Location: Ufa, Russia
|
Posted: Tue Sep 02, 2008 5:07 am Post subject: |
|
|
Mike Wey
Since you are now working on wrapping, I suggest wrap the GtkTreeIter structure fields directly in TreeIter class to avoid constructions like:
iter.getTreeIterStruct().userData
It could be something like this:
http://www.everfall.com/paste/id.php?ybdsfiq33ipq |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Wed Sep 03, 2008 3:26 pm Post subject: |
|
|
getIndices is wrapped correctly in svn r602, i'll look into the properties for the TreeIter. |
|
Back to top |
|
|
eldar
Joined: 14 Jun 2008 Posts: 101 Location: Ufa, Russia
|
Posted: Thu Sep 04, 2008 1:06 pm Post subject: |
|
|
Ok, that would be cool)
Thank you again for such a great work you are doing! I really love using gtkd) |
|
Back to top |
|
|
eldar
Joined: 14 Jun 2008 Posts: 101 Location: Ufa, Russia
|
Posted: Tue Oct 07, 2008 1:41 pm Post subject: |
|
|
Mike Wey
So what did you decide about wrapping TreeIterStruct fields? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Tue Oct 07, 2008 3:31 pm Post subject: |
|
|
I think i will add some simple properties before the next release. |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Mon Apr 20, 2009 3:57 pm Post subject: |
|
|
I extended this with simple boxing functionality in svn r673.
treeIter.setUserData(20);
int data = treeIter.getUserData!(int)(); |
|
Back to top |
|
|
|