class Gtk::Notebook

Overview

Gtk::Notebook is a container whose children are pages switched between using tabs.

An example Gtk::Notebook

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

Gtk::Notebook as Gtk::Buildable

The Gtk::Notebook implementation of the Gtk::Buildable interface supports placing children into tabs by specifying “tab” as the “type” attribute of a 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 type attribute.

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

An example of a UI definition fragment with Gtk::Notebook:

WARNING ⚠️ The following code is in xml ⚠️

<object class="Gtk::Notebook">
  <child>
    <object class="Gtk::Label" id="notebook-content">
      <property name="label">Content</property>
    </object>
  </child>
  <child type="tab">
    <object class="Gtk::Label" 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>

Gtk::Notebook has a main CSS node with name notebook, a subnode with name header and below that a subnode with name tabs which 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 Gtk::Notebook#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, regardless of text direction.

Accessibility

Gtk::Notebook uses the following roles:

Included Modules

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/notebook.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

==(other : self) ==, action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _ | Nil) : Bool activate_action, activate_default : Nil activate_default, add_controller(controller : Gtk::EventController) : Nil add_controller, add_css_class(css_class : String) : Nil add_css_class, add_mnemonic_label(label : Gtk::Widget) : Nil add_mnemonic_label, add_tick_callback(callback : Gtk::TickCallback) : UInt32 add_tick_callback, allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform | Nil) : Nil allocate, allocated_baseline : Int32 allocated_baseline, allocated_height : Int32 allocated_height, allocated_width : Int32 allocated_width, allocation : Gdk::Rectangle allocation, ancestor(widget_type : UInt64) : Gtk::Widget | Nil ancestor, can_focus : Bool can_focus, can_focus=(can_focus : Bool) : Nil can_focus=, can_focus? : Bool can_focus?, can_target : Bool can_target, can_target=(can_target : Bool) : Nil can_target=, can_target? : Bool can_target?, child_focus(direction : Gtk::DirectionType) : Bool child_focus, child_visible : Bool child_visible, child_visible=(child_visible : Bool) : Nil child_visible=, children : Iterator(Widget) children, clipboard : Gdk::Clipboard clipboard, compute_bounds(target : Gtk::Widget) : Graphene::Rect compute_bounds, compute_expand(orientation : Gtk::Orientation) : Bool compute_expand, compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point compute_point, compute_transform(target : Gtk::Widget) : Graphene::Matrix compute_transform, contains(x : Float64, y : Float64) : Bool contains, create_pango_context : Pango::Context create_pango_context, create_pango_layout(text : String | Nil) : Pango::Layout create_pango_layout, css_classes : Enumerable(String) css_classes, css_classes=(classes : Enumerable(String)) : Nil css_classes=, css_name : String css_name, css_name=(value : String) : String
css_name=(value : Nil) : Nil
css_name=
, css_name? : String | Nil css_name?, cursor : Gdk::Cursor | Nil cursor, cursor=(cursor : Gdk::Cursor | Nil) : Nil cursor=, cursor_from_name=(name : String | Nil) : Nil cursor_from_name=, destroy_signal destroy_signal, direction : Gtk::TextDirection direction, direction=(dir : Gtk::TextDirection) : Nil direction=, direction_changed_signal direction_changed_signal, display : Gdk::Display display, drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool drag_check_threshold, error_bell : Nil error_bell, first_child : Gtk::Widget | Nil first_child, focus_child : Gtk::Widget | Nil focus_child, focus_child=(child : Gtk::Widget | Nil) : Nil focus_child=, focus_on_click : Bool focus_on_click, focus_on_click=(focus_on_click : Bool) : Nil focus_on_click=, focus_on_click? : Bool focus_on_click?, focusable : Bool focusable, focusable=(focusable : Bool) : Nil focusable=, focusable? : Bool focusable?, font_map : Pango::FontMap | Nil font_map, font_map=(font_map : Pango::FontMap | Nil) : Nil font_map=, font_options : Cairo::FontOptions | Nil font_options, font_options=(options : Cairo::FontOptions | Nil) : Nil font_options=, frame_clock : Gdk::FrameClock | Nil frame_clock, grab_focus : Bool grab_focus, halign : Gtk::Align halign, halign=(align : Gtk::Align) : Nil halign=, has_css_class(css_class : String) : Bool has_css_class, has_default : Bool has_default, has_default? : Bool has_default?, has_focus : Bool has_focus, has_focus? : Bool has_focus?, has_tooltip : Bool has_tooltip, has_tooltip=(has_tooltip : Bool) : Nil has_tooltip=, has_tooltip? : Bool has_tooltip?, has_visible_focus : Bool has_visible_focus, hash(hasher) hash, height : Int32 height, height_request : Int32 height_request, height_request=(value : Int32) : Int32 height_request=, hexpand : Bool hexpand, hexpand=(expand : Bool) : Nil hexpand=, hexpand? : Bool hexpand?, hexpand_set : Bool hexpand_set, hexpand_set=(set : Bool) : Nil hexpand_set=, hexpand_set? : Bool hexpand_set?, hide : Nil hide, hide_signal hide_signal, in_destruction : Bool in_destruction, init_template : Nil init_template, insert_action_group(name : String, group : Gio::ActionGroup | Nil) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget | Nil) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget | Nil) : Nil insert_before, is_ancestor(ancestor : Gtk::Widget) : Bool is_ancestor, is_drawable : Bool is_drawable, is_focus : Bool is_focus, is_sensitive : Bool is_sensitive, is_visible : Bool is_visible, keynav_failed(direction : Gtk::DirectionType) : Bool keynav_failed, keynav_failed_signal keynav_failed_signal, last_child : Gtk::Widget | Nil last_child, layout_manager : Gtk::LayoutManager | Nil layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager | Nil) : Nil layout_manager=, list_mnemonic_labels : GLib::List list_mnemonic_labels, map : Nil map, map_signal map_signal, mapped : Bool mapped, margin_bottom : Int32 margin_bottom, margin_bottom=(margin : Int32) : Nil margin_bottom=, margin_end : Int32 margin_end, margin_end=(margin : Int32) : Nil margin_end=, margin_start : Int32 margin_start, margin_start=(margin : Int32) : Nil margin_start=, margin_top : Int32 margin_top, margin_top=(margin : Int32) : Nil margin_top=, measure(orientation : Gtk::Orientation, for_size : Int32) : Nil measure, mnemonic_activate(group_cycling : Bool) : Bool mnemonic_activate, mnemonic_activate_signal mnemonic_activate_signal, move_focus_signal move_focus_signal, name : String name, name=(name : String) : Nil
name=(value : Nil) : Nil
name=
, name? : String | Nil name?, native : Gtk::Native | Nil native, next_sibling : Gtk::Widget | Nil next_sibling, observe_children : Gio::ListModel observe_children, observe_controllers : Gio::ListModel observe_controllers, opacity : Float64 opacity, opacity=(opacity : Float64) : Nil opacity=, overflow : Gtk::Overflow overflow, overflow=(overflow : Gtk::Overflow) : Nil overflow=, pango_context : Pango::Context pango_context, parent : Gtk::Widget | Nil parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget | Nil pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget | Nil prev_sibling, primary_clipboard : Gdk::Clipboard primary_clipboard, query_tooltip_signal query_tooltip_signal, queue_allocate : Nil queue_allocate, queue_draw : Nil queue_draw, queue_resize : Nil queue_resize, realize : Nil realize, realize_signal realize_signal, realized : Bool realized, receives_default : Bool receives_default, receives_default=(receives_default : Bool) : Nil receives_default=, receives_default? : Bool receives_default?, remove_controller(controller : Gtk::EventController) : Nil remove_controller, remove_css_class(css_class : String) : Nil remove_css_class, remove_mnemonic_label(label : Gtk::Widget) : Nil remove_mnemonic_label, remove_tick_callback(id : UInt32) : Nil remove_tick_callback, request_mode : Gtk::SizeRequestMode request_mode, root : Gtk::Root | Nil root, scale_factor : Int32 scale_factor, sensitive : Bool sensitive, sensitive=(sensitive : Bool) : Nil sensitive=, sensitive? : Bool sensitive?, set_size_request(width : Int32, height : Int32) : Nil set_size_request, set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil set_state_flags, settings : Gtk::Settings settings, should_layout : Bool should_layout, show : Nil show, show_signal show_signal, size(orientation : Gtk::Orientation) : Int32 size, size_allocate(x : Int32, y : Int32, width : Int32, height : Int32, baseline : Int32)
size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil
size_allocate
, size_request : Nil size_request, snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil snapshot_child, state_flags : Gtk::StateFlags state_flags, state_flags_changed_signal state_flags_changed_signal, style_context : Gtk::StyleContext style_context, template_child(widget_type : UInt64, name : String) : GObject::Object
template_child(name : String) : GObject::Object
template_child
, tooltip_markup : String | Nil tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(value : Nil) : Nil
tooltip_markup=(markup : String | Nil) : Nil
tooltip_markup=
, tooltip_markup? : String | Nil tooltip_markup?, tooltip_text : String | Nil tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(value : Nil) : Nil
tooltip_text=(text : String | Nil) : Nil
tooltip_text=
, tooltip_text? : String | Nil tooltip_text?, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=

