Migration Guide to 1.0

From version 0.9 to version 1.0, lua-gtk has been split up into multiple modules, each providing the bindings to one library. This much more flexible design makes it easier to add any number of library bindings, as only the bindings you require are loaded:

require "gtk" require "gtkhtml"

If one binding depends on another, it is loaded automatically, as is the base library gnome. For example, gtk requires gdk, which in turn depends on glib. Therefore it is enough to require "gtk" to get all these modules.

Now there are multiple global variables in addition to "gtk". Each instance of gtk in your code may now have to be replaced by one of the other variables. While this sounds complicated, it's actually quite straightforward. Most of the code calls methods on objects, and this doesn't change at all.

For constants (enums etc.), a prefix is automatically prepended depending on the library, so for example GTK_ for gtk, G_ for glib etc. Remove the prefix for cleaner code, even though you could leave it. Some examples:


Non-gtk functions that were previously called with a prefix are now in the respective module's table without their prefix, even though the prefix can be given. This also applies to type names supplied to "new".

gtk.new "GtkTreeIter"gtk.new "TreeIter"

The LuaGnome specific functions are now in gnome and have sometimes simpler names, because no collision with module functions can happen anymore.


Some overrides have been removed, so that the LuaGnome API resembles the C API more closely. This reduces the additional knowledge required to code for LuaGnome.

treestore:append1(iter, parent, val1, val2)
iter = gtk.new "TreeIter" treestore:append(iter, parent) treestore:set(iter, 0, val1, 1, val2, -1)