GtkTreeModelSort            package:RGtk2            R Documentation

_G_t_k_T_r_e_e_M_o_d_e_l_S_o_r_t

_D_e_s_c_r_i_p_t_i_o_n:

     A GtkTreeModel which makes an underlying tree model sortable

_M_e_t_h_o_d_s _a_n_d _F_u_n_c_t_i_o_n_s:

     'gtkTreeModelSortNewWithModel(child.model = NULL)'
      'gtkTreeModelSortGetModel(object)'
      'gtkTreeModelSortConvertChildPathToPath(object, child.path)'
      'gtkTreeModelSortConvertChildIterToIter(object, child.iter)'
      'gtkTreeModelSortConvertPathToChildPath(object, sorted.path)'
      'gtkTreeModelSortConvertIterToChildIter(object, sorted.iter)'
      'gtkTreeModelSortResetDefaultSortFunc(object)'
      'gtkTreeModelSortClearCache(object)'
      'gtkTreeModelSortIterIsValid(object, iter)'
      'gtkTreeModelSort(child.model = NULL)'

_H_i_e_r_a_r_c_h_y:

     GObject
        +----GtkTreeModelSort 

_I_n_t_e_r_f_a_c_e_s:

     GtkTreeModelSort implements 'GtkTreeModel',  'GtkTreeDragSource'
     and  'GtkTreeSortable'.

_D_e_t_a_i_l_e_d _D_e_s_c_r_i_p_t_i_o_n:

     The 'GtkTreeModelSort' is a model which implements the
     'GtkTreeSortable' 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 'GtkTreeModelSort' is not
     guaranteed to be stable.

     The use of this is best demonstrated through an example.  In the
     following sample code we create two 'GtkTreeView' widgets each
     with a view of the same data.  As the model is wrapped here by a
     'GtkTreeModelSort', the two 'GtkTreeView's 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.

     _Using a   'GtkTreeModelSort'_


     ## Using a GtkTreeModel sort

     ## get the child model
     child_model <- get_my_model()

     ## Create the first tree 
     sort_model1 <- gtkTreeModelSort(child_model)
     tree_view1 <- gtkTreeView(sort_model1)

     ## Create the second tree
     sort_model2 <- gtkTreeModelSort(child_model)
     tree_view2 <- gtkTreeView(sort_model2)

     ## Now we can sort the two models independently
     sort_model1$setSortColumnId(0, "ascending")
     sort_model2$setSortColumnId(0, "descending")
      To demonstrate how to access the underlying child model from the
     sort model, the next example will be a callback for the
     'GtkTreeSelection' "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.

     _Accessing the child model of in a selection changed callback_


     # Accessing the child model in a selection changed callback

     selection_changed <- function(selection, data)
     {
       # Get the current selected row and the model.
       selected <- selection$getSelected()
       if (!selected[[1]])
         return()

       ## Look up the current value on the selected row and get a new
     value
       ## to change it to.
       some_data <- selected$model$get(selected$iter, COLUMN_1)

       modified_data <- change_the_data(some_data)

       ## Get an iterator on the child model, instead of the sort
     model.
       child_iter <-
     sort_model$convertIterToChildIter(selected$iter)$iter

       ## Get the child model and change the value of the row.  In this
       ## example, the child model is a GtkListStore.  It could be any
     other
       ## type of model, though.
       child_model <- sort_model$getModel()
       child_model$set(child_iter, COLUMN_1, modified_data)
     }


_S_t_r_u_c_t_u_r_e_s:


     '_G_t_k_T_r_e_e_M_o_d_e_l_S_o_r_t' This should not be accessed directly.  Use the
          accessor functions below.


_C_o_n_v_e_n_i_e_n_t _C_o_n_s_t_r_u_c_t_i_o_n:

     'gtkTreeModelSort' is the equivalent of
     'gtkTreeModelSortNewWithModel'.

_P_r_o_p_e_r_t_i_e_s:


     '_m_o_d_e_l' ['_G_t_k_T_r_e_e_M_o_d_e_l' : _R_e_a_d / _W_r_i_t_e / _C_o_n_s_t_r_u_c_t _O_n_l_y] The model
          for the TreeModelSort to sort.


_A_u_t_h_o_r(_s):

     Derived by RGtkGen from GTK+ documentation

_R_e_f_e_r_e_n_c_e_s:

     <URL:
     http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModelSort.html>

_S_e_e _A_l_s_o:

     'GtkTreeModel' 'GtkListStore' 'GtkTreeStore' 'GtkTreeSortable'
     'GtkTreeModelFilter'