Constructor methods inherited from class Gtk::Widget

new
new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, sensitive : Bool | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = nil)
new

Class methods inherited from class Gtk::Widget

default_direction : Gtk::TextDirection default_direction, default_direction=(dir : Gtk::TextDirection) : Nil default_direction=, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::InitiallyUnowned

==(other : self) ==, hash(hasher) hash

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new Gtk::Notebook widget with no pages.


[View source]
def self.new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, enable_popup : Bool | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, group_name : String | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, page : Int32 | Nil = nil, pages : Gio::ListModel | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, scrollable : Bool | Nil = nil, sensitive : Bool | Nil = nil, show_border : Bool | Nil = nil, show_tabs : Bool | Nil = nil, tab_pos : Gtk::PositionType | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = nil) #

[View source]

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def action_widget(pack_type : Gtk::PackType) : Gtk::Widget | Nil #

Gets one of the action widgets.

See Gtk::Notebook#action_widget=.


[View source]
def append_page(child : Gtk::Widget, tab_label : Gtk::Widget | Nil) : Int32 #

Appends a page to notebook.


[View source]
def append_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget | Nil, menu_label : Gtk::Widget | Nil) : Int32 #

Appends a page to notebook, specifying the widget to use as the label in the popup menu.


[View source]
def change_current_page_signal #

