const Lang = imports.lang;
const Gtk = imports.gi.Gtk;

const App = new Lang.Class({
    Name: 'Foo',
    Extends: Gtk.Application,

    vfunc_startup: function() {
        this.parent();
        let win = new Gtk.Window({
            application: this,
            title: 'foo',
        });

        let overlay = new Gtk.Overlay();

        let eventBox1 = new Gtk.EventBox();
        eventBox1.connect('button-release-event', () => { print('clicked on eventBox1') });

        let eventBox2 = new Gtk.EventBox();
        eventBox2.connect('button-release-event', () => { print('eventBox2 destroyed'); eventBox2.destroy(); });

        win.connect('button-release-event', () => { print('click') });

        overlay.add(eventBox1);
        overlay.add_overlay(eventBox2);

        win.set_titlebar(new Gtk.HeaderBar());

        win.add(overlay);
        win.show_all();
    },
})

let app = new App({ application_id: 'com.endlessm.foo' });
app.run(ARGV);