Trait gtk::prelude::NotebookExt
source · [−]pub trait NotebookExt: 'static {
Show 55 methods
fn detach_tab(&self, child: &impl IsA<Widget>);
fn action_widget(&self, pack_type: PackType) -> Option<Widget>;
fn group_name(&self) -> Option<GString>;
fn menu_label(&self, child: &impl IsA<Widget>) -> Option<Widget>;
fn menu_label_text(&self, child: &impl IsA<Widget>) -> Option<GString>;
fn is_scrollable(&self) -> bool;
fn shows_border(&self) -> bool;
fn shows_tabs(&self) -> bool;
fn tab_is_detachable(&self, child: &impl IsA<Widget>) -> bool;
fn tab_label(&self, child: &impl IsA<Widget>) -> Option<Widget>;
fn tab_label_text(&self, child: &impl IsA<Widget>) -> Option<GString>;
fn tab_pos(&self) -> PositionType;
fn tab_is_reorderable(&self, child: &impl IsA<Widget>) -> bool;
fn next_page(&self);
fn popup_disable(&self);
fn popup_enable(&self);
fn prev_page(&self);
fn set_action_widget(&self, widget: &impl IsA<Widget>, pack_type: PackType);
fn set_group_name(&self, group_name: Option<&str>);
fn set_menu_label(
&self,
child: &impl IsA<Widget>,
menu_label: Option<&impl IsA<Widget>>
);
fn set_menu_label_text(&self, child: &impl IsA<Widget>, menu_text: &str);
fn set_scrollable(&self, scrollable: bool);
fn set_show_border(&self, show_border: bool);
fn set_show_tabs(&self, show_tabs: bool);
fn set_tab_detachable(&self, child: &impl IsA<Widget>, detachable: bool);
fn set_tab_label(
&self,
child: &impl IsA<Widget>,
tab_label: Option<&impl IsA<Widget>>
);
fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str);
fn set_tab_pos(&self, pos: PositionType);
fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool);
fn enables_popup(&self) -> bool;
fn set_enable_popup(&self, enable_popup: bool);
fn page(&self) -> i32;
fn set_page(&self, page: i32);
fn connect_change_current_page<F: Fn(&Self, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_change_current_page(&self, object: i32) -> bool;
fn connect_create_window<F: Fn(&Self, &Widget, i32, i32) -> Notebook + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_focus_tab<F: Fn(&Self, NotebookTab) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_focus_tab(&self, object: NotebookTab) -> bool;
fn connect_move_focus_out<F: Fn(&Self, DirectionType) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_move_focus_out(&self, object: DirectionType);
fn connect_page_added<F: Fn(&Self, &Widget, u32) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_page_removed<F: Fn(&Self, &Widget, u32) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_page_reordered<F: Fn(&Self, &Widget, u32) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_reorder_tab<F: Fn(&Self, DirectionType, bool) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_reorder_tab(&self, object: DirectionType, p0: bool) -> bool;
fn connect_select_page<F: Fn(&Self, bool) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_select_page(&self, object: bool) -> bool;
fn connect_switch_page<F: Fn(&Self, &Widget, u32) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_enable_popup_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_group_name_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_page_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_scrollable_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_show_border_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_show_tabs_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_tab_pos_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods
fn detach_tab(&self, child: &impl IsA<Widget>)
fn detach_tab(&self, child: &impl IsA<Widget>)
Removes the child from the notebook.
This function is very similar to ContainerExt::remove()
,
but additionally informs the notebook that the removal
is happening as part of a tab DND operation, which should
not be cancelled.
child
a child
fn action_widget(&self, pack_type: PackType) -> Option<Widget>
fn action_widget(&self, pack_type: PackType) -> Option<Widget>
Gets one of the action widgets. See set_action_widget()
.
pack_type
pack type of the action widget to receive
Returns
The action widget with the given
pack_type
or None
when this action widget has not been set
fn group_name(&self) -> Option<GString>
fn group_name(&self) -> Option<GString>
Retrieves the text of the menu label for the page containing
child
.
child
the child widget of a page of the notebook.
Returns
the text of the tab label, or None
if the widget does
not have a menu label other than the default menu label, or the menu label
widget is not a Label
. The string is owned by the widget and must not be
freed.
fn is_scrollable(&self) -> bool
fn is_scrollable(&self) -> bool
Returns whether the tab label area has arrows for scrolling.
See set_scrollable()
.
Returns
true
if arrows for scrolling are present
fn shows_border(&self) -> bool
fn shows_border(&self) -> bool
Returns whether a bevel will be drawn around the notebook pages.
See set_show_border()
.
Returns
true
if the bevel is drawn
fn shows_tabs(&self) -> bool
fn shows_tabs(&self) -> bool
Returns whether the tabs of the notebook are shown.
See set_show_tabs()
.
Returns
true
if the tabs are shown
fn tab_is_detachable(&self, child: &impl IsA<Widget>) -> bool
fn tab_is_detachable(&self, child: &impl IsA<Widget>) -> bool
fn tab_pos(&self) -> PositionType
fn tab_pos(&self) -> PositionType
Gets the edge at which the tabs for switching pages in the notebook are drawn.
Returns
the edge at which the tabs are drawn
fn tab_is_reorderable(&self, child: &impl IsA<Widget>) -> bool
fn tab_is_reorderable(&self, child: &impl IsA<Widget>) -> bool
Switches to the next page. Nothing happens if the current page is the last page.
fn popup_disable(&self)
fn popup_disable(&self)
Disables the popup menu.
fn popup_enable(&self)
fn popup_enable(&self)
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.
Switches to the previous page. Nothing happens if the current page is the first page.
fn set_action_widget(&self, widget: &impl IsA<Widget>, pack_type: PackType)
fn set_action_widget(&self, widget: &impl IsA<Widget>, pack_type: PackType)
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 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 ContainerExt::foreach()
.
widget
a Widget
pack_type
pack type of the action widget
fn set_group_name(&self, group_name: Option<&str>)
fn set_group_name(&self, group_name: Option<&str>)
Sets a group name for self
.
Notebooks with the same name will be able to exchange tabs
via drag and drop. A notebook with a None
group name will
not be able to exchange tabs with any other notebook.
group_name
the name of the notebook group,
or None
to unset it
Changes the menu label for the page containing child
.
child
the child widget
menu_label
the menu label, or None
for default
fn set_scrollable(&self, scrollable: bool)
fn set_scrollable(&self, scrollable: bool)
Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.
scrollable
true
if scroll arrows should be added
fn set_show_border(&self, show_border: bool)
fn set_show_border(&self, show_border: bool)
Sets whether a bevel will be drawn around the notebook pages.
This only has a visual effect when the tabs are not shown.
See set_show_tabs()
.
show_border
true
if a bevel should be drawn around the notebook
fn set_show_tabs(&self, show_tabs: bool)
fn set_show_tabs(&self, show_tabs: bool)
fn set_tab_detachable(&self, child: &impl IsA<Widget>, detachable: bool)
fn set_tab_detachable(&self, child: &impl IsA<Widget>, detachable: bool)
Sets whether the tab can be detached from self
to another
notebook or widget.
Note that 2 notebooks must share a common group identificator
(see 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 detach_tab()
instead
of ContainerExt::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.
⚠️ The following code is in C ⚠️
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.
child
a child Widget
detachable
whether the tab is detachable or not
fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str)
fn set_tab_label_text(&self, child: &impl IsA<Widget>, tab_text: &str)
fn set_tab_pos(&self, pos: PositionType)
fn set_tab_pos(&self, pos: PositionType)
Sets the edge at which the tabs for switching pages in the notebook are drawn.
pos
the edge to draw the tabs at
fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool)
fn set_tab_reorderable(&self, child: &impl IsA<Widget>, reorderable: bool)
Sets whether the notebook tab can be reordered via drag and drop or not.
child
a child Widget
reorderable
whether the tab is reorderable or not
fn enables_popup(&self) -> bool
fn set_enable_popup(&self, enable_popup: bool)
fn connect_change_current_page<F: Fn(&Self, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn emit_change_current_page(&self, object: i32) -> bool
fn connect_create_window<F: Fn(&Self, &Widget, i32, i32) -> Notebook + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_create_window<F: Fn(&Self, &Widget, i32, i32) -> Notebook + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::create-window signal is emitted when a detachable tab is dropped on the root window.
A handler for this signal can create a window containing
a notebook where the tab will be attached. It is also
responsible for moving/resizing the window and adding the
necessary properties to the notebook (e.g. the
property::Notebook::group-name
).
page
the tab of notebook
that is being detached
x
the X coordinate where the drop happens
y
the Y coordinate where the drop happens