[View source]
def create_window_signal #

[View source]
def current_page : Int32 #

Returns the page number of the current page.


[View source]
def current_page=(page_num : Int32) : Nil #

Switches to the page number page_num.

Note that due to historical reasons, Gtk::Notebook refuses to switch to a page unless the child widget is visible. Therefore, it is recommended to show child widgets before adding them to a notebook.


[View source]
def detach_tab(child : Gtk::Widget) : Nil #

Removes the child from the notebook.

This function is very similar to Gtk::Notebook#remove_page, but additionally informs the notebook that the removal is happening as part of a tab DND operation, which should not be cancelled.


[View source]
def enable_popup=(value : Bool) : Bool #

[View source]
def enable_popup? : Bool #

[View source]
def focus_tab_signal #

[View source]
def group_name : String | Nil #

Gets the current group name for notebook.


[View source]
def group_name=(value : String) : String #

[View source]
def group_name=(value : Nil) : Nil #

Set #group_name property to nil.


[View source]
def group_name=(group_name : String | Nil) : Nil #

Sets a group name for notebook.

Notebooks with the same name will be able to exchange tabs via drag and drop. A notebook with a nil group name will not be able to exchange tabs with any other notebook.


[View source]
def group_name? : String | Nil #

Same as #group_name, but can return nil.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def insert_page(child : Gtk::Widget, tab_label : Gtk::Widget | Nil, position : Int32) : Int32 #

Insert a page into notebook at the given position.


[View source]
def insert_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget | Nil, menu_label : Gtk::Widget | Nil, position : Int32) : Int32 #

Insert a page into notebook at the given position, specifying the widget to use as the label in the popup menu.


[View source]
def menu_label(child : Gtk::Widget) : Gtk::Widget | Nil #

Retrieves the menu label widget of the page containing child.


[View source]
def menu_label_text(child : Gtk::Widget) : String | Nil #

Retrieves the text of the menu label for the page containing child.


[View source]
def move_focus_out_signal #

[View source]
def n_pages : Int32 #

Gets the number of pages in a notebook.


[View source]
def next_page : Nil #

Switches to the next page.

Nothing happens if the current page is the last page.


[View source]
def nth_page(page_num : Int32) : Gtk::Widget | Nil #

Returns the child widget contained in page number page_num.


[View source]
def page(child : Gtk::Widget) : Gtk::NotebookPage #

Returns the Gtk::NotebookPage for child.


[View source]
def page : Int32 #

[View source]
def page=(value : Int32) : Int32 #

[View source]
def page_added_signal #

[View source]
def page_num(child : Gtk::Widget) : Int32 #

Finds the index of the page which contains the given child widget.


[View source]
def page_removed_signal #

[View source]
def page_reordered_signal #

[View source]
def pages : Gio::ListModel #

Returns a GListModel that contains the pages of the notebook.

This can be used to keep an up-to-date view. The model also implements Gtk::SelectionModel and can be used to track and modify the visible page.


[View source]
def popup_disable : Nil #

Disables the popup menu.


[View source]
def popup_enable : Nil #

Enables the popup menu.

If the user clicks with the right mouse button on the tab labels, a menu with all the pages will be popped up.


[View source]
def prepend_page(child : Gtk::Widget, tab_label : Gtk::Widget | Nil) : Int32 #

Prepends a page to notebook.


[View source]
def prepend_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget | Nil, menu_label : Gtk::Widget | Nil) : Int32 #

Prepends a page to notebook, specifying the widget to use as the label in the popup menu.


[View source]
def prev_page : Nil #

Switches to the previous page.

Nothing happens if the current page is the first page.


