Trait gtk::prelude::ListBoxExt[][src]

pub trait ListBoxExt: 'static {
Show methods fn bind_model<P: IsA<ListModel>, Q: Fn(&Object) -> Widget + 'static>(
        &self,
        model: Option<&P>,
        create_widget_func: Q
    );
fn drag_highlight_row<P: IsA<ListBoxRow>>(&self, row: &P);
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<P: IsA<Widget>>(&self, child: &P, position: i32);
fn invalidate_filter(&self);
fn invalidate_headers(&self);
fn invalidate_sort(&self);
fn prepend<P: IsA<Widget>>(&self, child: &P);
fn select_all(&self);
fn select_row<P: IsA<ListBoxRow>>(&self, row: Option<&P>);
fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P);
fn set_activate_on_single_click(&self, single: bool);
fn set_adjustment<P: IsA<Adjustment>>(&self, adjustment: Option<&P>);
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<P: IsA<Widget>>(&self, placeholder: Option<&P>);
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<P: IsA<ListBoxRow>>(&self, row: &P);
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

Trait containing all ListBox methods.

Implementors

ListBox

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

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

If a row has previously been highlighted via drag_highlight_row() it will have the highlight removed.

Returns whether rows activate on single clicks.

Returns

true if rows are activated on single click, false otherwise

Gets the adjustment (if any) that the widget uses to for vertical scrolling.

Returns

the adjustment

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

Gets the row at the y position.

y

position

Returns

the row or None in case no row exists for the given y coordinate.

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

Creates a list of all selected children.

Returns

A GList containing the Widget for each selected child. Free with g_list_free() when done.

Gets the selection mode of the listbox.

Returns

a 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

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.

Update the separators for all rows. Call this when result of the header function on the self is changed due to an external factor.

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

Select all children of self, if the selection mode allows it.

Make row the currently selected row.

row

The row to select or None

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

If single is true, rows will be activated when you click on them, otherwise you need to double-click.

single

a boolean

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

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

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

Sets the placeholder widget that is shown in the list when it doesn’t display any visible children.

placeholder

a Widget or None

Sets how selection works in the listbox. See SelectionMode for details.

mode

The SelectionMode

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

Unselect all children of self, if the selection mode allows it.

Unselects a single row of self, if the selection mode allows it.

row

the row to unselected

The ::row-activated signal is emitted when a row has been activated by the user.

row

the activated row

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

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.

The ::selected-rows-changed signal is emitted when the set of selected rows changes.

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.

Implementors