/src/wrappers/gtk/library/gtk_tree_sortable.e

http://github.com/tybor/Liberty · Specman e · 180 lines · 59 code · 38 blank · 83 comment · 2 complexity · 8754b14101801e8a3e8786642119762b MD5 · raw file

  1. indexing
  2. description: "GtkTreeSortable -- The interface for sortable models used by GtkTreeView."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. deferred class GTK_TREE_SORTABLE
  19. -- GtkTreeSortable is an interface to be implemented by tree models
  20. -- which support sorting. The GtkTreeView uses the methods provided
  21. -- by this interface to sort the model.
  22. inherit
  23. -- TODO: G_INTERFACE
  24. -- Prerequisites: GtkTreeSortable requires GtkTreeModel and GObject.
  25. GTK_TREE_MODEL
  26. -- Note: GTK_TREE_MODEL already requires G_OBJECT
  27. -- Known Implementations: GtkTreeSortable is implemented by
  28. -- GtkTreeModelSort, GtkTreeStore and GtkListStore.
  29. insert
  30. GTK_SORT_TYPE
  31. GTK_TREE_SORTABLE_EXTERNALS
  32. feature
  33. -- GtkTreeIterCompareFunc ()
  34. -- gint (*GtkTreeIterCompareFunc) (GtkTreeModel *model,
  35. -- GtkTreeIter *a,
  36. -- GtkTreeIter *b,
  37. -- gpointer user_data);
  38. -- A GtkTreeIterCompareFunc should return a negative integer, zero, or a positive integer if a sorts before b, a sorts with b, or a sorts after b respectively. If two iters compare as equal, their order in the sorted model is undefined. In order to ensure that the GtkTreeSortable behaves as expected, the GtkTreeIterCompareFunc must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.
  39. -- For example, if model is a product catalogue, then a compare function for the "price" column could be one which returns price_of(a) - price_of(b).
  40. -- model : The GtkTreeModel the comparison is within
  41. -- a : A GtkTreeIter in model
  42. -- b : Another GtkTreeIter in model
  43. -- user_data : Data passed when the compare func is assigned e.g. by gtk_tree_sortable_set_sort_func()
  44. -- Returns :
  45. sort_column_changed is
  46. -- -- Emits a GtkTreeSortable::sort_column_changed signal on Current
  47. do
  48. gtk_tree_sortable_sort_column_changed (handle)
  49. end
  50. is_sort_column_id_not_special: BOOLEAN
  51. -- Is the sort column not one of the special sort column ids
  52. -- (i.e.: gtk_tree_sortable_default_sort_column_id or
  53. -- gtk_tree_sortable_unsorted_sort_column_id)?
  54. sort_column_id: INTEGER is
  55. -- The current sort column and the order. It returns TRUE
  56. -- unless the sort_column_id is
  57. -- GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
  58. -- GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
  59. -- sortable : A GtkTreeSortable
  60. -- sort_column_id : The sort column id to be filled in
  61. -- order : The GtkSortType to be filled in
  62. -- Returns : TRUE if the sort column is not one of the special sort column ids.
  63. local an_order: INTEGER
  64. do
  65. is_sort_column_id_not_special := (gtk_tree_sortable_get_sort_column_id (handle,
  66. $Result,
  67. $an_order
  68. )).to_boolean
  69. end
  70. order: INTEGER is
  71. -- Fills in sort_column_id and order with the current sort column and the order. It returns TRUE unless the sort_column_id is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
  72. -- sortable : A GtkTreeSortable
  73. -- sort_column_id : The sort column id to be filled in
  74. -- order : The GtkSortType to be filled in
  75. -- Returns : TRUE if the sort column is not one of the special sort column ids.
  76. local a_column: INTEGER
  77. do
  78. is_sort_column_id_not_special := (gtk_tree_sortable_get_sort_column_id (handle, $a_column,
  79. $Result)).to_boolean
  80. ensure is_valid_gtk_sort_type (Result)
  81. end
  82. set_sort_column_id (a_column_id, an_order: INTEGER) is
  83. -- Sets the current sort column to be `a_column_id'. The
  84. -- sortable will resort itself to reflect this change, after
  85. -- emitting a GtkTreeSortable::sort_column_changed signal. If
  86. -- sort_column_id is
  87. -- GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the default
  88. -- sort function will be used, if it is set.
  89. -- `an_order' is the sort order of the column
  90. require valid_order: is_valid_gtk_sort_type (an_order)
  91. do
  92. gtk_tree_sortable_set_sort_column_id (handle, a_column_id, an_order)
  93. end
  94. is_sorted: BOOLEAN is
  95. -- Is Current GTK_TREE_SORTABLE sorted?
  96. local
  97. col, sorted: INTEGER
  98. do
  99. Result := gtk_tree_sortable_get_sort_column_id (handle,
  100. $col,
  101. $sorted
  102. ).to_boolean
  103. end
  104. -- TODO: gtk_tree_sortable_set_sort_func ()
  105. -- void gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,
  106. -- gint sort_column_id,
  107. -- GtkTreeIterCompareFunc sort_func,
  108. -- gpointer user_data,
  109. -- GtkDestroyNotify destroy);
  110. -- Sets the comparison function used when sorting to be sort_func. If the current sort column id of sortable is the same as sort_column_id, then the model will sort using this function.
  111. -- sortable : A GtkTreeSortable
  112. -- sort_column_id : the sort column id to set the function for
  113. -- sort_func : The comparison function
  114. -- user_data : User data to pass to sort_func, or NULL
  115. -- destroy : Destroy notifier of user_data, or NULL
  116. -- TODO: set_default_sort_func is
  117. -- void gtk_tree_sortable_set_default_sort_func
  118. -- (GtkTreeSortable *sortable,
  119. -- GtkTreeIterCompareFunc sort_func,
  120. -- gpointer user_data,
  121. -- GtkDestroyNotify destroy);
  122. -- Sets the default comparison function used when sorting to be sort_func. If the current sort column id of sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using this function.
  123. -- If sort_func is NULL, then there will be no default comparison function. This means that once the model has been sorted, it can't go back to the default state. In this case, when the current sort column id of sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
  124. -- sortable : A GtkTreeSortable
  125. -- sort_func : The comparison function
  126. -- user_data : User data to pass to sort_func, or NULL
  127. -- destroy : Destroy notifier of user_data, or NULL
  128. -- gtk_tree_sortable_has_default_sort_func ()
  129. -- gboolean gtk_tree_sortable_has_default_sort_func
  130. -- (GtkTreeSortable *sortable);
  131. -- Returns TRUE if the model has a default sort function. This is used primarily by GtkTreeViewColumns in order to determine if a model can go back to the default state, or not.
  132. -- sortable : A GtkTreeSortable
  133. -- Returns : TRUE, if the model has a default sort function
  134. -- Signal Details
  135. -- The "sort-column-changed" signal
  136. -- void user_function (GtkTreeSortable *treesortable,
  137. -- gpointer user_data);
  138. -- treesortable : the object which received the signal.
  139. -- user_data : user data set when the signal handler was connected.
  140. -- See Also
  141. -- GtkTreeModel, GtkTreeView
  142. end