On Fri, Apr 1, 2011 at 18:43, Canol Gokel <
[hidden email]> wrote:
> Hello,
>
> #setAuthors: accepts an array of strings. How can I use this method in GST? I tried:
>
> myAboutDialog setAuthors: {'ergre', 'efwee'}.
The array syntax is wrong. You need a period rather than a comma, or
alternatively #('ergre' 'efwee').
Unfortunately this is not enough. You need something like this:
Array extend [
Array >> withPointersDo: aBlock [
| p |
"Allocate p as a char**."
p := (CPtrCType elementType: CCharType) gcNew: self size + 1.
(0 to: self size - 1) with: self do: [ :i :s |
p at: i put: s asCData ].
aBlock value: p.
"Free the items of the array, gtk_about_dialog_set_authors copies it."
(0 to: self size - 1) do: [ :i | (p at: i) free ].
]
]
and then
#('ergre' 'efwee') withPointersDo: [ :p | aboutDialog setAuthors: p ]
Note I use a char** without using CString. CString's "magic" would
eliminate the need to send #asCData; however, it would get in the way
when freeing, where you would need a cast to get the raw pointer
values.
This will be fixed by the GIR bindings. (The code above is untested).
Paolo
_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk