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

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

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

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _?) : 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 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? 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=, 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?) : 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=, cursor : Gdk::Cursor? cursor, cursor=(cursor : Gdk::Cursor?) : Nil cursor=, cursor_from_name=(name : String?) : 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, dispose_template(widget_type : UInt64) : Nil dispose_template, 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? first_child, focus_child : Gtk::Widget? focus_child, focus_child=(child : Gtk::Widget?) : 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? font_map, font_map=(font_map : Pango::FontMap?) : Nil font_map=, font_options : Cairo::FontOptions? font_options, font_options=(options : Cairo::FontOptions?) : Nil font_options=, frame_clock : Gdk::FrameClock? 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, 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 insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget?) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget?) : 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? last_child, layout_manager : Gtk::LayoutManager? layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager?) : 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=, native : Gtk::Native? native, next_sibling : Gtk::Widget? 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? parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget? pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget? 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? 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(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, tooltip_markup : String? tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(markup : String?) : Nil
tooltip_markup=
, tooltip_text : String? tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(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, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = 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

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

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

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

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

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, 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

compat_control(what : UInt64, data : Pointer(Void)?) : 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

Constructor Detail

def self.new : self #

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


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

Class Method Detail

def self.g_type : UInt64 #

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


Instance Method Detail

def action_widget(pack_type : Gtk::PackType) : Gtk::Widget? #

Gets one of the action widgets.

See Gtk::Notebook#action_widget=.


def append_page(child : Gtk::Widget, tab_label : Gtk::Widget?) : Int32 #

Appends a page to @notebook.


def append_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget?, menu_label : Gtk::Widget?) : Int32 #

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


def change_current_page_signal #

def create_window_signal #

def current_page : Int32 #

Returns the page number of the current page.


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.


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.


def enable_popup=(value : Bool) : Bool #

def enable_popup? : Bool #

def focus_tab_signal #

def group_name : String? #

Gets the current group name for @notebook.


def group_name=(value : String) : String #

def group_name=(group_name : String?) : 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.


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

Insert a page into @notebook at the given position.


def insert_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget?, menu_label : Gtk::Widget?, position : Int32) : Int32 #

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


def menu_label(child : Gtk::Widget) : Gtk::Widget? #

Retrieves the menu label widget of the page containing @child.


def menu_label_text(child : Gtk::Widget) : String? #

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


def move_focus_out_signal #

def n_pages : Int32 #

Gets the number of pages in a notebook.


def next_page : Nil #

Switches to the next page.

Nothing happens if the current page is the last page.


def nth_page(page_num : Int32) : Gtk::Widget? #

Returns the child widget contained in page number @page_num.


def page(child : Gtk::Widget) : Gtk::NotebookPage #

Returns the Gtk::NotebookPage for @child.


def page : Int32 #

def page=(value : Int32) : Int32 #

def page_added_signal #

def page_num(child : Gtk::Widget) : Int32 #

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


def page_removed_signal #

def page_reordered_signal #

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.


def popup_disable : Nil #

Disables the popup menu.


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.


def prepend_page(child : Gtk::Widget, tab_label : Gtk::Widget?) : Int32 #

Prepends a page to @notebook.


def prepend_page_menu(child : Gtk::Widget, tab_label : Gtk::Widget?, menu_label : Gtk::Widget?) : Int32 #

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


def prev_page : Nil #

Switches to the previous page.

Nothing happens if the current page is the first page.


def remove_page(page_num : Int32) : Nil #

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


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.


def reorder_tab_signal #

def scrollable : Bool #

Returns whether the tab label area has arrows for scrolling.


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.


def scrollable? : Bool #

def select_page_signal #

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.


def set_menu_label(child : Gtk::Widget, menu_label : Gtk::Widget?) : Nil #

Changes the menu label for the page containing @child.


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.


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.


def set_tab_label(child : Gtk::Widget, tab_label : Gtk::Widget?) : Nil #

Changes the tab label for @child.

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


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.


def set_tab_reorderable(child : Gtk::Widget, reorderable : Bool) : Nil #

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


def show_border : Bool #

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


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.


def show_border? : Bool #

def show_tabs : Bool #

Returns whether the tabs of the notebook are shown.


def show_tabs=(show_tabs : Bool) : Nil #

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


def show_tabs? : Bool #

def switch_page_signal #

def tab_detachable(child : Gtk::Widget) : Bool #

Returns whether the tab contents can be detached from @notebook.


def tab_label(child : Gtk::Widget) : Gtk::Widget? #

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.


def tab_label_text(child : Gtk::Widget) : String? #

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


def tab_pos : Gtk::PositionType #

Gets the edge at which the tabs are drawn.


def tab_pos=(pos : Gtk::PositionType) : Nil #

Sets the edge at which the tabs are drawn.


def tab_reorderable(child : Gtk::Widget) : Bool #

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