pub trait SelectionModelExt: IsA<SelectionModel> + Sealed + 'static {
    // Provided methods
    fn selection(&self) -> Bitset { ... }
    fn selection_in_range(&self, position: u32, n_items: u32) -> Bitset { ... }
    fn is_selected(&self, position: u32) -> bool { ... }
    fn select_all(&self) -> bool { ... }
    fn select_item(&self, position: u32, unselect_rest: bool) -> bool { ... }
    fn select_range(
        &self,
        position: u32,
        n_items: u32,
        unselect_rest: bool
    ) -> bool { ... }
    fn selection_changed(&self, position: u32, n_items: u32) { ... }
    fn set_selection(&self, selected: &Bitset, mask: &Bitset) -> bool { ... }
    fn unselect_all(&self) -> bool { ... }
    fn unselect_item(&self, position: u32) -> bool { ... }
    fn unselect_range(&self, position: u32, n_items: u32) -> bool { ... }
    fn connect_selection_changed<F: Fn(&Self, u32, u32) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId { ... }
}
Expand description

Provided Methods§

source

fn selection(&self) -> Bitset

Gets the set containing all currently selected items in the model.

This function may be slow, so if you are only interested in single item, consider using is_selected() or if you are only interested in a few, consider selection_in_range().

Returns

a Bitset containing all the values currently selected in @self. If no items are selected, the bitset is empty. The bitset must not be modified.

source

fn selection_in_range(&self, position: u32, n_items: u32) -> Bitset

Gets the set of selected items in a range.

This function is an optimization for selection() when you are only interested in part of the model’s selected state. A common use case is in response to the selection-changed signal.

position

start of the queried range

n_items

number of items in the queried range

Returns

A Bitset that matches the selection state for the given range with all other values being undefined. The bitset must not be modified.

source

fn is_selected(&self, position: u32) -> bool

Checks if the given item is selected.

position

the position of the item to query

Returns

true if the item is selected

source

fn select_all(&self) -> bool

Requests to select all items in the model.

Returns

true if this action was supported and no fallback should be tried. This does not mean that all items are now selected.

source

fn select_item(&self, position: u32, unselect_rest: bool) -> bool

Requests to select an item in the model.

position

the position of the item to select

unselect_rest

whether previously selected items should be unselected

Returns

true if this action was supported and no fallback should be tried. This does not mean the item was selected.

source

fn select_range(&self, position: u32, n_items: u32, unselect_rest: bool) -> bool

Requests to select a range of items in the model.

position

the first item to select

n_items

the number of items to select

unselect_rest

whether previously selected items should be unselected

Returns

true if this action was supported and no fallback should be tried. This does not mean the range was selected.

source

fn selection_changed(&self, position: u32, n_items: u32)

Helper function for implementations of SelectionModel.

Call this when the selection changes to emit the selection-changed signal.

position

the first changed item

n_items

the number of changed items

source

fn set_selection(&self, selected: &Bitset, mask: &Bitset) -> bool

Make selection changes.

This is the most advanced selection updating method that allows the most fine-grained control over selection changes. If you can, you should try the simpler versions, as implementations are more likely to implement support for those.

Requests that the selection state of all positions set in @mask be updated to the respective value in the @selected bitmask.

In pseudocode, it would look something like this:

⚠️ The following code is in c ⚠️

for (i = 0; i < n_items; i++)
  {
    // don't change values not in the mask
    if (!gtk_bitset_contains (mask, i))
      continue;

    if (gtk_bitset_contains (selected, i))
      select_item (i);
    else
      unselect_item (i);
  }

gtk_selection_model_selection_changed (model,
                                       first_changed_item,
                                       n_changed_items);

@mask and @selected must not be modified. They may refer to the same bitset, which would mean that every item in the set should be selected.

selected

bitmask specifying if items should be selected or unselected

mask

bitmask specifying which items should be updated

Returns

true if this action was supported and no fallback should be tried. This does not mean that all items were updated according to the inputs.

source

fn unselect_all(&self) -> bool

Requests to unselect all items in the model.

Returns

true if this action was supported and no fallback should be tried. This does not mean that all items are now unselected.

source

fn unselect_item(&self, position: u32) -> bool

Requests to unselect an item in the model.

position

the position of the item to unselect

Returns

true if this action was supported and no fallback should be tried. This does not mean the item was unselected.

source

fn unselect_range(&self, position: u32, n_items: u32) -> bool

Requests to unselect a range of items in the model.

position

the first item to unselect

n_items

the number of items to unselect

Returns

true if this action was supported and no fallback should be tried. This does not mean the range was unselected.

source

fn connect_selection_changed<F: Fn(&Self, u32, u32) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted when the selection state of some of the items in @model changes.

Note that this signal does not specify the new selection state of the items, they need to be queried manually. It is also not necessary for a model to change the selection state of any of the items in the selection model, though it would be rather useless to emit such a signal.

position

The first item that may have changed

n_items

number of items with changes

Implementors§