Package: gtk
Class gtk:tree-model-sort
Superclassesgtk:tree-model, gtk:tree-sortable, gtk:tree-drag-source, gobject: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. Examples(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) col1) (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 "changed" signal of the gtk:tree-selection object. In this callback, we get a string from col1 of the model. We then modify the string, find the same selected row on the child model, and change the row there. (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 col1)) (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 col1 new-value))) Warning | Returned bySlot Access FunctionsInherited Slot Access FunctionsSee also |
2024-5-9