gtk.GObject
Prev | Chapter 2. Gtk API for Lua scripts | Next

## gtk.GObject

### connect()

    object.connect(signal, callback)

Connect a signal handler.

Example 2.1. GObject.connect()

     editor.connect("before-save", function(editor, doc, file)
       if #doc.get_text() % 2 ~= 0 then
         moo.error_dialog("Won't save",
                          "Odd number of characters in a file " ..
                          "is bad for your hard drive, I am not " ..
                          "going to save this.",
                          doc.get_window())
         return moo.SAVE_RESPONSE_CANCEL
       else
         return moo.SAVE_RESPONSE_CONTINUE
       end
     end)

`signal` : | signal name
`callback` : | function to call when the signal is emitted

`Returns:` id of connected signal handler. Use `disconnect()` to remove it.

### connect_after()

    object.connect_after(signal, callback)

`signal` : | signal name
`callback` : | function to call when the signal is emitted

`Returns:` `integer`

### disconnect()

    object.disconnect(handler_id)

Disconnect a signal handler.

`handler_id` : | signal handler id returned from `connect()`

### get_property()

    object.get_property(property_name)

`property_name` : | `string`

`Returns:` `value`

### set_property()

    object.set_property(property_name, value)

`property_name` : | `string`
`value` : | `value`

### signal_handler_block()

    object.signal_handler_block(handler_id)

Temporarily blocks signal handler so it will not be called when the signal it's connected to is emitted. Call `signal_handler_unblock()` to re-enable the signal handler.

`handler_id` : | signal handler id returned from `connect()`

### signal_handler_unblock()

    object.signal_handler_unblock(handler_id)

Re-enables signal handler disabled by `signal_handler_block()`.

`handler_id` : | signal handler id returned from `connect()`

Prev | Up | Next
gtk.GFile | Home | gtk.GdkRectangle