LGI is gobject-introspection based dynamic Lua binding to GObject based libraries. It allows using GObject-based libraries directly from Lua.
Licensed under MIT-style license, see LICENSE file for full text.
Home of the project is on GitHub.
LGI is tested and compatible with standard Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT2. Compatibility with other Lua implementations is not tested yet. Lua 5.4 is only supported experimentally.
If you need to support pre-gobject-introspection GTK (ancient GTK+ 2.x releases), use Lua-Gnome.
In order to be able to compile native part of lgi,
gobject-introspection >= 0.10.8 development package must be installed,
although preferred version is >= 1.30. The development package is
libgirepository1.0-dev on debian-based systems (like Ubuntu)
gobject-introspection-devel on RedHat-based systems (like Fedora).
luarocks install lgi
Alternatively, use make-based installation:
make [sudo] make install [PREFIX=<prefix>] [DESTDIR=<destdir>]
Please note that on BSD-systems you may need to use 'gmake'.
Building via Meson is also supported, with the same requirements, plus a Meson installation along with the Ninja build tool, in an empty build directory:
cd $(builddir) meson $(lgi_srcroot) [--prefix=<prefix>] [--buildtype=<buildtype>] [--pkg-config-path=<pkgconfigpath>] [-Dlua-pc=...] [-Dlua-bin=...] ninja ninja test [sudo] ninja install
Building lgi with Visual Studio 2013 and later is also supported via
Meson. It is recommended in this case that CMake is also installed to
make finding Lua or LuaJIT easier, since Lua and LuaJIT support Visual
Studio builds via batch files or manual compilation of sources. Ensure
%INCLUDE% includes the path to the Lua or LuaJIT headers, and
%LIB% includes the path where the
lua5x.lib from Lua or LuaJIT can be
found, and ensure that
luajit.exe can be
%PATH% and run correctly. For building with LuaJIT, please do
not pass in
-Dlua-pc=luajit, but do pass in
-Dlua-bin=luajit in the
Meson command line so that the LuaJIT interpreter can be found correctly.
See examples in
samples/ directory. Documentation is available in
doc/ directory in markdown format. Process it with your favorite
Markdown processor if you want to read it in HTML. You can also check
the moonsteal/lua-gtk-examples repository, where you can find a variety
of Lua Gtk examples.
List of contributors, in no particular order:
- Uli Schlachter
- Jasper Lievisse Adriaanse
- Ildar Mulyukov
- Nils Nordman
- Ignas Anikevicius
- Craig Barnes
- Nicola Fontana
- Andreas Stührk
- Aaron Faanes
- Jiří Klimeš
- Garrett Regier
- Kenneth Zhou
- Travis Hoppe
- Tobias Jakobs
- Heiko Becker
- Vincent Bermel
Many other people contributed to what lgi is today, in many forms - writing patches, reporting bugs, packaging for distributions, providing ideas, spreading a word... Many thanks to all of you!
- fix assorted crashes in closure callback invocation code
- fix double-free bug caused by incorrect annotation of Gio.DBusProxy.get_interface_info
- fix marshaling of arrays of pointers
- make objects unusable in __gc metamethod
- work around API break in GLib 2.54
- use structured GLib logging when available
- add Gio.Async support also for static methods and global functions
- better error message when Gtk.init fails
- add support for Travis
- don't hardcode pkg-config executable
- fix URI in GStreamer sample
- fix flags for DBus samples
- marshal NULL strings as nil instead of empty strings. This allows use of e.g. DataInputStream:read_line() APIs.
- fix and improve build for OSX and Win-based configurations
- add support for arrays with lengths as struct fields
- allow GLib.Variant construction for lightuserdata
- fix gtop binding (certain structs could not be imported)
- adapt to new set of annotations in newer glib
- assorted Lua5.3 fixes, lgi is now fully Lua5.3 compatible
- fix binding of Gdk.Rectangle from newer GDK
- new feature: allow defining new properties on custom GObject subclasses implemented using lgi
- fix: improve compatibility with locales (turkish)
- fix: GPtrArray handling
- fix: improve behavior when running in assorted multiple-embedded and concurrent scenarios
- new feature: add automatically-generated wrappers for do_async()/do_finish() pairs. Documented as Gio.Async namespace functionality.
- new feature: automatically initialize objects implementing Gio.Initable and Gio.AsyncInitable interfaces.
- new feature: GLib.Error is now handled properly, functions returning errors return GLib.Error instances instead of error numbers and strings. This also allows overriding virtual methods from Lua which report errors by returning GLib.Error
- new feature: GLib.Bytes support, adding # operator and 'data' property allowing easy use of GLib.Bytes object. This leads to deprecation of seldomly used modifiable buffers extensions.
- optimization: type attribute caching brings significant speedup of method and property lookups.
- fix: Gtk: override for Gtk.Menu.popup() compatible with new GTK annotation.
- fix: cairo: assorted small fixes of bad signatures, added some convenience properties.
- fix: GLib: add overrides for GLib.MarkupParser
- fix: Gio: add overrides for Gio.DBus*Info structures
- fix: Pango: add override for Pango.GlyphString.glyphs array
- fix: Gdk: Add override inheriting specific Gdk.EventXxx from Gdk.Event
- fix: Compile cleanly against Lua5.2 with compatibility mode turned on
- fix: avoid leak when adding already cached owned record and for retrieving Variant from Value.
- fix: improper marshalling of certain APIs passing pointers to records.
- fix: cairo.PsSurface.create() had incorrect signature, missing filename.
- fix: If GTK initialization fails, raise Lua exception instead of hard-crash of calling process.
- fix: when running test in devel tree, prefer lgi from devel tree instead of the installed one.
- add: cairo.Status.to_string() API
- fix: avoid referencing GdkRGBA in GDk override when targetting Gdk2.0, which does not have GdkRGBA.
- fix: replace GStaticRecMutex with GRecMutex to avoid compilation warnings.
- fix: Gtk.Container.'child' pseudoproperty works even in Gtk2, where it was shadowed by internal field.
- fix: add workaround for improperly parsed g_bytes_get_data() annotation.
- fix: add workarounf for incorrect annotation on Pango.Layour.set_attributes(), which caused memory leak.
- fix: adapt to Gio.InputStream.[read|read_all|read_async] API change, which does not accept buffer length argument any more (due to the newly added annotations).
- Add support for GStreamer 1.0, while still retaining GStreamer 0.10 compatibility.
- fix: crash when trying to to access '_class' attribute of class which does not have public classstruct exposed in typelib
- fix: crash when passing 'nil' to transfer=full struct (caused crash of Awesome WM during startup).
- New feature - subclassing. Allows creating GObject subclasses and implementing their virtual methods in Lua.
- cairo: add support for most 1.12-specific cairo features
- cairo: create hierarchy for Pattern subclasses
- cairo: assorted small cairo bugfixes
- samples: add GDBus client example
- samples: add GnomeKeyring example
- samples: GTK: offscreen window demos
- samples: libsoup simple http server example
- platforms: added support for darwin/macosx platform
- platforms: additional fixes for OpenBSD
- build: Makefiles now respect
LDFLAGSenv vars values
- build: Add Lua version option into Makefile
- fix: custom ffi enum/flags handling
- fix: more exotic callback-to-Lua marshalling scenarios
- fix: do not allow GTK+ and gstreamer to call setlocale() - this might break Lua in some locales
- fix: small adjustments, fixes and additions in Gtk override
- fix: tons of other small fixes
- Avoid unexpected dependency on cairo-devel, cairo-runtime is now enough
set_resident()more robust and fix stack leak for Lua 5.2 case, avoid useless warning when
set_resident()fails (to accommodate for static linking case).
- Fix small memory leak (mutex) which occured once per opened
- objects and structs: actually implement
_typeproperty as documented
- tests: Fix regression tests for less common platforms
- Pango: Add a few missing overrides
- cairo: Fix
Context:user_to_device()family of methods.
- GStreamer: Add support for transfer!=none for input objects. This is needed to avoid leaks caused by strange usage of transfer annotations of gstreamer-0.10
- GStreamer: Add more missing overrides
- GStreamer: Fix and improve samples
- Various fixes for usecase when Lua context with loaded lgi is closed and opened again
- Gtk: Add missing
- Add cairo bindings, cairo sample and finish some gtk-demo parts which were requiring cairo
0.5.1 (not officially released)
- Fix a few problems on more exotic architectures (s390x, mips, ia64).
- Allow passing
byte.bufferwhen UTF8 string is requested.
- Port gtk3-demo to Lua code. Try running 'lua samples/gtk-demo/main.lua'
- Finish override set for Gtk
- Extend and document features for interfacing LGI with external libraries (exporting and importing objects and structures via lightuserdata pointers).
- Fix: a few bugs with resolving bitflags values
- Fix: a few bugs in coroutines-as-callbacks feature
- Fix: workaround for crashing bug in gobject-introspection 1.32.0
- Fix: don't try to squeeze
lua_Numberany more; this could cause crashes on some 64bit arches.
- Changed handling of enums and bitflags, switched from marshaling them as numbers to prefering strings for enums and tables (sets or lists) for bitflags. Numeric values still work for Lua->C marshalling, but backward compatibility is broken in C->Lua enum and bitflags marshalling.
- Compatible with Lua 5.2 and LuaJIT
- Added standardized way for overrides to handle constructor argument table array part.
- Existing Gtk overrides reworked and improved, there is now a way to
describe and create widget hierarchies in Lua-friendly way. See
docs/gtk.lua, chapter about
Gtk.Containerfor overview and samples.
- Various bugfixes and portability fixes.
- Project hosting moved to GitHub.
- Build system switched from
wafto simple Makefile-based one
- Added automatic locking of thread-sensitive libraries (Gdk and
Clutter). There is no need to add
Clutter.threads_leave()pairs into application, lgi handles this automatically.
- Added new sample
samples/console.lua, which implements already quite usable Lua console using Gtk widgets.
- Fixes for compatibility with older gobject-introspection 0.10.8 package
- Testsuite is not built automatically, because building it can be apparently problematic on some systems, causing installation failure even when testsuite is not needed at all.
setlocale()initialization, which could break Lua when used with some regional locales. The downside of this change is that marshaling file names containing non-ASCII characters on systems which define
G_BROKEN_FILENAMESenvironment variable (probably only Fedora 15) does not work now.
First public release