[−][src]Trait gtk::ListBoxExt
Required methods
fn bind_model<P: IsA<ListModel>, Q: Fn(&Object) -> Widget + 'static>(
&self,
model: Option<&P>,
create_widget_func: Q
)
&self,
model: Option<&P>,
create_widget_func: Q
)
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
ListBoxExt::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 ListBox
. When using a model, filtering and sorting
should be implemented by the model.
Feature: v3_16
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
user_data
user data passed to create_widget_func
user_data_free_func
function for freeing user_data
fn drag_highlight_row<P: IsA<ListBoxRow>>(&self, row: &P)
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
a ListBoxRow
fn drag_unhighlight_row(&self)
If a row has previously been highlighted via ListBoxExt::drag_highlight_row
it will have the highlight removed.
fn get_activate_on_single_click(&self) -> bool
Returns whether rows activate on single clicks.
Returns
true
if rows are activated on single click, false
otherwise
fn get_adjustment(&self) -> Option<Adjustment>
fn get_row_at_index(&self, index_: i32) -> Option<ListBoxRow>
Gets the n-th child in the list (not counting headers).
If _index
is negative or larger than the number of items in the
list, None
is returned.
index_
the index of the row
Returns
the child Widget
or None
fn get_row_at_y(&self, y: i32) -> Option<ListBoxRow>
Gets the row at the y
position.
y
position
Returns
the row or None
in case no row exists for the given y coordinate.
fn get_selected_row(&self) -> Option<ListBoxRow>
Gets the selected row.
Note that the box may allow multiple selection, in which
case you should use ListBoxExt::selected_foreach
to
find all selected rows.
Returns
the selected row
fn get_selected_rows(&self) -> Vec<ListBoxRow>
Creates a list of all selected children.
Returns
A glib::List
containing the Widget
for each selected child.
Free with glib::List::free
when done.
fn get_selection_mode(&self) -> SelectionMode
fn insert<P: IsA<Widget>>(&self, child: &P, position: i32)
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)
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)
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)
Update the sorting for all rows. Call this when result
of the sort function on the self
is changed due
to an external factor.
fn prepend<P: IsA<Widget>>(&self, child: &P)
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)
Select all children of self
, if the selection mode allows it.
fn select_row<P: IsA<ListBoxRow>>(&self, row: Option<&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
data
user data to pass to the function
fn set_activate_on_single_click(&self, single: bool)
If single
is true
, rows will be activated when you click on them,
otherwise you need to double-click.
single
a boolean
fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: Option<&P>)
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>>
)
&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 ListBoxExt::invalidate_filter
is called.
Note that using a filter function is incompatible with using a model
(see ListBoxExt::bind_model
).
filter_func
callback that lets you filter which rows to show
user_data
user data passed to filter_func
destroy
destroy notifier for user_data
fn set_header_func(
&self,
update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>
)
&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::get_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
ListBoxExt::invalidate_headers
is called.
update_header
callback that lets you add row headers
user_data
user data passed to update_header
destroy
destroy notifier for user_data
fn set_placeholder<P: IsA<Widget>>(&self, placeholder: Option<&P>)
Sets the placeholder widget that is shown in the list when it doesn't display any visible children.
placeholder
a Widget
or None
fn set_selection_mode(&self, mode: SelectionMode)
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
)
&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
ListBoxExt::invalidate_sort
is called.
Note that using a sort function is incompatible with using a model
(see ListBoxExt::bind_model
).
sort_func
the sort function
user_data
user data passed to sort_func
destroy
destroy notifier for user_data
fn unselect_all(&self)
Unselect all children of self
, if the selection mode allows it.
fn unselect_row<P: IsA<ListBoxRow>>(&self, row: &P)
fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn emit_activate_cursor_row(&self)
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId
&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
&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
&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 ListBox::selected-rows-changed
signal instead.
row
the selected row
fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::select-all signal is a [keybinding signal][BindingSignal
]
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
&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
&self,
f: F
) -> SignalHandlerId
fn emit_toggle_cursor_row(&self)
fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::unselect-all signal is a [keybinding signal][BindingSignal
]
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.
fn emit_unselect_all(&self)
fn connect_property_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn connect_property_selection_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
Implementors
impl<O: IsA<ListBox>> ListBoxExt for O
[src]
fn bind_model<P: IsA<ListModel>, Q: Fn(&Object) -> Widget + 'static>(
&self,
model: Option<&P>,
create_widget_func: Q
)
[src]
&self,
model: Option<&P>,
create_widget_func: Q
)
fn drag_highlight_row<P: IsA<ListBoxRow>>(&self, row: &P)
[src]
fn drag_unhighlight_row(&self)
[src]
fn get_activate_on_single_click(&self) -> bool
[src]
fn get_adjustment(&self) -> Option<Adjustment>
[src]
fn get_row_at_index(&self, index_: i32) -> Option<ListBoxRow>
[src]
fn get_row_at_y(&self, y: i32) -> Option<ListBoxRow>
[src]
fn get_selected_row(&self) -> Option<ListBoxRow>
[src]
fn get_selected_rows(&self) -> Vec<ListBoxRow>
[src]
fn get_selection_mode(&self) -> SelectionMode
[src]
fn insert<P: IsA<Widget>>(&self, child: &P, position: i32)
[src]
fn invalidate_filter(&self)
[src]
fn invalidate_headers(&self)
[src]
fn invalidate_sort(&self)
[src]
fn prepend<P: IsA<Widget>>(&self, child: &P)
[src]
fn select_all(&self)
[src]
fn select_row<P: IsA<ListBoxRow>>(&self, row: Option<&P>)
[src]
fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P)
[src]
fn set_activate_on_single_click(&self, single: bool)
[src]
fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: Option<&P>)
[src]
fn set_filter_func(
&self,
filter_func: Option<Box_<dyn Fn(&ListBoxRow) -> bool + 'static>>
)
[src]
&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>>
)
[src]
&self,
update_header: Option<Box_<dyn Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>>
)
fn set_placeholder<P: IsA<Widget>>(&self, placeholder: Option<&P>)
[src]
fn set_selection_mode(&self, mode: SelectionMode)
[src]
fn set_sort_func(
&self,
sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
)
[src]
&self,
sort_func: Option<Box_<dyn Fn(&ListBoxRow, &ListBoxRow) -> i32 + 'static>>
)
fn unselect_all(&self)
[src]
fn unselect_row<P: IsA<ListBoxRow>>(&self, row: &P)
[src]
fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn emit_activate_cursor_row(&self)
[src]
fn connect_move_cursor<F: Fn(&Self, MovementStep, i32) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn emit_move_cursor(&self, object: MovementStep, p0: i32)
[src]
fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
[src]
fn emit_select_all(&self)
[src]
fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn emit_toggle_cursor_row(&self)
[src]
fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
[src]
fn emit_unselect_all(&self)
[src]
fn connect_property_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId
fn connect_property_selection_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
[src]
&self,
f: F
) -> SignalHandlerId