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