FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Implementing custom tree model for TreeView using TreeModel.
Goto page Previous  1, 2
 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
eldar



Joined: 14 Jun 2008
Posts: 101
Location: Ufa, Russia

PostPosted: Thu Aug 21, 2008 8:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Thu Aug 21, 2008 12:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
eldar



Joined: 14 Jun 2008
Posts: 101
Location: Ufa, Russia

PostPosted: Tue Sep 02, 2008 5:07 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Wed Sep 03, 2008 3:26 pm    Post subject: Reply with quote

getIndices is wrapped correctly in svn r602, i'll look into the properties for the TreeIter.
Back to top
View user's profile Send private message
eldar



Joined: 14 Jun 2008
Posts: 101
Location: Ufa, Russia

PostPosted: Thu Sep 04, 2008 1:06 pm    Post subject: Reply with quote

Ok, that would be cool)
Thank you again for such a great work you are doing! I really love using gtkd)
Back to top
View user's profile Send private message
eldar



Joined: 14 Jun 2008
Posts: 101
Location: Ufa, Russia

PostPosted: Tue Oct 07, 2008 1:41 pm    Post subject: Reply with quote

Mike Wey
So what did you decide about wrapping TreeIterStruct fields?
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Tue Oct 07, 2008 3:31 pm    Post subject: Reply with quote

I think i will add some simple properties before the next release.
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon Apr 20, 2009 3:57 pm    Post subject: Reply with quote

I extended this with simple boxing functionality in svn r673.

treeIter.setUserData(20);
int data = treeIter.getUserData!(int)();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group