Notebook


Object Hierarchy:

Gtk.Notebook Gtk.Notebook Gtk.Notebook Gtk.Container Gtk.Container Gtk.Container->Gtk.Notebook 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.Notebook Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Notebook Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget

Description:

[ CCode ( type_id = "gtk_notebook_get_type ()" ) ]
public class Notebook : Container, Implementor, Buildable

The Notebook widget is a Container whose children are pages that can be switched between using tab labels along one edge.

There are many configuration options for GtkNotebook. Among other things, you can choose on which edge the tabs appear (see set_tab_pos), whether, if there are too many tabs to fit the notebook should be made bigger or scrolling arrows added (see set_scrollable), and whether there will be a popup menu allowing the users to switch pages. (see popup_enable, popup_disable)

GtkNotebook as GtkBuildable

The GtkNotebook implementation of the Buildable interface supports placing children into tabs by specifying “tab” as the “type” attribute of a `<child>` element. Note that the content of the tab must be created before the tab can be filled. A tab child can be specified without specifying a `<child>` type attribute.

To add a child widget in the notebooks action area, specify "action-start" or “action-end” as the “type” attribute of the `<child >` element.

An example of a UI definition fragment with GtkNotebook:

<object class="GtkNotebook">
<child>
<object class="GtkLabel" id="notebook-content">
<property name="label">Content</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="notebook-tab">
<property name="label">Tab</property>
</object>
</child>
</object>

CSS nodes

notebook
├── header.top
│ ├── [<action widget>]
│ ├── tabs
│ │ ├── [arrow]
│ │ ├── tab
│ │ │ ╰── <tab label>
┊ ┊ ┊
│ │ ├── tab[.reorderable-page]
│ │ │ ╰── <tab label>
│ │ ╰── [arrow]
│ ╰── [<action widget>]

╰── stack
├── <child>

╰── <child>
hich contains one subnode per tab with name tab.

If action widgets are present, their CSS nodes are placed next to the tabs node. If the notebook is scrollable, CSS nodes with name arrow are placed as first and last child of the tabs node.

The main node gets the .frame style class when the notebook has a border (see set_show_border).

The header node gets one of the style class .top, .bottom, .left or .right, depending on where the tabs are placed. For reorderable pages, the tab node gets the .reorderable-page class.

A tab node gets the .dnd style class while it is moved with drag-and-drop.

The nodes are always arranged from left-to-right, regarldess of text direction.

GtkNotebook

Example: Notebook:

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

// The Notebook:
Gtk.Notebook notebook = new Gtk.Notebook ();
this.add (notebook);

// Tab 1:
Gtk.Label title = new Gtk.Label ("Title 1");
Gtk.Label content = new Gtk.Label ("Content 1");
notebook.append_page (content, title);

// Tab 2:
title = new Gtk.Label ("Title 2");
content = new Gtk.Label ("Content 2");
notebook.append_page (content, title);
}

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.Notebook.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