View previous topic :: View next topic |
Author |
Message |
bkropf
Joined: 28 Oct 2008 Posts: 6
|
Posted: Sat May 02, 2009 9:38 am Post subject: TreeView / ListStore question |
|
|
I'm currently having some trouble with using ListStore with a TreeView (I haven't tried TreeStore yet, but I suspect it will be similar). I'm using current svn of gtkd, tango svn, and gdc 4.1.2 20070214 ( gdc 0.24, using dmd 1.030) on x86_64. When I build the test below I get an empty window with no items displayed. Has anyone gotten TreeVIew & ListStores working properly?
Also of interest:
If I uncomment the lines related to columns, then I get the column headers with two clickable lines in the TreeVIew, but no visible text.
If I uncomment the lines related to adding a second column, then I get a segfault.
Code: |
module treeviewexample;
import gtk.Main;
import gtk.Window;
import gtk.Widget;
import gtk.TreeIter;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.ListStore;
int main(char[][] args) {
Main.init(args);
Window window = new Window("TreeView Example");
TreeView tree = new TreeView();
window.add(tree);
//TreeViewColumn artistColumn = new TreeViewColumn();
//artistColumn.setTitle = "Artist";
//TreeViewColumn songColumn = new TreeViewColumn();
//songColumn.setTitle = "Song Title";
//tree.appendColumn(artistColumn);
//tree.appendColumn(songColumn);
GType[1] types;
types[0] = GType.STRING;
//types[1] = GType.STRING;
ListStore musicListStore = new ListStore(types);
TreeIter iter = musicListStore.createIter();
musicListStore.setValue(iter, 0, "Radiohead");
//musicListStore.setValue(iter, 1, "15 Step");
musicListStore.append(iter);
musicListStore.setValue(iter, 0, "Doors");
//musicListStore.setValue(iter, 1, "Hello I Love You");
tree.setModel(musicListStore);
window.addOnHide(delegate void(Widget w) { Main.exit(0); });
window.showAll;
Main.run();
return 0;
}
|
|
|
Back to top |
|
|
okibi
Joined: 04 Jan 2007 Posts: 170
|
Posted: Sat May 02, 2009 7:00 pm Post subject: |
|
|
Try this:
Code: |
module treeviewexample;
import gtk.Main;
import gtk.Window;
import gtk.Widget;
import gtk.TreeIter;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.ListStore;
import gtk.CellRendererText;
int main(char[][] args) {
Main.init(args);
Window window = new Window("TreeView Example");
TreeView tree = new TreeView();
window.add(tree);
TreeViewColumn artistColumn = new TreeViewColumn();
artistColumn.setTitle = "Artist";
tree.appendColumn(artistColumn);
CellRendererText cell_text = new CellRendererText();
artistColumn.packStart(cell_text, 0);
artistColumn.addAttribute(cell_text, "text", 0);
TreeViewColumn songColumn = new TreeViewColumn();
songColumn.setTitle = "Song Title";
tree.appendColumn(songColumn);
cell_text = new CellRendererText();
songColumn.packStart(cell_text, 0);
songColumn.addAttribute(cell_text, "text", 1);
GType[] types;
types ~= GType.STRING;
types ~= GType.STRING;
ListStore musicListStore = new ListStore(types);
TreeIter iter = musicListStore.createIter();
musicListStore.setValue(iter, 0, "Radiohead");
musicListStore.setValue(iter, 1, "15 Step");
musicListStore.append(iter);
musicListStore.setValue(iter, 0, "Doors");
musicListStore.setValue(iter, 1, "Hello I Love You");
tree.setModel(musicListStore);
window.addOnHide(delegate void(Widget w) { Main.exit(0); });
window.showAll;
Main.run();
return 0;
}
|
|
|
Back to top |
|
|
bkropf
Joined: 28 Oct 2008 Posts: 6
|
Posted: Sat May 02, 2009 9:19 pm Post subject: |
|
|
I actually think the issue is related to 64 bit glib / gtk. When I print the size of a GType from gtkD, I get 4 bytes, but when I print the size of a GType from c++ I get 8 bytes.
Output from my D program:
Code: |
sizeof GType 4
sizeof GType.STRING 4
sizeof pointer 8
|
But from a simple C++ program:
Code: |
sizeof G_TYPE_STRING 8
|
I have also verified that if I add a long as basetype to the GType enum, then things work as expected. I'll try to figure out a way to properly version this for 64 bit and submit a ticket. |
|
Back to top |
|
|
okibi
Joined: 04 Jan 2007 Posts: 170
|
Posted: Sat May 02, 2009 10:20 pm Post subject: |
|
|
Oh, you're right. I thought that issue was fixed awhile back?
I'll look into it tonight/tomorrow morning. Shouldn't be too hard to implement a fix. |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun May 03, 2009 8:08 am Post subject: |
|
|
I changed the basetype of the GType Enum to size_t which should be the correct size on all platforms.
@okibi: I saw the ticket before your post, i hope you didn't start working on a fix already |
|
Back to top |
|
|
okibi
Joined: 04 Jan 2007 Posts: 170
|
Posted: Sun May 03, 2009 10:08 am Post subject: |
|
|
I looked, but wasn't going to do anything until this morning.
Glad to see you already implemented a fix. |
|
Back to top |
|
|
bkropf
Joined: 28 Oct 2008 Posts: 6
|
Posted: Wed May 06, 2009 9:33 pm Post subject: |
|
|
Thanks, it worked great! |
|
Back to top |
|
|
|
|
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
|