gtk/auto/tree_store.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Buildable, TreeDragDest, TreeDragSource, TreeIter, TreeModel, TreeSortable, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// The [`TreeStore`][crate::TreeStore] object is a list model for use with a [`TreeView`][crate::TreeView]
10 /// widget. It implements the [`TreeModel`][crate::TreeModel] interface, and consequentially,
11 /// can use all of the methods available there. It also implements the
12 /// [`TreeSortable`][crate::TreeSortable] interface so it can be sorted by the view. Finally,
13 /// it also implements the tree
14 /// [drag and drop][gtk3-GtkTreeView-drag-and-drop]
15 /// interfaces.
16 ///
17 /// # GtkTreeStore as GtkBuildable
18 ///
19 /// The GtkTreeStore implementation of the [`Buildable`][crate::Buildable] interface allows
20 /// to specify the model columns with a ``<columns>`` element that may contain
21 /// multiple ``<column>`` elements, each specifying one model column. The “type”
22 /// attribute specifies the data type for the column.
23 ///
24 /// An example of a UI Definition fragment for a tree store:
25 ///
26 ///
27 ///
28 /// **⚠️ The following code is in xml ⚠️**
29 ///
30 /// ```xml
31 /// <object class="GtkTreeStore">
32 /// <columns>
33 /// <column type="gchararray"/>
34 /// <column type="gchararray"/>
35 /// <column type="gint"/>
36 /// </columns>
37 /// </object>
38 /// ```
39 ///
40 /// # Implements
41 ///
42 /// [`TreeStoreExt`][trait@crate::prelude::TreeStoreExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`TreeDragDestExt`][trait@crate::prelude::TreeDragDestExt], [`TreeDragSourceExt`][trait@crate::prelude::TreeDragSourceExt], [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeSortableExt`][trait@crate::prelude::TreeSortableExt], [`TreeStoreExtManual`][trait@crate::prelude::TreeStoreExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual], [`TreeSortableExtManual`][trait@crate::prelude::TreeSortableExtManual]
43 #[doc(alias = "GtkTreeStore")]
44 pub struct TreeStore(Object<ffi::GtkTreeStore, ffi::GtkTreeStoreClass>) @implements Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable;
45
46 match fn {
47 type_ => || ffi::gtk_tree_store_get_type(),
48 }
49}
50
51impl TreeStore {
52 pub const NONE: Option<&'static TreeStore> = None;
53
54 //#[doc(alias = "gtk_tree_store_new")]
55 //pub fn new(n_columns: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> TreeStore {
56 // unsafe { TODO: call ffi:gtk_tree_store_new() }
57 //}
58
59 //#[doc(alias = "gtk_tree_store_newv")]
60 //pub fn newv(types: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 30 }) -> TreeStore {
61 // unsafe { TODO: call ffi:gtk_tree_store_newv() }
62 //}
63}
64
65/// Trait containing all [`struct@TreeStore`] methods.
66///
67/// # Implementors
68///
69/// [`TreeStore`][struct@crate::TreeStore]
70pub trait TreeStoreExt: IsA<TreeStore> + 'static {
71 /// Appends a new row to `self`. If `parent` is non-[`None`], then it will append the
72 /// new row after the last child of `parent`, otherwise it will append a row to
73 /// the top level. `iter` will be changed to point to this new row. The row will
74 /// be empty after this function is called. To fill in values, you need to call
75 /// [`TreeStoreExtManual::set()`][crate::prelude::TreeStoreExtManual::set()] or [`TreeStoreExtManual::set_value()`][crate::prelude::TreeStoreExtManual::set_value()].
76 /// ## `parent`
77 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
78 ///
79 /// # Returns
80 ///
81 ///
82 /// ## `iter`
83 /// An unset [`TreeIter`][crate::TreeIter] to set to the appended row
84 #[doc(alias = "gtk_tree_store_append")]
85 fn append(&self, parent: Option<&TreeIter>) -> TreeIter {
86 unsafe {
87 let mut iter = TreeIter::uninitialized();
88 ffi::gtk_tree_store_append(
89 self.as_ref().to_glib_none().0,
90 iter.to_glib_none_mut().0,
91 mut_override(parent.to_glib_none().0),
92 );
93 iter
94 }
95 }
96
97 /// Removes all rows from `self`
98 #[doc(alias = "gtk_tree_store_clear")]
99 fn clear(&self) {
100 unsafe {
101 ffi::gtk_tree_store_clear(self.as_ref().to_glib_none().0);
102 }
103 }
104
105 /// Creates a new row at `position`. If parent is non-[`None`], then the row will be
106 /// made a child of `parent`. Otherwise, the row will be created at the toplevel.
107 /// If `position` is -1 or is larger than the number of rows at that level, then
108 /// the new row will be inserted to the end of the list. `iter` will be changed
109 /// to point to this new row. The row will be empty after this function is
110 /// called. To fill in values, you need to call [`TreeStoreExtManual::set()`][crate::prelude::TreeStoreExtManual::set()] or
111 /// [`TreeStoreExtManual::set_value()`][crate::prelude::TreeStoreExtManual::set_value()].
112 /// ## `parent`
113 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
114 /// ## `position`
115 /// position to insert the new row, or -1 for last
116 ///
117 /// # Returns
118 ///
119 ///
120 /// ## `iter`
121 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
122 #[doc(alias = "gtk_tree_store_insert")]
123 fn insert(&self, parent: Option<&TreeIter>, position: i32) -> TreeIter {
124 unsafe {
125 let mut iter = TreeIter::uninitialized();
126 ffi::gtk_tree_store_insert(
127 self.as_ref().to_glib_none().0,
128 iter.to_glib_none_mut().0,
129 mut_override(parent.to_glib_none().0),
130 position,
131 );
132 iter
133 }
134 }
135
136 /// Inserts a new row after `sibling`. If `sibling` is [`None`], then the row will be
137 /// prepended to `parent` ’s children. If `parent` and `sibling` are [`None`], then
138 /// the row will be prepended to the toplevel. If both `sibling` and `parent` are
139 /// set, then `parent` must be the parent of `sibling`. When `sibling` is set,
140 /// `parent` is optional.
141 ///
142 /// `iter` will be changed to point to this new row. The row will be empty after
143 /// this function is called. To fill in values, you need to call
144 /// [`TreeStoreExtManual::set()`][crate::prelude::TreeStoreExtManual::set()] or [`TreeStoreExtManual::set_value()`][crate::prelude::TreeStoreExtManual::set_value()].
145 /// ## `parent`
146 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
147 /// ## `sibling`
148 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
149 ///
150 /// # Returns
151 ///
152 ///
153 /// ## `iter`
154 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
155 #[doc(alias = "gtk_tree_store_insert_after")]
156 fn insert_after(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
157 unsafe {
158 let mut iter = TreeIter::uninitialized();
159 ffi::gtk_tree_store_insert_after(
160 self.as_ref().to_glib_none().0,
161 iter.to_glib_none_mut().0,
162 mut_override(parent.to_glib_none().0),
163 mut_override(sibling.to_glib_none().0),
164 );
165 iter
166 }
167 }
168
169 /// Inserts a new row before `sibling`. If `sibling` is [`None`], then the row will
170 /// be appended to `parent` ’s children. If `parent` and `sibling` are [`None`], then
171 /// the row will be appended to the toplevel. If both `sibling` and `parent` are
172 /// set, then `parent` must be the parent of `sibling`. When `sibling` is set,
173 /// `parent` is optional.
174 ///
175 /// `iter` will be changed to point to this new row. The row will be empty after
176 /// this function is called. To fill in values, you need to call
177 /// [`TreeStoreExtManual::set()`][crate::prelude::TreeStoreExtManual::set()] or [`TreeStoreExtManual::set_value()`][crate::prelude::TreeStoreExtManual::set_value()].
178 /// ## `parent`
179 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
180 /// ## `sibling`
181 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
182 ///
183 /// # Returns
184 ///
185 ///
186 /// ## `iter`
187 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
188 #[doc(alias = "gtk_tree_store_insert_before")]
189 fn insert_before(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
190 unsafe {
191 let mut iter = TreeIter::uninitialized();
192 ffi::gtk_tree_store_insert_before(
193 self.as_ref().to_glib_none().0,
194 iter.to_glib_none_mut().0,
195 mut_override(parent.to_glib_none().0),
196 mut_override(sibling.to_glib_none().0),
197 );
198 iter
199 }
200 }
201
202 //#[doc(alias = "gtk_tree_store_insert_with_values")]
203 //fn insert_with_values(&self, parent: Option<&TreeIter>, position: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> TreeIter {
204 // unsafe { TODO: call ffi:gtk_tree_store_insert_with_values() }
205 //}
206
207 //#[doc(alias = "gtk_tree_store_insert_with_valuesv")]
208 //fn insert_with_valuesv(&self, parent: Option<&TreeIter>, position: i32, columns: &[i32], values: &[&glib::Value]) -> TreeIter {
209 // unsafe { TODO: call ffi:gtk_tree_store_insert_with_valuesv() }
210 //}
211
212 /// Returns [`true`] if `iter` is an ancestor of `descendant`. That is, `iter` is the
213 /// parent (or grandparent or great-grandparent) of `descendant`.
214 /// ## `iter`
215 /// A valid [`TreeIter`][crate::TreeIter]
216 /// ## `descendant`
217 /// A valid [`TreeIter`][crate::TreeIter]
218 ///
219 /// # Returns
220 ///
221 /// [`true`], if `iter` is an ancestor of `descendant`
222 #[doc(alias = "gtk_tree_store_is_ancestor")]
223 fn is_ancestor(&self, iter: &TreeIter, descendant: &TreeIter) -> bool {
224 unsafe {
225 from_glib(ffi::gtk_tree_store_is_ancestor(
226 self.as_ref().to_glib_none().0,
227 mut_override(iter.to_glib_none().0),
228 mut_override(descendant.to_glib_none().0),
229 ))
230 }
231 }
232
233 /// Returns the depth of `iter`. This will be 0 for anything on the root level, 1
234 /// for anything down a level, etc.
235 /// ## `iter`
236 /// A valid [`TreeIter`][crate::TreeIter]
237 ///
238 /// # Returns
239 ///
240 /// The depth of `iter`
241 #[doc(alias = "gtk_tree_store_iter_depth")]
242 fn iter_depth(&self, iter: &TreeIter) -> i32 {
243 unsafe {
244 ffi::gtk_tree_store_iter_depth(
245 self.as_ref().to_glib_none().0,
246 mut_override(iter.to_glib_none().0),
247 )
248 }
249 }
250
251 /// WARNING: This function is slow. Only use it for debugging and/or testing
252 /// purposes.
253 ///
254 /// Checks if the given iter is a valid iter for this [`TreeStore`][crate::TreeStore].
255 /// ## `iter`
256 /// A [`TreeIter`][crate::TreeIter].
257 ///
258 /// # Returns
259 ///
260 /// [`true`] if the iter is valid, [`false`] if the iter is invalid.
261 #[doc(alias = "gtk_tree_store_iter_is_valid")]
262 fn iter_is_valid(&self, iter: &TreeIter) -> bool {
263 unsafe {
264 from_glib(ffi::gtk_tree_store_iter_is_valid(
265 self.as_ref().to_glib_none().0,
266 mut_override(iter.to_glib_none().0),
267 ))
268 }
269 }
270
271 /// Moves `iter` in `self` to the position after `position`. `iter` and
272 /// `position` should be in the same level. Note that this function only
273 /// works with unsorted stores. If `position` is [`None`], `iter` will be moved
274 /// to the start of the level.
275 /// ## `iter`
276 /// A [`TreeIter`][crate::TreeIter].
277 /// ## `position`
278 /// A [`TreeIter`][crate::TreeIter].
279 #[doc(alias = "gtk_tree_store_move_after")]
280 fn move_after(&self, iter: &TreeIter, position: Option<&TreeIter>) {
281 unsafe {
282 ffi::gtk_tree_store_move_after(
283 self.as_ref().to_glib_none().0,
284 mut_override(iter.to_glib_none().0),
285 mut_override(position.to_glib_none().0),
286 );
287 }
288 }
289
290 /// Moves `iter` in `self` to the position before `position`. `iter` and
291 /// `position` should be in the same level. Note that this function only
292 /// works with unsorted stores. If `position` is [`None`], `iter` will be
293 /// moved to the end of the level.
294 /// ## `iter`
295 /// A [`TreeIter`][crate::TreeIter].
296 /// ## `position`
297 /// A [`TreeIter`][crate::TreeIter] or [`None`].
298 #[doc(alias = "gtk_tree_store_move_before")]
299 fn move_before(&self, iter: &TreeIter, position: Option<&TreeIter>) {
300 unsafe {
301 ffi::gtk_tree_store_move_before(
302 self.as_ref().to_glib_none().0,
303 mut_override(iter.to_glib_none().0),
304 mut_override(position.to_glib_none().0),
305 );
306 }
307 }
308
309 /// Prepends a new row to `self`. If `parent` is non-[`None`], then it will prepend
310 /// the new row before the first child of `parent`, otherwise it will prepend a row
311 /// to the top level. `iter` will be changed to point to this new row. The row
312 /// will be empty after this function is called. To fill in values, you need to
313 /// call [`TreeStoreExtManual::set()`][crate::prelude::TreeStoreExtManual::set()] or [`TreeStoreExtManual::set_value()`][crate::prelude::TreeStoreExtManual::set_value()].
314 /// ## `parent`
315 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
316 ///
317 /// # Returns
318 ///
319 ///
320 /// ## `iter`
321 /// An unset [`TreeIter`][crate::TreeIter] to set to the prepended row
322 #[doc(alias = "gtk_tree_store_prepend")]
323 fn prepend(&self, parent: Option<&TreeIter>) -> TreeIter {
324 unsafe {
325 let mut iter = TreeIter::uninitialized();
326 ffi::gtk_tree_store_prepend(
327 self.as_ref().to_glib_none().0,
328 iter.to_glib_none_mut().0,
329 mut_override(parent.to_glib_none().0),
330 );
331 iter
332 }
333 }
334
335 /// Removes `iter` from `self`. After being removed, `iter` is set to the
336 /// next valid row at that level, or invalidated if it previously pointed to the
337 /// last one.
338 /// ## `iter`
339 /// A valid [`TreeIter`][crate::TreeIter]
340 ///
341 /// # Returns
342 ///
343 /// [`true`] if `iter` is still valid, [`false`] if not.
344 #[doc(alias = "gtk_tree_store_remove")]
345 fn remove(&self, iter: &TreeIter) -> bool {
346 unsafe {
347 from_glib(ffi::gtk_tree_store_remove(
348 self.as_ref().to_glib_none().0,
349 mut_override(iter.to_glib_none().0),
350 ))
351 }
352 }
353
354 //#[doc(alias = "gtk_tree_store_set_column_types")]
355 //fn set_column_types(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 30 }) {
356 // unsafe { TODO: call ffi:gtk_tree_store_set_column_types() }
357 //}
358
359 //#[doc(alias = "gtk_tree_store_set_valist")]
360 //fn set_valist(&self, iter: &TreeIter, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
361 // unsafe { TODO: call ffi:gtk_tree_store_set_valist() }
362 //}
363
364 //#[doc(alias = "gtk_tree_store_set_valuesv")]
365 //fn set_valuesv(&self, iter: &TreeIter, columns: &[i32], values: &[&glib::Value]) {
366 // unsafe { TODO: call ffi:gtk_tree_store_set_valuesv() }
367 //}
368
369 /// Swaps `a` and `b` in the same level of `self`. Note that this function
370 /// only works with unsorted stores.
371 /// ## `a`
372 /// A [`TreeIter`][crate::TreeIter].
373 /// ## `b`
374 /// Another [`TreeIter`][crate::TreeIter].
375 #[doc(alias = "gtk_tree_store_swap")]
376 fn swap(&self, a: &TreeIter, b: &TreeIter) {
377 unsafe {
378 ffi::gtk_tree_store_swap(
379 self.as_ref().to_glib_none().0,
380 mut_override(a.to_glib_none().0),
381 mut_override(b.to_glib_none().0),
382 );
383 }
384 }
385}
386
387impl<O: IsA<TreeStore>> TreeStoreExt for O {}