Jump to page: 1 2
Thread overview
GtkD: Best way to get TreeStore out of TreeView.Model
Jun 11, 2013
Alex Horvat
Jun 11, 2013
Mike Wey
Jun 11, 2013
Alex Horvat
Jun 12, 2013
Mike Wey
Jun 13, 2013
Alex Horvat
Jun 16, 2013
Mike Wey
Jun 17, 2013
Alex Horvat
Jun 17, 2013
Mike Wey
Jun 17, 2013
Alex Horvat
Jun 18, 2013
Alex Horvat
Jun 19, 2013
Mike Wey
Jun 20, 2013
Alex Horvat
Jun 20, 2013
Mike Wey
Jun 21, 2013
Alex Horvat
June 11, 2013
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
June 11, 2013
On 06/11/2013 05:56 PM, Alex Horvat wrote:
> TreeStore store = cast(TreeStore)tvTreeView.getModel();
> In this case store == null

I think that one should work, how are you setting/creating the TreeStore?

-- 
Mike Wey
June 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:
>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>> In this case store == null
>
> I think that one should work, how are you setting/creating the TreeStore?

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);
}
June 12, 2013
On 06/11/2013 07:55 PM, Alex Horvat wrote:
> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>> In this case store == null
>>
>> I think that one should work, how are you setting/creating the TreeStore?

getModel returns an interface, so try the following:

TreeStore store = cast(TreeStore)cast(void*)tv.getModel();

-- 
Mike Wey
June 13, 2013
On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
> On 06/11/2013 07:55 PM, Alex Horvat wrote:
>> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>>> In this case store == null
>>>
>>> I think that one should work, how are you setting/creating the TreeStore?
>
> getModel returns an interface, so try the following:
>
> TreeStore store = cast(TreeStore)cast(void*)tv.getModel();

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.
June 16, 2013
On 06/13/2013 06:14 AM, Alex Horvat wrote:
> On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
>> On 06/11/2013 07:55 PM, Alex Horvat wrote:
>>> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>>>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>>>> In this case store == null
>>>>
>>>> I think that one should work, how are you setting/creating the
>>>> TreeStore?
>>
>> getModel returns an interface, so try the following:
>>
>> TreeStore store = cast(TreeStore)cast(void*)tv.getModel();
>
> 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.

Could you try again with the latest git?

https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bdd

-- 
Mike Wey
June 17, 2013
On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:
> On 06/13/2013 06:14 AM, Alex Horvat wrote:
>> On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
>>> On 06/11/2013 07:55 PM, Alex Horvat wrote:
>>>> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>>>>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>>>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>>>>> In this case store == null
>>>>>
>>>>> I think that one should work, how are you setting/creating the
>>>>> TreeStore?
>>>
>>> getModel returns an interface, so try the following:
>>>
>>> TreeStore store = cast(TreeStore)cast(void*)tv.getModel();
>>
>> 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.
>
> Could you try again with the latest git?
>
> https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bdd

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?
June 17, 2013
On 06/17/2013 04:44 AM, Alex Horvat wrote:
> On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:
>> On 06/13/2013 06:14 AM, Alex Horvat wrote:
>>> On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
>>>> On 06/11/2013 07:55 PM, Alex Horvat wrote:
>>>>> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>>>>>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>>>>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>>>>>> In this case store == null
>>>>>>
>>>>>> I think that one should work, how are you setting/creating the
>>>>>> TreeStore?
>>>>
>>>> getModel returns an interface, so try the following:
>>>>
>>>> TreeStore store = cast(TreeStore)cast(void*)tv.getModel();
>>>
>>> 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.
>>
>> Could you try again with the latest git?
>>
>> https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bdd
>>
>
> 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?

What OS are you using and which compiler?

-- 
Mike Wey
June 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:
>> On Sunday, 16 June 2013 at 18:22:47 UTC, Mike Wey wrote:
>>> On 06/13/2013 06:14 AM, Alex Horvat wrote:
>>>> On Wednesday, 12 June 2013 at 21:44:55 UTC, Mike Wey wrote:
>>>>> On 06/11/2013 07:55 PM, Alex Horvat wrote:
>>>>>> On Tuesday, 11 June 2013 at 17:41:59 UTC, Mike Wey wrote:
>>>>>>> On 06/11/2013 05:56 PM, Alex Horvat wrote:
>>>>>>>> TreeStore store = cast(TreeStore)tvTreeView.getModel();
>>>>>>>> In this case store == null
>>>>>>>
>>>>>>> I think that one should work, how are you setting/creating the
>>>>>>> TreeStore?
>>>>>
>>>>> getModel returns an interface, so try the following:
>>>>>
>>>>> TreeStore store = cast(TreeStore)cast(void*)tv.getModel();
>>>>
>>>> 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.
>>>
>>> Could you try again with the latest git?
>>>
>>> https://github.com/gtkd-developers/GtkD/commit/ab664087b9d354f9cae7e11c17f0b7125dcf8bdd
>>>
>>
>> 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?
>
> What OS are you using and which compiler?

Linux (Fedora) 64bit, DMD 2.063.1
June 18, 2013
Just upgraded to dmd 2.063.2 - no difference
« First   ‹ Prev
1 2