Trait gtk::prelude::ListBoxExt
source · [−]pub trait ListBoxExt: 'static {
Show 42 methods
fn bind_model<P: Fn(&Object) -> Widget + 'static>(
&self,
model: Option<&impl IsA<ListModel>>,
create_widget_func: P
);
fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>);
fn drag_unhighlight_row(&self);
fn activates_on_single_click(&self) -> bool;
fn adjustment(&self) -> Option<Adjustment>;
fn row_at_index(&self, index_: i32) -> Option<ListBoxRow>;
fn row_at_y(&self, y: i32) -> Option<ListBoxRow>;
fn selected_row(&self) -> Option<ListBoxRow>;
fn selected_rows(&self) -> Vec<ListBoxRow>;
fn selection_mode(&self) -> SelectionMode;
fn insert(&self, child: &impl IsA<Widget>, position: i32);
fn invalidate_filter(&self);
fn invalidate_headers(&self);
fn invalidate_sort(&self);
fn prepend(&self, child: &impl IsA<Widget>);
fn select_all(&self);
fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>);
fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P);
fn set_activate_on_single_click(&self, single: bool);
fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>);
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>
);
fn set_header_func(
&self,
update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>
);
fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>);
fn set_selection_mode(&self, mode: SelectionMode);
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
);
fn unselect_all(&self);
fn unselect_row(&self, row: &impl IsA<ListBoxRow>);
fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_activate_cursor_row(&self);
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_move_cursor(&self, object: MovementStep, p0: i32);
fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_select_all<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_select_all(&self);
fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn emit_toggle_cursor_row(&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_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 GtkListBox. 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
or None
in case you also passed None
as model
fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>)
fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>)
This is a helper function for implementing DnD onto a ListBox
.
The passed in row
will be highlighted via WidgetExt::drag_highlight()
,
and any previously highlighted row will be unhighlighted.
The row will also be unhighlighted when the widget gets a drag leave event.
row
fn drag_unhighlight_row(&self)
fn drag_unhighlight_row(&self)
If a row has previously been highlighted via drag_highlight_row()
it will have the highlight removed.
fn activates_on_single_click(&self) -> bool
fn activates_on_single_click(&self) -> bool
fn adjustment(&self) -> Option<Adjustment>
fn adjustment(&self) -> Option<Adjustment>
fn row_at_index(&self, index_: i32) -> Option<ListBoxRow>
fn row_at_index(&self, index_: i32) -> Option<ListBoxRow>
fn row_at_y(&self, y: i32) -> Option<ListBoxRow>
fn row_at_y(&self, y: i32) -> Option<ListBoxRow>
fn selected_row(&self) -> Option<ListBoxRow>
fn selected_row(&self) -> Option<ListBoxRow>
Gets the selected row.
Note that the box may allow multiple selection, in which
case you should use selected_foreach()
to
find all selected rows.
Returns
the selected row
fn selected_rows(&self) -> Vec<ListBoxRow>
fn selected_rows(&self) -> Vec<ListBoxRow>
fn selection_mode(&self) -> SelectionMode
fn selection_mode(&self) -> SelectionMode
Insert the child
into the 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 of ContainerExt::add()
.
If position
is -1, or larger than the total number of items in the
self
, then the child
will be appended to the end.
child
the Widget
to add
position
the position to insert child
in
fn invalidate_filter(&self)
fn invalidate_filter(&self)
Update the filtering for all rows. Call this when result
of the filter function on the self
is changed due
to an external factor. For instance, this would be used
if the filter function just looked for a specific search
string and the entry with the search string has changed.
fn invalidate_headers(&self)
fn invalidate_headers(&self)
Update the separators for all rows. Call this when result
of the header function on the self
is changed due
to an external factor.
fn invalidate_sort(&self)
fn invalidate_sort(&self)
Update the sorting for all rows. Call this when result
of the sort function on the self
is changed due
to an external factor.
Prepend a widget to the list. If a sort function is set, the widget will
actually be inserted at the calculated position and this function has the
same effect of ContainerExt::add()
.
child
the Widget
to add
fn select_all(&self)
fn select_all(&self)
Select all children of self
, if the selection mode allows it.
fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>)
fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>)
fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P)
fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&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_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>)
fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>)
Sets the adjustment (if any) that the widget uses to for vertical scrolling. For instance, this is used to get the page size for PageUp/Down key handling.
In the normal case when the self
is packed inside
a ScrolledWindow
the adjustment from that will
be picked up automatically, so there is no need
to manually do that.
adjustment
the adjustment, or None
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>
)
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>
)
By setting a filter function on the self
one can decide dynamically which
of the rows to show. For instance, to implement a search function on a list that
filters the original list to only show the matching rows.
The filter_func
will be called for each row after the call, and it will
continue to be called each time a row changes (via ListBoxRowExt::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 rows to show
fn set_header_func(
&self,
update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>
)
fn set_header_func(
&self,
update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>
)
By setting a header function on the self
one can dynamically add headers
in front of rows, depending on the contents of the row and its position in the list.
For instance, one could use it to add headers in front of the first item of a
new kind, in a list sorted by the kind.
The update_header
can look at the current header widget using ListBoxRowExt::header()
and either update the state of the widget as needed, or set a new one using
ListBoxRowExt::set_header()
. If no header is needed, set the header to None
.
Note that you may get many calls update_header
to this for a particular row when e.g.
changing things that don’t affect the header. In this case it is important for performance
to not blindly replace an existing header with an identical one.
The update_header
function will be called for each row after the call, and it will
continue to be called each time a row changes (via ListBoxRowExt::changed()
) and when
the row before changes (either by ListBoxRowExt::changed()
on the previous row, or when
the previous row becomes a different row). It is also called for all rows when
invalidate_headers()
is called.
update_header
callback that lets you add row headers
fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>)
fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>)
Sets the placeholder widget that is shown in the list when it doesn’t display any visible children.
placeholder
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(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
)
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
)
By setting a sort function on the self
one can dynamically reorder the rows
of the list, based on the contents of the rows.
The sort_func
will be called for each row after the call, and will continue to
be called each time a row changes (via ListBoxRowExt::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 unselect_all(&self)
fn unselect_all(&self)
Unselect all children of self
, if the selection mode allows it.
fn unselect_row(&self, row: &impl IsA<ListBoxRow>)
fn unselect_row(&self, row: &impl IsA<ListBoxRow>)
fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn emit_activate_cursor_row(&self)
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn emit_move_cursor(&self, object: MovementStep, p0: i32)
fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::row-activated signal is emitted when a row has been activated by the user.
row
the activated row
fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::row-selected signal is emitted when a new row is selected, or
(with a None
row
) when the selection is cleared.
When the box_
is using SelectionMode::Multiple
, this signal will not
give you the full picture of selection changes, and you should use
the signal::ListBox::selected-rows-changed
signal instead.
row
the selected row
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_rows_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::selected-rows-changed signal is emitted when the set of selected rows changes.
fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn emit_toggle_cursor_row(&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.