Class: Gtk::Notebook

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#append_page(child, tab_label) ⇒ Integer

Appends a page to notebook.

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

Returns:

  • (Integer)

    the index (starting from 0) of the appended page in the notebook, or -1 if function fails

#append_page_menu(child, tab_label, menu_label) ⇒ Integer

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

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

  • menu_label (Gtk::Widget)

    the widget to use as a label for the page-switch menu, if that is enabled. If nil, and tab_label is a Gtk::Label or nil, then the menu label will be a newly created label with the same text as tab_label; if tab_label is not a Gtk::Label, menu_label must be specified if the page-switch menu is to be used.

Returns:

  • (Integer)

    the index (starting from 0) of the appended page in the notebook, or -1 if function fails

#current_pageInteger

Returns the page number of the current page.

Returns:

  • (Integer)

    the index (starting from 0) of the current page in the notebook. If the notebook has no pages, then -1 will be returned.

#current_page=(page_num) ⇒ nil

Switches to the page number page_num.

Note that due to historical reasons, GtkNotebook 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.

Parameters:

  • page_num (Integer)

    index of the page to switch to, starting from 0. If negative, the last page will be used. If greater than the number of pages in the notebook, nothing will be done.

Returns:

  • (nil)

#detach_tab(child) ⇒ nil

Removes the child from the notebook.

This function is very similar to gtk_container_remove(), but additionally informs the notebook that the removal is happening as part of a tab DND operation, which should not be cancelled.

Parameters:

Returns:

  • (nil)

#enable_popup=(enable_popup) ⇒ TrueClass

Parameters:

  • enable_popup (TrueClass)

Returns:

  • (TrueClass)

    enable-popup

  • (TrueClass)

    enable-popup

#enable_popup?TrueClass

Returns enable-popup.

Returns:

  • (TrueClass)

    enable-popup

#get_action_widget(pack_type) ⇒ Gtk::Widget

Gets one of the action widgets. See gtk_notebook_set_action_widget(). pack_type or nil when this action widget has not been set

Parameters:

  • pack_type (Gtk::PackType)

    pack type of the action widget to receive

Returns:

#get_menu_label(child) ⇒ Gtk::Widget

Retrieves the menu label widget of the page containing child. notebook page does not have a menu label other than the default (the tab label).

Parameters:

  • child (Gtk::Widget)

    a widget contained in a page of notebook

Returns:

#get_menu_label_text(child) ⇒ String

Retrieves the text of the menu label for the page containing child. not have a menu label other than the default menu label, or the menu label widget is not a Gtk::Label. The string is owned by the widget and must not be freed.

Parameters:

  • child (Gtk::Widget)

    the child widget of a page of the notebook.

Returns:

  • (String)

    the text of the tab label, or nil if the widget does

#get_nth_page(page_num) ⇒ Gtk::Widget

Returns the child widget contained in page number page_num. is out of bounds

Parameters:

  • page_num (Integer)

    the index of a page in the notebook, or -1 to get the last page

Returns:

  • (Gtk::Widget)

    the child widget, or nil if page_num

#get_tab_detachable(child) ⇒ TrueClass

Returns whether the tab contents can be detached from notebook.

Parameters:

Returns:

  • (TrueClass)

    true if the tab is detachable.

#get_tab_label(child) ⇒ 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.

Parameters:

Returns:

#get_tab_label_text(child) ⇒ String

Retrieves the text of the tab label for the page containing child. widget is not a Gtk::Label. The string is owned by the widget and must not be freed.

Parameters:

  • child (Gtk::Widget)

    a widget contained in a page of notebook

Returns:

  • (String)

    the text of the tab label, or nil if the tab label

#get_tab_reorderable(child) ⇒ TrueClass

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

Parameters:

Returns:

  • (TrueClass)

    true if the tab is reorderable.

#group_nameString

Group name for tab drag and drop.

Returns:

  • (String)

    group-name

#group_name=(group_name) ⇒ String

Group name for tab drag and drop.

Parameters:

  • group_name (String)

Returns:

  • (String)

    group-name

  • (String)

    group-name

#insert_page(child, tab_label, position) ⇒ Integer

Insert a page into notebook at the given position.

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

  • position (Integer)

    the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages

Returns:

  • (Integer)

    the index (starting from 0) of the inserted page in the notebook, or -1 if function fails

#insert_page_menu(child, tab_label, menu_label, position) ⇒ Integer

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

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

  • menu_label (Gtk::Widget)

    the widget to use as a label for the page-switch menu, if that is enabled. If nil, and tab_label is a Gtk::Label or nil, then the menu label will be a newly created label with the same text as tab_label; if tab_label is not a Gtk::Label, menu_label must be specified if the page-switch menu is to be used.

  • position (Integer)

    the index (starting at 0) at which to insert the page, or -1 to append the page after all other pages.

Returns:

  • (Integer)

    the index (starting from 0) of the inserted page in the notebook

#n_pagesInteger

Gets the number of pages in a notebook.

Returns:

  • (Integer)

    the number of pages in the notebook

#newGtk::Widget

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

Returns:

#next_pagenil

Switches to the next page. Nothing happens if the current page is the last page.

Returns:

  • (nil)

#pageInteger

Returns page.

Returns:

  • (Integer)

    page

#page=(page) ⇒ Integer

Parameters:

  • page (Integer)

Returns:

  • (Integer)

    page

  • (Integer)

    page

#page_num(child) ⇒ Integer

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

Parameters:

Returns:

  • (Integer)

    the index of the page containing child, or -1 if child is not in the notebook

