Trait gtk::prelude::FlowBoxExt
source · [−]pub trait FlowBoxExt: 'static {
Show 49 methods
fn bind_model<P: Fn(&Object) -> Widget + 'static>(
&self,
model: Option<&impl IsA<ListModel>>,
create_widget_func: P
);
fn activates_on_single_click(&self) -> bool;
fn child_at_index(&self, idx: i32) -> Option<FlowBoxChild>;
fn child_at_pos(&self, x: i32, y: i32) -> Option<FlowBoxChild>;
fn column_spacing(&self) -> u32;
fn is_homogeneous(&self) -> bool;
fn max_children_per_line(&self) -> u32;
fn min_children_per_line(&self) -> u32;
fn row_spacing(&self) -> u32;
fn selected_children(&self) -> Vec<FlowBoxChild>;
fn selection_mode(&self) -> SelectionMode;
fn insert(&self, widget: &impl IsA<Widget>, position: i32);
fn invalidate_filter(&self);
fn invalidate_sort(&self);
fn select_all(&self);
fn select_child(&self, child: &impl IsA<FlowBoxChild>);
fn selected_foreach<P: FnMut(&FlowBox, &FlowBoxChild)>(&self, func: P);
fn set_activate_on_single_click(&self, single: bool);
fn set_column_spacing(&self, spacing: u32);
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&FlowBoxChild) -> bool + 'static>>
);
fn set_hadjustment(&self, adjustment: &impl IsA<Adjustment>);
fn set_homogeneous(&self, homogeneous: bool);
fn set_max_children_per_line(&self, n_children: u32);
fn set_min_children_per_line(&self, n_children: u32);
fn set_row_spacing(&self, spacing: u32);
fn set_selection_mode(&self, mode: SelectionMode);
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&FlowBoxChild, &FlowBoxChild) -> i32 + 'static>>
);
fn set_vadjustment(&self, adjustment: &impl IsA<Adjustment>);
fn unselect_all(&self);
fn unselect_child(&self, child: &impl IsA<FlowBoxChild>);
fn connect_activate_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_activate_cursor_child(&self);
fn connect_child_activated<F: Fn(&Self, &FlowBoxChild) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_move_cursor(&self, step: MovementStep, count: i32) -> bool;
fn connect_select_all<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_select_all(&self);
fn connect_selected_children_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_toggle_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_toggle_cursor_child(&self);
fn connect_unselect_all<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_unselect_all(&self);
fn connect_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_column_spacing_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_homogeneous_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_max_children_per_line_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_min_children_per_line_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_row_spacing_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_selection_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods
Binds model
to self
.
If self
was already bound to a model, that previous binding is
destroyed.
The contents of self
are cleared and then filled with widgets that
represent items from model
. self
is updated whenever model
changes.
If model
is None
, self
is left empty.
It is undefined to add or remove widgets directly (for example, with
insert()
or ContainerExt::add()
) while self
is bound to a
model.
Note that using a model is incompatible with the filtering and sorting functionality in GtkFlowBox. When using a model, filtering and sorting should be implemented by the model.
model
the gio::ListModel
to be bound to self
create_widget_func
a function that creates widgets for items
fn activates_on_single_click(&self) -> bool
fn activates_on_single_click(&self) -> bool
fn child_at_index(&self, idx: i32) -> Option<FlowBoxChild>
fn child_at_index(&self, idx: i32) -> Option<FlowBoxChild>
Gets the nth child in the self
.
idx
the position of the child
Returns
the child widget, which will
always be a FlowBoxChild
or None
in case no child widget
with the given index exists.
fn child_at_pos(&self, x: i32, y: i32) -> Option<FlowBoxChild>
fn child_at_pos(&self, x: i32, y: i32) -> Option<FlowBoxChild>
v3_22_6
only.Gets the child in the (x
, y
) position.
x
the x coordinate of the child
y
the y coordinate of the child
Returns
the child widget, which will
always be a FlowBoxChild
or None
in case no child widget
exists for the given x and y coordinates.
fn column_spacing(&self) -> u32
fn column_spacing(&self) -> u32
fn is_homogeneous(&self) -> bool
fn is_homogeneous(&self) -> bool
Returns whether the box is homogeneous (all children are the
same size). See BoxExt::set_homogeneous()
.
Returns
true
if the box is homogeneous.
fn max_children_per_line(&self) -> u32
fn max_children_per_line(&self) -> u32
fn min_children_per_line(&self) -> u32
fn min_children_per_line(&self) -> u32
fn row_spacing(&self) -> u32
fn row_spacing(&self) -> u32
fn selected_children(&self) -> Vec<FlowBoxChild>
fn selected_children(&self) -> Vec<FlowBoxChild>
fn selection_mode(&self) -> SelectionMode
fn selection_mode(&self) -> SelectionMode
Inserts the widget
into self
at position
.
If a sort function is set, the widget will actually be inserted
at the calculated position and this function has the same effect
as ContainerExt::add()
.
If position
is -1, or larger than the total number of children
in the self
, then the widget
will be appended to the end.
widget
the Widget
to add
position
the position to insert child
in
fn invalidate_filter(&self)
fn invalidate_filter(&self)
Updates the filtering for all children.
Call this function when the result of the filter
function on the self
is changed due ot an external
factor. For instance, this would be used if the
filter function just looked for a specific search
term, and the entry with the string has changed.
fn invalidate_sort(&self)
fn invalidate_sort(&self)
Updates the sorting for all children.
Call this when the result of the sort function on
self
is changed due to an external factor.
fn select_all(&self)
fn select_all(&self)
Select all children of self
, if the selection
mode allows it.
fn select_child(&self, child: &impl IsA<FlowBoxChild>)
fn select_child(&self, child: &impl IsA<FlowBoxChild>)
fn selected_foreach<P: FnMut(&FlowBox, &FlowBoxChild)>(&self, func: P)
fn selected_foreach<P: FnMut(&FlowBox, &FlowBoxChild)>(&self, func: P)
Calls a function for each selected child.
Note that the selection cannot be modified from within this function.
func
the function to call for each selected child
fn set_activate_on_single_click(&self, single: bool)
fn set_activate_on_single_click(&self, single: bool)
fn set_column_spacing(&self, spacing: u32)
fn set_column_spacing(&self, spacing: u32)
Sets the horizontal space to add between children.
See the property::FlowBox::column-spacing
property.
spacing
the spacing to use
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&FlowBoxChild) -> bool + 'static>>
)
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&FlowBoxChild) -> bool + 'static>>
)
By setting a filter function on the self
one can decide dynamically
which of the children to show. For instance, to implement a search
function that only shows the children matching the search terms.
The filter_func
will be called for each child after the call, and
it will continue to be called each time a child changes (via
FlowBoxChildExt::changed()
) or when invalidate_filter()
is called.
Note that using a filter function is incompatible with using a model
(see bind_model()
).
filter_func
callback that lets you filter which children to show
fn set_hadjustment(&self, adjustment: &impl IsA<Adjustment>)
fn set_hadjustment(&self, adjustment: &impl IsA<Adjustment>)
Hooks up an adjustment to focus handling in self
.
The adjustment is also used for autoscrolling during
rubberband selection. See ScrolledWindowExt::hadjustment()
for a typical way of obtaining the adjustment, and
set_vadjustment()
for setting the vertical
adjustment.
The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.
adjustment
an adjustment which should be adjusted
when the focus is moved among the descendents of container
fn set_homogeneous(&self, homogeneous: bool)
fn set_homogeneous(&self, homogeneous: bool)
Sets the property::FlowBox::homogeneous
property of self
, controlling
whether or not all children of self
are given equal space
in the box.
homogeneous
true
to create equal allotments,
false
for variable allotments
fn set_max_children_per_line(&self, n_children: u32)
fn set_max_children_per_line(&self, n_children: u32)
Sets the maximum number of children to request and
allocate space for in self
’s orientation.
Setting the maximum number of children per line
limits the overall natural size request to be no more
than n_children
children long in the given orientation.
n_children
the maximum number of children per line
fn set_min_children_per_line(&self, n_children: u32)
fn set_min_children_per_line(&self, n_children: u32)
Sets the minimum number of children to line up
in self
’s orientation before flowing.
n_children
the minimum number of children per line
fn set_row_spacing(&self, spacing: u32)
fn set_row_spacing(&self, spacing: u32)
Sets the vertical space to add between children.
See the property::FlowBox::row-spacing
property.
spacing
the spacing to use
fn set_selection_mode(&self, mode: SelectionMode)
fn set_selection_mode(&self, mode: SelectionMode)
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&FlowBoxChild, &FlowBoxChild) -> i32 + 'static>>
)
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&FlowBoxChild, &FlowBoxChild) -> i32 + 'static>>
)
By setting a sort function on the self
, one can dynamically
reorder the children of the box, based on the contents of
the children.
The sort_func
will be called for each child after the call,
and will continue to be called each time a child changes (via
FlowBoxChildExt::changed()
) and when invalidate_sort()
is called.
Note that using a sort function is incompatible with using a model
(see bind_model()
).
sort_func
the sort function
fn set_vadjustment(&self, adjustment: &impl IsA<Adjustment>)
fn set_vadjustment(&self, adjustment: &impl IsA<Adjustment>)
Hooks up an adjustment to focus handling in self
.
The adjustment is also used for autoscrolling during
rubberband selection. See ScrolledWindowExt::vadjustment()
for a typical way of obtaining the adjustment, and
set_hadjustment()
for setting the horizontal
adjustment.
The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the box.
adjustment
an adjustment which should be adjusted
when the focus is moved among the descendents of container
fn unselect_all(&self)
fn unselect_all(&self)
Unselect all children of self
, if the selection
mode allows it.
fn unselect_child(&self, child: &impl IsA<FlowBoxChild>)
fn unselect_child(&self, child: &impl IsA<FlowBoxChild>)
fn connect_activate_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_activate_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::activate-cursor-child signal is a
[keybinding signal][GtkBindingSignal]
which gets emitted when the user activates the box_
.
fn emit_activate_cursor_child(&self)
fn connect_child_activated<F: Fn(&Self, &FlowBoxChild) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_child_activated<F: Fn(&Self, &FlowBoxChild) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::child-activated signal is emitted when a child has been activated by the user.
child
the child that is activated
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::move-cursor signal is a [keybinding signal][GtkBindingSignal] which gets emitted when the user initiates a cursor movement.
Applications should not connect to it, but may emit it with
g_signal_emit_by_name()
if they need to control the cursor
programmatically.
The default bindings for this signal come in two variants, the variant with the Shift modifier extends the selection, the variant without the Shift modifer does not. There are too many key combinations to list them all here.
- Arrow keys move by individual children
- Home/End keys move to the ends of the box
- PageUp/PageDown keys move vertically by pages
step
the granularity fo the move, as a MovementStep
count
the number of step
units to move
Returns
true
to stop other handlers from being invoked for the event.
false
to propagate the event further.
fn emit_move_cursor(&self, step: MovementStep, count: i32) -> bool
fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::select-all signal is a [keybinding signal][GtkBindingSignal] which gets emitted to select all children of the box, if the selection mode permits it.
The default bindings for this signal is Ctrl-a.
fn emit_select_all(&self)
fn connect_selected_children_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_selected_children_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::selected-children-changed signal is emitted when the set of selected children changes.
Use selected_foreach()
or
selected_children()
to obtain the
selected children.
fn connect_toggle_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_toggle_cursor_child<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::toggle-cursor-child signal is a [keybinding signal][GtkBindingSignal] which toggles the selection of the child that has the focus.
The default binding for this signal is Ctrl-Space.
fn emit_toggle_cursor_child(&self)
fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::unselect-all signal is a [keybinding signal][GtkBindingSignal] which gets emitted to unselect all children of the box, if the selection mode permits it.
The default bindings for this signal is Ctrl-Shift-a.