Package: gtk
Class gtk-tree-model-sort
Superclassesgtk-tree-model, gtk-tree-sortable, gtk-tree-drag-source, g-object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct SlotsDetails The gtk-tree-model-sort object is a model which implements the gtk-tree-sortable interface.
It does not hold any data itself, but rather is created with a child model
and proxies its data. It has identical column types to this child model, and
the changes in the child are propagated. The primary purpose of this model is
to provide a way to sort a different model without modifying it. Note that the sort function used by the gtk-tree-model-sort object is not
guaranteed to be stable. The use of this is best demonstrated through an example. In the following sample code we create two gtk-tree-view widgets each with a view of the same data. As the model is wrapped here by a gtk-tree-model-sort object, the two gtk-tree-view widgets can each sort their view of the data without affecting the other. By contrast, if we simply put the same model in each widget, then sorting the first would sort the second. Example: Using a gtk-tree-model-sort object (let* (;; Get the child model (child-model (gtk-my-model())) ;; Create the first tree view (sort-model1 (gtk-tree-model-sort-new-with-model child-model)) (tree-view1 (gtk-tree-view-with-model sort-model1)) ;; Create the second tree view (sort-model2 (gtk-tree-vmodel-sort-new-with-model child-model)) (tree-view2 (gtk-tree-view-new-with-model sort-model2))) ;; Now we can sort the two models independently (setf (gtk-tree-sortable-sort-column-id sort-model1) col-1) (setf (gtk-tree-sortable-sort-column-id sort-model1) '(col1 :descending)) ... )To demonstrate how to access the underlying child model from the sort model, the next example will be a callback for the gtk-tree-selection "changed" signal. In this callback, we get a string from COLUMN_1 of the model. We then modify the string, find the same selected row on the child model, and change the row there. Example: Accessing the child model in a selection changed callback (defun selection-changed (selection) (let* ((view (gtk-tree-selection-tree-view selection)) ;; Get the current selected row and the model (sort-model (gtk-tree-view-model view)) (sort-iter (gtk-tree-selection-selected selection)) ;; Look up the current value on the selected row and get a new value (value (gtk-tree-model-value sort-model sort-iter col-1)) (new-value (change-the-value value)) ;; Get the child model and an iterator on the child model (model (gtk-tree-model-sort-model sort-model)) (iter (gtk-tree-model-sort-convert-iter-to-child-iter sort-model sort-iter))) ;; Change the value of the row in the child model (gtk-list-store-set-value model iter col-1 new-value))) | Slot Access FunctionsInherited Slot Access FunctionsSee also |
2021-3-10