File src/glib/callback.c

Functions

local _callback (data, ...) Handler for Gtk signal callbacks.
local _callback_return_value (L, return_type, cbi) Handle return values from the Lua handler to pass back to Gtk.
local _free_callback_info (data, closure) Free memory on signal handler disconnection.
local connect (object, signal_name, handler, ...) Connect a signal to a Lua function.
disconnect (object, handler_id) Disconnect a signal handler from a given object.


Functions

local _callback (data, ...)
Handler for Gtk signal callbacks. Find the proper Lua callback, build the parameters, call, and optionally return something to Gtk. This runs in the lua_State that was used to call glib_connect with, and therefore probably uses the stack of the main function, which mustn't be modified.

Parameters

  • data: a pointer to a struct callback_info
  • ...: Variable arguments, and finally the object pointer.

Return value:

A value to return to Gtk.
local _callback_return_value (L, return_type, cbi)
Handle return values from the Lua handler to pass back to Gtk. Not many different types are supported - but I think no others are actually used.

Parameters

  • L: lua_State
  • return_type: The GType of the expected return value
  • cbi: callback_info of this signal

Return value:

An integer to return to Gtk.
local _free_callback_info (data, closure)
Free memory on signal handler disconnection. The struct callback_info contains references to entries in the registry of the Lua state. They must be unreferenced, then the structure itself is freed. XXX the Lua state might not exist anymore?

Parameters

  • data:
  • closure:
local connect (object, signal_name, handler, ...)
Connect a signal to a Lua function.

Parameters

  • object:
  • signal_name: Name of the signal, like "clicked"
  • handler: A Lua function (the callback)
  • ...: (optional) extra parameters to the callback
disconnect (object, handler_id)
Disconnect a signal handler from a given object.

Parameters

  • object: The object to disconnect a handler for
  • handler_id: The handler ID of the connection, as returned from the connect function.

Valid XHTML 1.0!