lua-users home
lua-l archive

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


Thomas Harning <harningt@gmail.com> writes:
>> require "alien"
>> local gtk,p,i=alien.load("gtk-x11-2.0"),"pointer","int"
>> gtk.gtk_init:types(nil,p,p)
>> gtk.gtk_message_dialog_new:types(p,p,i,i,i,p)
>> gtk.gtk_dialog_run:types(i,p)
>> gtk.gtk_init(nil,nil)
>> gtk.gtk_dialog_run(
>>   gtk.gtk_message_dialog_new(nil,0,0,1,"Alien Rocks!"))
>
> Awesome!  This may be be a better hook for what LuaGTK/GTKLua (whatever
> it was) wanted to be...

Lua-gtk presents a much cleaner Lua interface (and quite likely more
efficient too) than a "raw" translation by alien of the underlying C
interface, because it uses knowledge of the way the gtk C interface is
designed.  I guess it's perhaps closer in spirit to gtkmm than basic gtk.

I mean no insult against alien -- it looks like a great package -- but
obviously it is going to present more generic view of a C interface than
a package specifically targetting that interface.

Because there's obviously a lot of overlap (e.g. they both use libffi),
maybe there's room for code-sharing or refactorization (e.g., maybe
lua-gtk could use alien in some way).

> I've always had problems with it and I bet it was due to the same
> issue that alien encountered on AMD64....

Have you tried recent versions of it?  It works very well these days.

Sorry to sound so strident, but lua-gtk is a very impressive project,
so I don't want to see others put off by misinformation about it.

Here's the lua-gtk version, btw:

   local gtk = require 'gtk'
   gtk.gtk_message_dialog_new (nil,
                               gtk.GTK_DIALOG_MODAL,
                               gtk.GTK_MESSAGE_INFO,
                               gtk.GTK_BUTTONS_OK,
                               "Lua-gtk Rocks!"):run ()

-Miles

-- 
Happiness, n. An agreeable sensation arising from contemplating the misery of
another.