<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>LGI Core Reference</title> <link rel="stylesheet" type="text/css" href="default.css" /> </head> <body> <h1>LGI Core Reference</h1> <h2>Core</h2> <p>Core LGI functionality is accessible through <code>lgi</code> module, loaded by <code>require 'lgi'</code> command. LGI does not install itself into global namespace, caller has to use the return value from <code>require</code> call.</p> <ul> <li><code>lgi.'module'</code> <ul> <li><code>module</code> string with module name, e.g.'Gtk' or 'WebKit'.</li> </ul></li> </ul> <p> Loads requested module of the latest version found into the repository.</p> <ul> <li><code>lgi.require(module, version)</code> <ul> <li><code>module</code> string with module name, e.g. 'Gtk' or 'WebKit'.</li> <li><code>version</code> string with exact required version of the module</li> </ul></li> </ul> <p> Loads requested module with specified version into the repository.</p> <ul> <li><p><code>lgi.log.domain(name)</code></p> <ul> <li><code>name</code> is string denoting logging area name, usually identifying the application or the library</li> <li><code>return</code> table containing</li> <li><code>message</code></li> <li><code>warning</code></li> <li><code>critical</code></li> <li><code>error</code></li> <li><code>debug</code></li> </ul> <p> methods for logging messages. These methods accept format string and inserts, which are formatted according to Lua's <code>string.format</code> conventions.</p></li> <li><p><code>lgi.yield()</code> when called, unlocks LGI state lock, for a while, thus allowing potentially blocked callbacks or signals to enter the Lua state. When using LGI with GLib's MainLoop, this call is not needed at all.</p></li> </ul> <h2>GObject basic constructs</h2> <h3>GObject.Type</h3> <ul> <li><code>NONE</code>, <code>INTERFACE</code>, <code>CHAR</code>, <code>UCHAR</code>, <code>BOOLEAN</code>, <code>INT</code>, <code>UINT</code>, <code>LONG</code>, <code>ULONG</code>, <code>INT64</code>, <code>UINT64</code>, <code>ENUM</code>, <code>FLAGS</code>, <code>FLOAT</code>, <code>DOUBLE</code>, <code>STRING</code>, <code>POINTER</code>, <code>BOXED</code>, <code>PARAM</code>, <code>OBJECT</code>, <code>VARIANT</code></li> </ul> <p> Constants containing type names of fundamental GObject types.</p> <ul> <li><code>parent</code>, <code>depth</code>, <code>next_base</code>, <code>is_a</code>, <code>children</code>, <code>interfaces</code>, <code>query</code>, <code>fundamental_next</code>, <code>fundamental</code></li> </ul> <p> Functions for manipulating and querying <code>GType</code>. THey are direct mappings of <code>g_type_xxx()</code> APIs, e.g. <code>GObject.Type.parent()</code> behaves in the same way as <code>g_type_parent()</code> in C.</p> <h3>GObject.Value</h3> <ul> <li><code>GObject.Value([gtype [, val]])</code> <ul> <li><code>gtype</code> type of the vlue to create, if not specified, defaults to <code>GObject.Type.NONE</code>.</li> <li><code>val</code> Lua value to initialize GValue with.</li> </ul></li> </ul> <p> Creates new GObject.Value of specified type, optionally assigns Lua value to it. For example, `local val = GObject.Value(GObject.Type.INT, 42)` creates GValue of type <code>G_TYPE_INT</code> and initializes it to value <code>42</code>.</p> <ul> <li><p><code>GObject.Value.gtype</code></p> <ul> <li>reading yields the gtype of the value</li> <li>writing changes the type of the value. Note that if GValue is already initialized with some value, a <code>g_value_transform</code> is called to attempt to convert value to target type.</li> </ul></li> <li><p><code>GObject.Value.value</code></p> <ul> <li>reading retrieves Lua-native contents of the referenced Value (i.e. GValue unboxing is performed).</li> <li>writing stores Lua-native contents to the Value (boxing is performed).</li> </ul></li> </ul> <h3>GObject.Closure</h3> <ul> <li><code>GObject.Glosure(func)</code> <ul> <li><code>target</code> is Lua function or anything Lua-callable.</li> </ul></li> </ul> <p> Creates new GClosure instance wrapping given Lua callable. When the closure is emitted, <code>target</code> function is invoked, getting GObject.Value instances as arguments, and expecting single GObject.Value to be returned.</p> </body></html>