November 19, 2014
On Wed, 19 Nov 2014 13:44:09 +0000
via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

> Ah, right, it _does_ work with explicitly defined constructors. Maybe GValue doesn't have those?
that may be true. i'm too lazy to look at the sources, and it seems
to me that it's very easy to miss the fact that adding explicit
constructors will allow to construct struct with simple assign, so
authors seems to omit such constructors (and adding 'setXXX' functions,
heh ;-).


November 19, 2014
On 11/19/2014 03:50 AM, Sergey wrote:
>      Hello everyone!
>
> I try to use gtkd + d in production, and of course I started with
> gtk.TreeView and gtk.ListStore objects. But I encounter a problem with
> GValyue type:
>
> GValue[] array_values = cast(GValue[])["str1","str2","str3","str4"];
> file_1.d(92): Error: e2ir: cannot cast "str1" of type string to type GValue
> ...
>
> ListStore1.setValuesv(itr, [0,1,2,3], "str1","str2","str3","str4");
> file_1.d(98): Error: function gtk.ListStore.ListStore.setValuesv
> (TreeIter iter, int[] columns, GValue[] values) is not callable using
> argument types (TreeIter, int[], string, string, string, string)
>
> GValue ggg = cast(GValue)"123";
> file_1.d(78): Error: cannot cast from string to GValue
>
> GValue ggg = "123";
> file_1.d(79): Error: cannot implicitly convert expression ("123") of
> type string to GValue
>
> How to deal with this type?
>
> thanks in advance.

If it's really just strings you can use;
ListStore1.setValues(itr, [0,1,2,3], ["str1","str2","str3","str4"]);

Otherwise you'll need to make multiple calls to ListStore.setValue.

For setValuesv there is an error in the generated code it should except an array of gobject.Value, in stead of the the C equivalent.

-- 
Mike Wey
November 20, 2014
Ok, thanks. I'll just use this command:
ListStore1.setValue(itr, 0, "some str");
...
November 20, 2014
auto ggg = GValue("123");
file_12.d(27): Error: cannot implicitly convert expression ("123") of type string to GType


GValue ggg = {"ki",};
file_12.d(22): Error: cannot implicitly convert expression ("ki") of type string to GType
1 2
Next ›   Last »