Consider renaming gtk_info_bar_add_child()
The method shows up as add_child()
in introspection, which overlaps with the GtkBuildable
method of the same name.
Arguably bindings should always prefer methods on the object itself over methods brought in from implemented interfaces, but avoiding the ambiguity in the first place would be easier.
In particular it's less clear which method to pick when the overlap is between a parent class and an interface.
Case in point, gjs does get this right when using Gtk.InfoBar
directly:
imports.gi.versions.Gtk = '4.0';
const {Gtk} = imports.gi;
const app = new Gtk.Application({application_id: 'org.gnome.fmuellner.Test'});
app.connect('activate', () => {
const window = new Gtk.ApplicationWindow({application: app});
const box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL});
const info = new Gtk.InfoBar();
info.add_child(new Gtk.Label({label: 'Test'}));
box.append(info);
window.set_child(box);
window.present();
});
app.run(null);
But it fails to pick the "right" method when subclassing Gtk.InfoBar
:
imports.gi.versions.Gtk = '4.0';
const {GObject, Gtk} = imports.gi;
const MyInfoBar = GObject.registerClass(
class MyInfoBar extends Gtk.InfoBar {
_init() {
super._init();
// this breaks
this.add_child(new Gtk.Label({label: 'Test'}));
// this works, but ugh
Gtk.InfoBar.prototype.add_child.call(this, new Gtk.Label({label: 'Test'}));
}
});
const app = new Gtk.Application({application_id: 'org.gnome.fmuellner.Test'});
app.connect('activate', () => {
const window = new Gtk.ApplicationWindow({application: app});
const box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL});
box.append(new MyInfoBar());
window.set_child(box);
window.present();
});
app.run(null);