Skip to content

Support GObject.Closure boxed types

Evan Welsh requested to merge ewlsh/fix-closures into master

Background

When we create a signal closure with connect_impl in C we associate the signal ID with the closure using marshalling data. In GTK4 we've moved closure creation into JS using BuilderScope. These closures lack the associated metadata and are thus unable to resolve any non-primitive types like gpointer because the signal information can't be associated. This MR exposes GObject.Closure to JS in order to create GObject.Closure instances with the signal_id set to 0. This is then used as a flag to associate the signal invocation hint and thus the relevant type information.

GNOME/glib!2477 (reverted) changed the invoke API to accept a return value, this MR mirrors the intent of the API by accepting a return type. A null return type is equivalent to VOID. This MR no longer implements .invoke()

API Overrides

namespace GObject {
    class Closure {
        constructor(callable: Function);
    }
}

Examples

const closure = new GObject.Closure(() => 'test');

Changes

  • Exposes GObject.Closure as a boxed type for parameters
  • Fixes signals metadata for Gtk 4

Addresses some of the GClosure parts of #80

Fixes #421

Edited by Evan Welsh

Merge request reports