MenuBar


Object Hierarchy:

Gtk.MenuBar Gtk.MenuBar Gtk.MenuBar Gtk.MenuShell Gtk.MenuShell Gtk.MenuShell->Gtk.MenuBar Gtk.Container Gtk.Container Gtk.Container->Gtk.MenuShell Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.MenuBar Atk.Implementor->Gtk.MenuShell Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.MenuBar Gtk.Buildable->Gtk.MenuShell Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_menu_bar_get_type ()" ) ]
public class MenuBar : MenuShell, Implementor, Buildable

The MenuBar is a subclass of MenuShell which contains one or more MenuItems.

The result is a standard menu bar which can hold many menu items.

CSS nodes

GtkMenuBar has a single CSS node with name menubar.

GtkMenuBar

Example: MenuBar:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.MenuBar";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);

// MenuBar:
Gtk.MenuBar bar = new Gtk.MenuBar ();
this.add (bar);

// File:
Gtk.MenuItem item_file = new Gtk.MenuItem.with_label ("File");
bar.add (item_file);

Gtk.Menu filemenu = new Gtk.Menu ();
item_file.set_submenu (filemenu);

Gtk.MenuItem item_open = new Gtk.MenuItem.with_label ("Open");
item_open.activate.connect (() => {
Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
"Select your favorite file", this, Gtk.FileChooserAction.OPEN,
"_Cancel",
Gtk.ResponseType.CANCEL,
"_Open",
Gtk.ResponseType.ACCEPT);
chooser.run ();
chooser.close ();
});
filemenu.add (item_open);

Gtk.MenuItem item_exit = new Gtk.MenuItem.with_label ("Exit");
item_exit.activate.connect (Gtk.main_quit);
filemenu.add (item_exit);
}

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

Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}

valac --pkg gtk+-3.0 Gtk.MenuBar.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor