help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] How to set authors for a GTK about dialog


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] How to set authors for a GTK about dialog
Date: Sun, 3 Apr 2011 15:32:42 +0200

On Fri, Apr 1, 2011 at 18:43, Canol Gokel <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]