digitalmars.D.learn - GtkD: Best way to get TreeStore out of TreeView.Model
- Alex Horvat (24/24) Jun 11 2013 I'm trying to get a TreeStore object back out of a TreeView in
- Mike Wey (4/6) Jun 11 2013 I think that one should work, how are you setting/creating the TreeStore...
- Alex Horvat (9/14) Jun 11 2013 tvTreeView.setModel(CreateModel());
- Mike Wey (5/11) Jun 12 2013 getModel returns an interface, so try the following:
- Alex Horvat (6/16) Jun 12 2013 Thanks
- Mike Wey (5/23) Jun 16 2013 Could you try again with the latest git?
- Alex Horvat (9/33) Jun 16 2013 OK, I pulled the changes and rebuilt gtkd but the error is still
- Mike Wey (4/38) Jun 17 2013 What OS are you using and which compiler?
- Alex Horvat (2/46) Jun 17 2013 Linux (Fedora) 64bit, DMD 2.063.1
- Alex Horvat (1/1) Jun 17 2013 Just upgraded to dmd 2.063.2 - no difference
- Mike Wey (6/30) Jun 19 2013 I seem to have missed a few cases in the last commit, would you mind
- Alex Horvat (1/4) Jun 19 2013 Sorry, no changes - still getting the same errors as before.
- Mike Wey (19/26) Jun 20 2013 Does this code run successfully for you?
- Alex Horvat (5/31) Jun 20 2013 Yes, and I did writeln(store) and the result was a treestore so
I'm trying to get a TreeStore object back out of a TreeView in GtkD. The reason for this is so that I can change the value of a cell in the TreeView - in this case changing one image for another. I can't use a TreeModel for this as it does not have a setValue function. I've got this working with the following code: private bool tvTreeView_ButtonRelease(Event e, Widget sender) { TreeIter selectedItem = tvTreeView.getSelectedIter(); TreeStore store = new TreeStore(cast(GtkTreeStore*)selectedItem.gtkTreeModel); store.setValue(selectedItem, 2, newPixbuf); } But this seems like a really ugly way to do this, I'm sure I'm missing something. I've also tried: TreeStore store = ObjectG.getDObject!(TreeStore)(cast(GtkTreeStore*)selectedItem.gtkTreeModel); This creates a TreeModel not a TreeStore TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == null Does anyone know a better way of doing this? Or is this something missing from GtkD? Thanks
Jun 11 2013
On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore? -- Mike Wey
Jun 11 2013
On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:On 06/11/2013 05:56 PM, Alex Horvat wrote:tvTreeView.setModel(CreateModel()); private TreeStore CreateModel() { TreeStore treeStore = new TreeStore([GType.STRING, GType.STRING, Pixbuf.getType()]); Values a filled recursively using treeStore.setValue(iter, column, value); }TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 11 2013
On 06/11/2013 07:55 PM, Alex Horvat wrote:On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel(); -- Mike WeyOn 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 12 2013
On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:On 06/11/2013 07:55 PM, Alex Horvat wrote:Thanks Ok, just tried this and after setting store if I call writeln(store) the output is what looks like a memory dump, definitly something wrong there. And the program crashes if I try to use store.On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel();On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 12 2013
On 06/13/2013 06:14 AM, Alex Horvat wrote:On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:Could you try again with the latest git? https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bdd -- Mike WeyOn 06/11/2013 07:55 PM, Alex Horvat wrote:Thanks Ok, just tried this and after setting store if I call writeln(store) the output is what looks like a memory dump, definitly something wrong there. And the program crashes if I try to use store.On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel();On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 16 2013
On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:On 06/13/2013 06:14 AM, Alex Horvat wrote:OK, I pulled the changes and rebuilt gtkd but the error is still the same. I tried all the variations in code listed in my first post, plus the one you suggested with the double cast, but everything failed in the same ways as before. On the plus side, nothing new broke - it still works with the work-around way I've got. Is there any more info I can supply that would help you?On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:Could you try again with the latest git? https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bddOn 06/11/2013 07:55 PM, Alex Horvat wrote:Thanks Ok, just tried this and after setting store if I call writeln(store) the output is what looks like a memory dump, definitly something wrong there. And the program crashes if I try to use store.On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel();On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 16 2013
On 06/17/2013 04:44 AM, Alex Horvat wrote:On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:What OS are you using and which compiler? -- Mike WeyOn 06/13/2013 06:14 AM, Alex Horvat wrote:OK, I pulled the changes and rebuilt gtkd but the error is still the same. I tried all the variations in code listed in my first post, plus the one you suggested with the double cast, but everything failed in the same ways as before. On the plus side, nothing new broke - it still works with the work-around way I've got. Is there any more info I can supply that would help you?On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:Could you try again with the latest git? https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bddOn 06/11/2013 07:55 PM, Alex Horvat wrote:Thanks Ok, just tried this and after setting store if I call writeln(store) the output is what looks like a memory dump, definitly something wrong there. And the program crashes if I try to use store.On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel();On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 17 2013
On Monday, 17 June 2013 at 17:52:38 UTC, Mike Wey wrote:On 06/17/2013 04:44 AM, Alex Horvat wrote:Linux (Fedora) 64bit, DMD 2.063.1On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:What OS are you using and which compiler?On 06/13/2013 06:14 AM, Alex Horvat wrote:OK, I pulled the changes and rebuilt gtkd but the error is still the same. I tried all the variations in code listed in my first post, plus the one you suggested with the double cast, but everything failed in the same ways as before. On the plus side, nothing new broke - it still works with the work-around way I've got. Is there any more info I can supply that would help you?On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:Could you try again with the latest git? https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bddOn 06/11/2013 07:55 PM, Alex Horvat wrote:Thanks Ok, just tried this and after setting store if I call writeln(store) the output is what looks like a memory dump, definitly something wrong there. And the program crashes if I try to use store.On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:getModel returns an interface, so try the following: TreeStore store = cast(TreeStore)cast(void*)tv.getModel();On 06/11/2013 05:56 PM, Alex Horvat wrote:TreeStore store = cast(TreeStore)tvTreeView.getModel(); In this case store == nullI think that one should work, how are you setting/creating the TreeStore?
Jun 17 2013
On 06/17/2013 09:32 PM, Alex Horvat wrote:On Monday, 17 June 2013 at 17:52:38 UTC, Mike Wey wrote:I seem to have missed a few cases in the last commit, would you mind trying again? https://github.com/gtkd-developers/GtkD/commit/7e95380bbb4f569c95fc9435711e1f2ec73122fe -- Mike WeyOn 06/17/2013 04:44 AM, Alex Horvat wrote:Linux (Fedora) 64bit, DMD 2.063.1On Sunday, 16 June 2013 at 18:22:47 UTC, MiWhat OS are you using and which compiler?Could you try again with the latest git? https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bddOK, I pulled the changes and rebuilt gtkd but the error is still the same. I tried all the variations in code listed in my first post, plus the one you suggested with the double cast, but everything failed in the same ways as before. On the plus side, nothing new broke - it still works with the work-around way I've got. Is there any more info I can supply that would help you?
Jun 19 2013
I seem to have missed a few cases in the last commit, would you mind trying again? https://github.com/gtkd-developers/GtkD/commit/7e95380bbb4f569c95fc9435711e1f2ec73122feSorry, no changes - still getting the same errors as before.
Jun 19 2013
On 06/20/2013 07:53 AM, Alex Horvat wrote:Does this code run successfully for you? ---- import gtk.Main; import gtk.TreeStore; import gtk.TreeView; void main(string[] args) { Main.init(args); TreeStore ts = new TreeStore([GType.STRING, GType.STRING]); TreeView tv = new TreeView(); tv.setModel(ts); TreeStore store = cast(TreeStore)tv.getModel(); assert(store !is null); store.getNColumns(); } ---- -- Mike WeyI seem to have missed a few cases in the last commit, would you mind trying again? https://github.com/gtkd-developers/GtkD/commit/7e95380bbb4f569c95fc9435711e1f2ec73122feSorry, no changes - still getting the same errors as before.
Jun 20 2013
On Thursday, 20 June 2013 at 17:44:18 UTC, Mike Wey wrote:On 06/20/2013 07:53 AM, Alex Horvat wrote:Yes, and I did writeln(store) and the result was a treestore so this code works fine. Yet still my code doesn't work even though it's effectively doing the same thing, kind of weird.Does this code run successfully for you? ---- import gtk.Main; import gtk.TreeStore; import gtk.TreeView; void main(string[] args) { Main.init(args); TreeStore ts = new TreeStore([GType.STRING, GType.STRING]); TreeView tv = new TreeView(); tv.setModel(ts); TreeStore store = cast(TreeStore)tv.getModel(); assert(store !is null); store.getNColumns(); } ----I seem to have missed a few cases in the last commit, would you mind trying again? https://github.com/gtkd-developers/GtkD/commit/7e95380bbb4f569c95fc9435711e1f2ec73122feSorry, no changes - still getting the same errors as before.
Jun 20 2013