[View source]
def remove_page(page_num : Int32) : Nil #

Removes a page from the notebook given its index in the notebook.


[View source]
def reorder_child(child : Gtk::Widget, position : Int32) : Nil #

Reorders the page containing child, so that it appears in position position.

If position is greater than or equal to the number of children in the list or negative, child will be moved to the end of the list.


[View source]
def reorder_tab_signal #

[View source]
def scrollable : Bool #

Returns whether the tab label area has arrows for scrolling.


[View source]
def scrollable=(scrollable : Bool) : Nil #

Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.


[View source]
def scrollable? : Bool #

[View source]
def select_page_signal #

[View source]
def set_action_widget(widget : Gtk::Widget, pack_type : Gtk::PackType) : Nil #

Sets widget as one of the action widgets.

Depending on the pack type the widget will be placed before or after the tabs. You can use a Gtk::Box if you need to pack more than one widget on the same side.


[View source]
def set_menu_label(child : Gtk::Widget, menu_label : Gtk::Widget | Nil) : Nil #

Changes the menu label for the page containing child.


[View source]
def set_menu_label_text(child : Gtk::Widget, menu_text : String) : Nil #

Creates a new label and sets it as the menu label of child.


[View source]
def set_tab_detachable(child : Gtk::Widget, detachable : Bool) : Nil #

Sets whether the tab can be detached from notebook to another notebook or widget.

Note that two notebooks must share a common group identificator (see Gtk::Notebook#group_name=) to allow automatic tabs interchange between them.

If you want a widget to interact with a notebook through DnD (i.e.: accept dragged tabs from it) it must be set as a drop destination and accept the target “GTK_NOTEBOOK_TAB”. The notebook will fill the selection with a Gtk::Widget** pointing to the child widget that corresponds to the dropped tab.

Note that you should use Gtk::Notebook#detach_tab instead of Gtk::Notebook#remove_page if you want to remove the tab from the source notebook as part of accepting a drop. Otherwise, the source notebook will think that the dragged tab was removed from underneath the ongoing drag operation, and will initiate a drag cancel animation.

WARNING ⚠️ The following code is in c ⚠️

static void
on_drag_data_received (Gtk::Widget        *widget,
                       Gdk::Drop          *drop,
                       Gtk::SelectionData *data,
                       guint             time,
                       gpointer          user_data)
{
  Gtk::Drag *drag;
  Gtk::Widget *notebook;
  Gtk::Widget **child;

  drag = gtk_drop_get_drag (drop);
  notebook = g_object_get_data (drag, "gtk-notebook-drag-origin");
  child = (void*) gtk_selection_data_get_data (data);

  // process_widget (*child);

  gtk_notebook_detach_tab (GTK_NOTEBOOK (notebook), *child);
}

If you want a notebook to accept drags from other widgets, you will have to set your own DnD code to do it.


[View source]
def set_tab_label(child : Gtk::Widget, tab_label : Gtk::Widget | Nil) : Nil #

Changes the tab label for child.

If nil is specified for tab_label, then the page will have the label “page N”.


[View source]
def set_tab_label_text(child : Gtk::Widget, tab_text : String) : Nil #

Creates a new label and sets it as the tab label for the page containing child.


[View source]
def set_tab_reorderable(child : Gtk::Widget, reorderable : Bool) : Nil #

Sets whether the notebook tab can be reordered via drag and drop or not.


[View source]
def show_border : Bool #

Returns whether a bevel will be drawn around the notebook pages.


[View source]
def show_border=(show_border : Bool) : Nil #

Sets whether a bevel will be drawn around the notebook pages.

This only has a visual effect when the tabs are not shown.


[View source]
def show_border? : Bool #

[View source]
def show_tabs : Bool #

Returns whether the tabs of the notebook are shown.


[View source]
def show_tabs=(show_tabs : Bool) : Nil #

Sets whether to show the tabs for the notebook or not.


[View source]
def show_tabs? : Bool #

[View source]
def switch_page_signal #

[View source]
def tab_detachable(child : Gtk::Widget) : Bool #

Returns whether the tab contents can be detached from notebook.


[View source]
def tab_label(child : Gtk::Widget) : Gtk::Widget | Nil #

Returns the tab label widget for the page child.

nil is returned if child is not in notebook or if no tab label has specifically been set for child.


[View source]
def tab_label_text(child : Gtk::Widget) : String | Nil #

Retrieves the text of the tab label for the page containing child.


[View source]
def tab_pos : Gtk::PositionType #

Gets the edge at which the tabs are drawn.


[View source]
def tab_pos=(pos : Gtk::PositionType) : Nil #

Sets the edge at which the tabs are drawn.


[View source]
def tab_reorderable(child : Gtk::Widget) : Bool #

Gets whether the tab can be reordered via drag and drop or not.


[View source]