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

Problem with use of TreeViewColumn::setCellDataFunc

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
lulabad



Joined: 24 Apr 2008
Posts: 7

PostPosted: Sun May 18, 2008 6:14 am    Post subject: Problem with use of TreeViewColumn::setCellDataFunc Reply with quote

I do not know how i can use this function.
Can anyone give me an simple example of usage and how must defined the function GtkTreeCellDataFunc func?
_________________
-----------------------------------------
Sorry for my bad English, im German Wink
Back to top
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Mon May 19, 2008 2:11 pm    Post subject: Reply with quote

I haven't used GtkTreeCellDataFunc or similar functions myself, i tried setting one up in the TestWindow demo.

is this what you're looking for:

Code:
diff -u --strip-trailing-cr gtkD/demos/gtkD/TestWindow.d gtkD/demos/gtkD/TestWindow.d
--- gtkD/demos/gtkD/TestWindow.d   2008-04-28 22:22:09.000000000 +0200
+++ gtkD/demos/gtkD/TestWindow.d   2008-05-18 17:37:59.000000000 +0200
@@ -93,6 +93,7 @@
 private import gtk.TreeIter;
 private import gtk.TreeView;
 private import gtk.TreeViewColumn;
+private import gtk.TreeModel;
 private import gtk.CellRendererText;
 //private import gtk.SListG;
 //private import ddi.Drawable;
@@ -1125,12 +1126,14 @@
       treeView.setRulesHint(true);
 
       //CellRendererText cellText = new CellRendererText();
-      TreeViewColumn column = new TreeViewColumn("Author",new CellRendererText(),"text", 0);
+      auto renderer = new CellRendererText();
+      TreeViewColumn column = new TreeViewColumn("Author", renderer,"text", 0);
       treeView.appendColumn(column);
       column.setResizable(true);
       column.setReorderable(true);
       column.setSortColumnId(0);
       column.setSortIndicator(true);
+      column.setCellDataFunc(renderer, cast(GtkTreeCellDataFunc)&myDataFunc, /*data*/ null , /*DestroyNotify*/ null);
 
       column = new TreeViewColumn("Country",new CellRendererText(),"text", 1);
       treeView.appendColumn(column);
@@ -1154,6 +1157,19 @@
       debug(Tango) Stdout("TestWindow.testList END").newline;
    }
 
+   import tango.io.Stdout;
+
+   extern(C) static void myDataFunc(GtkTreeViewColumn* tree_column, GtkCellRenderer* cell, GtkTreeModel* tree_model, GtkTreeIter* tree_iter, void* data)
+   {
+      //Turn the params into D objects.
+      TreeViewColumn column = new TreeViewColumn(tree_column);
+      CellRenderer renderer = new CellRenderer(cell);
+      TreeModel model       = new TreeModel(tree_model);
+      TreeIter iter         = new TreeIter(tree_iter);
+
+      Stdout("Hello World").newline;
+   }
+   
    void testDelete(Notebook notebook)
    {
 //      ulong l = 0;
Back to top
View user's profile Send private message
lulabad



Joined: 24 Apr 2008
Posts: 7

PostPosted: Mon May 19, 2008 2:33 pm    Post subject: Reply with quote

Mike Wey wrote:
is this what you're looking for:

perfect. p e r f e c t.
this was exactly I'm looking for.
thank you very much
_________________
-----------------------------------------
Sorry for my bad English, im German Wink
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
Page 1 of 1

 
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