lua-users home
lua-l archive

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

On Fri, Feb 11, 2011 at 11:57 PM, Miles Bader <> wrote:
> Lucas <> writes:
>> As Iñigo Serna already pointed, lgob maintains the original GTK+ API
>> where possible. The main differences are published in is tiny
>> documentation [1]. There are more than 70 examples in the bundle,
>> covering many parts of the API.
> Does it provide the _exact_ GTK+ C API, or does it do "obvious"
> cleanups, removing redundancies/warts which are only necessary because
> of the C API's implementation in C?
> lua-gtk does the latter, basically a "thin" cleanup of the C interface
> (which I think is largely done automatically); the result is very
> similar to gtkmm (so I actually learned lua-gtk by reading docs and
> examples written for gtkmm!).
> For instance in "raw" GTK+, you might say:
>   gtk_range_set_increments (GTK_RANGE (thing), 1, 1)
> but in lua-gtk, you do:
>   thing:set_increments (1, 1)
> [The redundant prefix is removed from the method name, and of course the
> superclass cast is automatic.]
> I really like this "cleaned up" interface; it's still very close to
> GTK+'s C interface (so one can use the same docs, applying the obvious
> transformations in one's head), but more pleasant to use.
> Thanks,
> -Miles
> --
> Cat, n. A soft, indestructible automaton provided by nature to be kicked when
> things go wrong in the domestic circle.

It provides a 'nice' API, with the changes that you've mentioned, like

label ="My label")
label:set_text("new label")

It also provides other nice things, like GError handling and callbacks
with the userdata as first parameter to allow simplified usage of
member functions, automatic memory management and etc, all that you
would expect for a Lua library.