Interface

Gtk-4.0GtkSelectionModelInterface

Interface for implementing SelectionModel. Contains only the virtual methods that need to be implemented.

interface Interface<A extends GObject.Object = GObject.Object> {
    vfunc_get_item(position: number): GObject.Object;
    vfunc_get_item_type(): GType;
    vfunc_get_n_items(): number;
    vfunc_get_selection_in_range(position: number, n_items: number): Bitset;
    vfunc_is_selected(position: number): boolean;
    vfunc_select_all(): boolean;
    vfunc_select_item(position: number, unselect_rest: boolean): boolean;
    vfunc_select_range(
        position: number,
        n_items: number,
        unselect_rest: boolean,
    ): boolean;
    vfunc_set_selection(selected: Bitset, mask: Bitset): boolean;
    vfunc_unselect_all(): boolean;
    vfunc_unselect_item(position: number): boolean;
    vfunc_unselect_range(position: number, n_items: number): boolean;
}

Type Parameters

Hierarchy (View Summary)

Index

Methods

  • Gets the set of selected items in a range.

    This function is an optimization for Gtk.SelectionModel.get_selection when you are only interested in part of the model's selected state. A common use case is in response to the Gtk.SelectionModel::selection-changed signal.

    Parameters

    • position: number

      start of the queried range

    • n_items: number

      number of items in the queried range

    Returns Bitset

  • Checks if the given item is selected.

    Parameters

    • position: number

      the position of the item to query

    Returns boolean

  • Requests to select an item in the model.

    Parameters

    • position: number

      the position of the item to select

    • unselect_rest: boolean

      whether previously selected items should be unselected

    Returns boolean

  • Requests to select a range of items in the model.

    Parameters

    • position: number

      the first item to select

    • n_items: number

      the number of items to select

    • unselect_rest: boolean

      whether previously selected items should be unselected

    Returns boolean

  • 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:

    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.

    Parameters

    • selected: Bitset

      bitmask specifying if items should be selected or unselected

    • mask: Bitset

      bitmask specifying which items should be updated

    Returns boolean

  • Requests to unselect an item in the model.

    Parameters

    • position: number

      the position of the item to unselect

    Returns boolean

  • Requests to unselect a range of items in the model.

    Parameters

    • position: number

      the first item to unselect

    • n_items: number

      the number of items to unselect

    Returns boolean

Methods - Inherited from Gio

  • Gets the type of the items in list.

    All items returned from g_list_model_get_item() are of the type returned by this function, or a subtype, or if the type is an interface, they are an implementation of that interface.

    The item type of a Gio.ListModel can not change during the life of the model.

    Returns GType

  • Gets the number of items in list.

    Depending on the model implementation, calling this function may be less efficient than iterating the list with increasing values for position until g_list_model_get_item() returns null.

    Returns number