Skip to content

fundamental: Use value or instance pointer when no get/set funcs are provided

Marco Trevisan requested to merge 3v1n0/gjs:handle-fundamental-pointers into master

Some fundamental types are providing value set/get functions however this is not mandatory as the fundamental can be just retrieved from the GValue pointer or we can build a GValue using the instance and gtype.

A case for this are Gdk4 Events that does not provide such functions, making impossible to use events signals.

Add tests simulating this, depending on a new gobject-introspection type that respects this constrain.

Fixes: #398 (closed)


Meanwhile the depending change in gobject-introspection!268 (merged) lands this can be manually tested using the regression-test provided in #398 (closed) with some additional changes to check both ways conversions:

// test.js
imports.gi.versions.Gtk = "4.0";
const { Gtk, GObject } = imports.gi;
Gtk.init();

var ExampleApp = GObject.registerClass(
class ExampleApp extends Gtk.Application {
    vfunc_activate() {
        let appWindow = new Gtk.ApplicationWindow({ application: this });

        let add = new Gtk.Box({ halign: Gtk.Align.CENTER });
        add.append(new Gtk.Image({ icon_name: 'list-add-symbolic' }));
        let ctl = new Gtk.EventControllerLegacy({});
        let ctl2 = new Gtk.EventControllerLegacy({});
        add.add_controller(ctl);
        ctl.connect('event', (_c, e) => {
            log('event'); print(ctl); print(e); print('dev',e.get_device());
            ctl2.emit('event', e);
        });
        ctl2.connect('event', (_c, e) => print('got again:', e))
        appWindow.set_child(add);

        appWindow.set_default_size(200, 200);
        appWindow.present();
    }
});
new ExampleApp().run([imports.system.programInvocationName].concat(ARGV));

Merge request reports