Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: SortListModel

[29:7] extends: object

A list model that sorts the elements of another model. The elements are sorted according to a GtkSorter. The model is a stable sort. If two items compare equal according to the sorter, the one that appears first in the original model will also appear first after sorting. Note that if you change the sorter, the previous order will have no influence on the new order. If you want that, consider using a GtkMultiSorter and appending the previous sorter to it. The model can be set up to do incremental sorting, so that sorting long lists doesn't block the UI. See [method@Gtk.SortListModel.set_incremental] for details. GtkSortListModel is a generic model and because of that it cannot take advantage of any external knowledge when sorting. If you run into performance issues with GtkSortListModel, it is strongly recommended that you write your own sorting list model. GtkSortListModel allows sorting the items into sections. It implements GtkSectionModel and when [property@Gtk.SortListModel:section-sorter] is set, it will sort all items with that sorter and items comparing equal with it will be put into the same section. The [property@Gtk.SortListModel:sorter] will then be used to sort items inside their sections.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • SortListModel (model = null, sorter = null)

    Creates a new sort list model that uses the @sorter to sort @model.

    • @p model is the model to sort.
    • @p sorter is the GtkSorter to sort @model with,.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • asListModel ()

    Wraps this handle as ListModel.

    • @r A ListModel object.
  • asSectionModel ()

    Wraps this handle as SectionModel.

    • @r A SectionModel object.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setIncremental (bool Value)

    If the model should sort items incrementally.

    • @p Value is the new property value.
    • @r None.
  • setModel (object Value)

    The model being sorted.

    • @p Value is the new property value.
    • @r None.
  • setSectionsorter (object Value)

    The section sorter for this model, if one is set.

    • @p Value is the new property value.
    • @r None.
  • setSorter (object Value)

    The sorter for this model.

    • @p Value is the new property value.
    • @r None.
  • get_incremental ()

    Returns whether incremental sorting is enabled. See [method@Gtk.SortListModel.set_incremental].

  • get_model ()

    Gets the model currently sorted or %NULL if none.

  • get_pending ()

    Estimates progress of an ongoing sorting operation. The estimate is the number of items that would still need to be sorted to finish the sorting operation if this was a linear algorithm. So this number is not related to how many items are already correctly sorted. If you want to estimate the progress, you can use code like this: c pending = gtk_sort_list_model_get_pending (self); model = gtk_sort_list_model_get_model (self); progress = 1.0 - pending / (double) MAX (1, g_list_model_get_n_items (model)); If no sort operation is ongoing - in particular when [property@Gtk.SortListModel:incremental] is %FALSE - this function returns 0.

  • get_section_sorter ()

    Gets the section sorter that is used to sort items of @self into sections.

  • get_sorter ()

    Gets the sorter that is used to sort @self.

  • set_incremental (bool incremental)

    Sets the sort model to do an incremental sort. When incremental sorting is enabled, the GtkSortListModel will not do a complete sort immediately, but will instead queue an idle handler that incrementally sorts the items towards their correct position. This of course means that items do not instantly appear in the right place. It also means that the total sorting time is a lot slower. When your filter blocks the UI while sorting, you might consider turning this on. Depending on your model and sorters, this may become interesting around 10,000 to 100,000 items. By default, incremental sorting is disabled. See [method@Gtk.SortListModel.get_pending] for progress information about an ongoing incremental sorting operation.

    • @p incremental is %TRUE to sort incrementally.
    • @r None.
  • set_model (object model)

    Sets the model to be sorted. The @model's item type must conform to the item type of @self.

    • @p model is The model to be sorted.
    • @r None.
  • set_section_sorter (object sorter)

    Sets a new section sorter on @self.

    • @p sorter is the GtkSorter to sort @model with.
    • @r None.
  • set_sorter (object sorter)

    Sets a new sorter on @self.

    • @p sorter is the GtkSorter to sort @model with.
    • @r None.
  • model ()

    Returns get_model as an Aussom list of wrapper objects. This companion method materializes the full collection up front; use get_model() when lazy or change-notify access is required.

    • @r An Aussom list of elements.

class: SortListModelMeta

[345:14] static extends: object

Generated metadata helpers for SortListModel class surfaces.

Methods

  • properties ()

    Returns property metadata for SortListModel.

    • @r A list.