Toolbar


Object Hierarchy:

Gtk.Toolbar Gtk.Toolbar Gtk.Toolbar Gtk.Container Gtk.Container Gtk.Container->Gtk.Toolbar 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.Toolbar Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Toolbar Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Orientable Gtk.Orientable Gtk.Orientable->Gtk.Toolbar Gtk.ToolShell Gtk.ToolShell Gtk.ToolShell->Gtk.Toolbar

Description:

[ CCode ( type_id = "gtk_toolbar_get_type ()" ) ]
public class Toolbar : Container, Implementor, Buildable, Orientable, ToolShell

A toolbar is created with a call to Toolbar.

A toolbar can contain instances of a subclass of ToolItem. To add a ToolItem to the a toolbar, use insert. To remove an item from the toolbar use remove. To add a button to the toolbar, add an instance of ToolButton.

Toolbar items can be visually grouped by adding instances of SeparatorToolItem to the toolbar. If the GtkToolbar child property “expand” is TRUE and the property draw is set to FALSE, the effect is to force all following items to the end of the toolbar.

By default, a toolbar can be shrunk, upon which it will add an arrow button to show an overflow menu offering access to any ToolItem child that has a proxy menu item. To disable this and request enough size for all children, call set_show_arrow to set show_arrow to false.

Creating a context menu for the toolbar can be done by connecting to the popup_context_menu signal.

CSS nodes

GtkToolbar has a single CSS node with name toolbar.

GtkToolbar

Example: Toolbar:

public class Application : Gtk.Window {
public Application () {
// Prepare Gtk.Window:
this.title = "My Gtk.Toolbar";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
this.set_default_size (350, -1);


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


// Toolbar content:
Gtk.Image img = new Gtk.Image.from_icon_name ("document-open", Gtk.IconSize.SMALL_TOOLBAR);
Gtk.ToolButton button1 = new Gtk.ToolButton (img, null);
button1.clicked.connect (() => {
print ("Button 1\n");
});
bar.add (button1);

img = new Gtk.Image.from_icon_name ("window-close", Gtk.IconSize.SMALL_TOOLBAR);
Gtk.ToolButton button2 = new Gtk.ToolButton (img, null);
button2.clicked.connect (() => {
print ("Button 2\n");
});
bar.add (button2);
}

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.Toolbar.vala


Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

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