using Gtk;

private class MyWindow : Gtk.ApplicationWindow {

    private const GLib.ActionEntry[] mActions = {
        { "minimode", WinMiniMode, null, "false"},
    };

    private Notebook nb;

    public MyWindow() {

        this.add_action_entries(mActions, this);

        var b = new Gtk.Builder();
            b.add_from_string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
        <interface>
          <requires lib=\"gtk+\" version=\"3.12\"/>
          <menu id='popovermenu'>
            <section>
              <item>
                <attribute name=\"label\">Mini-Mode</attribute>
                <attribute name=\"action\">win.minimode</attribute>
              </item>
            </section>
        </menu>
        </interface>", -1);
        var model = b.get_object("popovermenu") as MenuModel;

        var popover = new Gtk.MenuButton();
        popover.sensitive         = true;
        popover.menu_model        = model;
        popover.use_popover       = true;

        this.nb = new Notebook();
        //his.nb.show_tabs = false;

        var header = new Gtk.HeaderBar();
        header.show_close_button = true;
        header.pack_end(popover);

        this.set_titlebar(header);

	    Gtk.Label title = new Gtk.Label ("Title 1");
	    Gtk.Label content = new Gtk.Label ("Content 1");
	    this.nb.append_page (content, title);

	    title = new Gtk.Label ("Title 2");

        GtkClutter.Embed embed = new GtkClutter.Embed();	
        embed.get_stage().background_color = Clutter.Color.from_string("black");

	    this.nb.append_page (embed, title);
        this.add (this.nb);

    }


    private void WinMiniMode(SimpleAction action, Variant? parameter) {
        if(this.nb.page == 0) {
            this.nb.page = 1;
        } else {
            this.nb.page = 0;
        }
    }

}

int main (string[] args) {
    Gtk.init (ref args);
    GtkClutter.init(ref args);

    var window = new MyWindow ();
    window.title = "First GTK+ Program";
    window.border_width = 10;
    window.window_position = WindowPosition.CENTER;
    window.set_default_size (350, 70);
    window.destroy.connect (Gtk.main_quit);

    
    window.show_all ();


    Gtk.main ();
    return 0;
}