Disables the popup menu.

Returns:

  • (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.

Returns:

  • (nil)

#prepend_page(child, tab_label) ⇒ Integer

Prepends a page to notebook.

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

Returns:

  • (Integer)

    the index (starting from 0) of the prepended page in the notebook, or -1 if function fails

#prepend_page_menu(child, tab_label, menu_label) ⇒ Integer

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

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to use as the contents of the page

  • tab_label (Gtk::Widget)

    the Gtk::Widget to be used as the label for the page, or nil to use the default label, “page N”

  • menu_label (Gtk::Widget)

    the widget to use as a label for the page-switch menu, if that is enabled. If nil, and tab_label is a Gtk::Label or nil, then the menu label will be a newly created label with the same text as tab_label; if tab_label is not a Gtk::Label, menu_label must be specified if the page-switch menu is to be used.

Returns:

  • (Integer)

    the index (starting from 0) of the prepended page in the notebook, or -1 if function fails

#prev_pagenil

Switches to the previous page. Nothing happens if the current page is the first page.

Returns:

  • (nil)

#remove_page(page_num) ⇒ nil

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

Parameters:

  • page_num (Integer)

    the index of a notebook page, starting from 0. If -1, the last page will be removed.

Returns:

  • (nil)

#reorder_child(child, position) ⇒ 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.

Parameters:

  • child (Gtk::Widget)

    the child to move

  • position (Integer)

    the new position, or -1 to move to the end

Returns:

  • (nil)

#scrollableTrueClass

Returns whether the tab label area has arrows for scrolling. See gtk_notebook_set_scrollable().

Returns:

  • (TrueClass)

    true if arrows for scrolling are present

#scrollable=(scrollable) ⇒ TrueClass

Parameters:

  • scrollable (TrueClass)

Returns:

  • (TrueClass)

    scrollable

  • (TrueClass)

    scrollable

#scrollable?TrueClass

Returns scrollable.

Returns:

  • (TrueClass)

    scrollable

#set_action_widget(widget, pack_type) ⇒ 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.

Note that action widgets are “internal” children of the notebook and thus not included in the list returned from gtk_container_foreach().

Parameters:

Returns:

  • (nil)

#set_menu_label(child, menu_label) ⇒ nil

Changes the menu label for the page containing child.

Parameters:

Returns:

  • (nil)

#set_menu_label_text(child, menu_text) ⇒ nil

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

Parameters:

  • child (Gtk::Widget)

    the child widget

  • menu_text (String)

    the label text

Returns:

  • (nil)

#set_tab_detachable(child, detachable) ⇒ nil

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

Note that 2 notebooks must share a common group identificator (see gtk_notebook_set_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 GtkWidget** pointing to the child widget that corresponds to the dropped tab.

Note that you should use gtk_notebook_detach_tab() instead of gtk_container_remove() 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.

static void
on_drag_data_received (GtkWidget        *widget,
                       GdkDragContext   *context,
                       gint              x,
                       gint              y,
                       GtkSelectionData *data,
                       guint             info,
                       guint             time,
                       gpointer          user_data)
{
  GtkWidget *notebook;
  GtkWidget **child;

  notebook = gtk_drag_get_source_widget (context);
  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.

Parameters:

  • child (Gtk::Widget)

    a child Gtk::Widget

  • detachable (TrueClass)

    whether the tab is detachable or not

Returns:

  • (nil)

#set_tab_label(child, tab_label) ⇒ nil

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

Parameters:

  • child (Gtk::Widget)

    the page

  • tab_label (Gtk::Widget)

    the tab label widget to use, or nil for default tab label

Returns:

  • (nil)

#set_tab_label_text(child, tab_text) ⇒ nil

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

Parameters:

  • child (Gtk::Widget)

    the page

  • tab_text (String)

    the label text

Returns:

  • (nil)

#set_tab_reorderable(child, reorderable) ⇒ nil

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

Parameters:

  • child (Gtk::Widget)

    a child Gtk::Widget

  • reorderable (TrueClass)

    whether the tab is reorderable or not

Returns:

  • (nil)

#show_borderTrueClass

Returns whether a bevel will be drawn around the notebook pages. See gtk_notebook_set_show_border().

Returns:

  • (TrueClass)

    true if the bevel is drawn

#show_border=(show_border) ⇒ TrueClass

Parameters:

  • show_border (TrueClass)

Returns:

  • (TrueClass)

    show-border

  • (TrueClass)

    show-border

#show_border?TrueClass

Returns show-border.

Returns:

  • (TrueClass)

    show-border

#show_tabsTrueClass

Returns whether the tabs of the notebook are shown. See gtk_notebook_set_show_tabs().

Returns:

  • (TrueClass)

    true if the tabs are shown

#show_tabs=(show_tabs) ⇒ TrueClass

Parameters:

  • show_tabs (TrueClass)

Returns:

  • (TrueClass)

    show-tabs

  • (TrueClass)

    show-tabs

#show_tabs?TrueClass

Returns show-tabs.

Returns:

  • (TrueClass)

    show-tabs

#tab_hborderInteger

Returns the horizontal width of a tab border.

Returns:

  • (Integer)

    horizontal width of a tab border

#tab_posGtk::PositionType

Returns tab-pos.

Returns:

#tab_pos=(tab_pos) ⇒ Gtk::PositionType

Parameters:

Returns:

#tab_vborderInteger

Returns the vertical width of a tab border.

Returns:

  • (Integer)

    vertical width of a tab border