gtk4/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#![allow(deprecated)]
5
6use crate::{Buildable, TreeDragDest, TreeDragSource, TreeIter, TreeModel, TreeSortable, ffi};
7use glib::translate::*;
8
9glib::wrapper! {
10 /// Use [`TreeListModel`][crate::TreeListModel] instead
11 ///
12 /// ```text
13 ///
14 ///
15 /// # Implements
16 ///
17 /// [`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], [`TreeModelExtManual`][trait@crate::prelude::TreeModelExtManual], [`TreeSortableExtManual`][trait@crate::prelude::TreeSortableExtManual]
18 #[doc(alias = "GtkTreeStore")]
19 pub struct TreeStore(Object<ffi::GtkTreeStore, ffi::GtkTreeStoreClass>) @implements Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable;
20
21 match fn {
22 type_ => || ffi::gtk_tree_store_get_type(),
23 }
24}
25
26impl TreeStore {
27 /// Appends a new row to @self.
28 ///
29 /// If @parent is non-[`None`], then it will append the new row after the last
30 /// child of @parent, otherwise it will append a row to the top level.
31 ///
32 /// The @iter parameter will be changed to point to this new row. The row will
33 /// be empty after this function is called. To fill in values, you need to call
34 /// gtk_tree_store_set() or gtk_tree_store_set_value().
35 ///
36 /// # Deprecated since 4.10
37 ///
38 /// Use [`TreeListModel`][crate::TreeListModel] instead
39 /// ## `parent`
40 /// A valid [`TreeIter`][crate::TreeIter]
41 ///
42 /// # Returns
43 ///
44 ///
45 /// ## `iter`
46 /// An unset [`TreeIter`][crate::TreeIter] to set to the appended row
47 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
48 #[allow(deprecated)]
49 #[doc(alias = "gtk_tree_store_append")]
50 pub fn append(&self, parent: Option<&TreeIter>) -> TreeIter {
51 unsafe {
52 let mut iter = TreeIter::uninitialized();
53 ffi::gtk_tree_store_append(
54 self.to_glib_none().0,
55 iter.to_glib_none_mut().0,
56 mut_override(parent.to_glib_none().0),
57 );
58 iter
59 }
60 }
61
62 /// Removes all rows from @self
63 ///
64 /// # Deprecated since 4.10
65 ///
66 /// Use [`TreeListModel`][crate::TreeListModel] instead
67 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
68 #[allow(deprecated)]
69 #[doc(alias = "gtk_tree_store_clear")]
70 pub fn clear(&self) {
71 unsafe {
72 ffi::gtk_tree_store_clear(self.to_glib_none().0);
73 }
74 }
75
76 /// Creates a new row at @position.
77 ///
78 /// If parent is non-[`None`], then the row will be made a child of @parent.
79 /// Otherwise, the row will be created at the toplevel.
80 ///
81 /// If @position is `-1` or is larger than the number of rows at that level,
82 /// then the new row will be inserted to the end of the list.
83 ///
84 /// The @iter parameter will be changed to point to this new row. The row
85 /// will be empty after this function is called. To fill in values, you
86 /// need to call gtk_tree_store_set() or gtk_tree_store_set_value().
87 ///
88 /// # Deprecated since 4.10
89 ///
90 /// Use [`TreeListModel`][crate::TreeListModel] instead
91 /// ## `parent`
92 /// A valid [`TreeIter`][crate::TreeIter]
93 /// ## `position`
94 /// position to insert the new row, or -1 for last
95 ///
96 /// # Returns
97 ///
98 ///
99 /// ## `iter`
100 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
101 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
102 #[allow(deprecated)]
103 #[doc(alias = "gtk_tree_store_insert")]
104 pub fn insert(&self, parent: Option<&TreeIter>, position: i32) -> TreeIter {
105 unsafe {
106 let mut iter = TreeIter::uninitialized();
107 ffi::gtk_tree_store_insert(
108 self.to_glib_none().0,
109 iter.to_glib_none_mut().0,
110 mut_override(parent.to_glib_none().0),
111 position,
112 );
113 iter
114 }
115 }
116
117 /// Inserts a new row after @sibling.
118 ///
119 /// If @sibling is [`None`], then the row will be prepended to @parent’s children.
120 ///
121 /// If @parent and @sibling are [`None`], then the row will be prepended to the
122 /// toplevel.
123 ///
124 /// If both @sibling and @parent are set, then @parent must be the parent
125 /// of @sibling. When @sibling is set, @parent is optional.
126 ///
127 /// The @iter parameter will be changed to point to this new row. The row will
128 /// be empty after this function is called. To fill in values, you need to call
129 /// gtk_tree_store_set() or gtk_tree_store_set_value().
130 ///
131 /// # Deprecated since 4.10
132 ///
133 /// Use [`TreeListModel`][crate::TreeListModel] instead
134 /// ## `parent`
135 /// A valid [`TreeIter`][crate::TreeIter]
136 /// ## `sibling`
137 /// A valid [`TreeIter`][crate::TreeIter]
138 ///
139 /// # Returns
140 ///
141 ///
142 /// ## `iter`
143 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
144 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
145 #[allow(deprecated)]
146 #[doc(alias = "gtk_tree_store_insert_after")]
147 pub fn insert_after(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
148 unsafe {
149 let mut iter = TreeIter::uninitialized();
150 ffi::gtk_tree_store_insert_after(
151 self.to_glib_none().0,
152 iter.to_glib_none_mut().0,
153 mut_override(parent.to_glib_none().0),
154 mut_override(sibling.to_glib_none().0),
155 );
156 iter
157 }
158 }
159
160 /// Inserts a new row before @sibling.
161 ///
162 /// If @sibling is [`None`], then the row will be appended to @parent’s children.
163 ///
164 /// If @parent and @sibling are [`None`], then the row will be appended to the
165 /// toplevel.
166 ///
167 /// If both @sibling and @parent are set, then @parent must be the parent
168 /// of @sibling. When @sibling is set, @parent is optional.
169 ///
170 /// The @iter parameter will be changed to point to this new row. The row will
171 /// be empty after this function is called. To fill in values, you need to call
172 /// gtk_tree_store_set() or gtk_tree_store_set_value().
173 ///
174 /// # Deprecated since 4.10
175 ///
176 /// Use [`TreeListModel`][crate::TreeListModel] instead
177 /// ## `parent`
178 /// A valid [`TreeIter`][crate::TreeIter]
179 /// ## `sibling`
180 /// A valid [`TreeIter`][crate::TreeIter]
181 ///
182 /// # Returns
183 ///
184 ///
185 /// ## `iter`
186 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
187 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
188 #[allow(deprecated)]
189 #[doc(alias = "gtk_tree_store_insert_before")]
190 pub fn insert_before(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
191 unsafe {
192 let mut iter = TreeIter::uninitialized();
193 ffi::gtk_tree_store_insert_before(
194 self.to_glib_none().0,
195 iter.to_glib_none_mut().0,
196 mut_override(parent.to_glib_none().0),
197 mut_override(sibling.to_glib_none().0),
198 );
199 iter
200 }
201 }
202
203 /// Checks if @iter is an ancestor of @descendant.
204 ///
205 /// # Deprecated since 4.10
206 ///
207 /// Use [`TreeListModel`][crate::TreeListModel] instead
208 /// ## `iter`
209 /// A valid [`TreeIter`][crate::TreeIter]
210 /// ## `descendant`
211 /// A valid [`TreeIter`][crate::TreeIter]
212 ///
213 /// # Returns
214 ///
215 /// true if @iter is an ancestor of @descendant, and false otherwise
216 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
217 #[allow(deprecated)]
218 #[doc(alias = "gtk_tree_store_is_ancestor")]
219 pub fn is_ancestor(&self, iter: &TreeIter, descendant: &TreeIter) -> bool {
220 unsafe {
221 from_glib(ffi::gtk_tree_store_is_ancestor(
222 self.to_glib_none().0,
223 mut_override(iter.to_glib_none().0),
224 mut_override(descendant.to_glib_none().0),
225 ))
226 }
227 }
228
229 /// Returns the depth of the position pointed by the iterator
230 ///
231 /// The depth will be 0 for anything on the root level, 1 for anything down
232 /// a level, etc.
233 ///
234 /// # Deprecated since 4.10
235 ///
236 /// Use [`TreeListModel`][crate::TreeListModel] instead
237 /// ## `iter`
238 /// A valid [`TreeIter`][crate::TreeIter]
239 ///
240 /// # Returns
241 ///
242 /// The depth of the position pointed by the iterator
243 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
244 #[allow(deprecated)]
245 #[doc(alias = "gtk_tree_store_iter_depth")]
246 pub fn iter_depth(&self, iter: &TreeIter) -> i32 {
247 unsafe {
248 ffi::gtk_tree_store_iter_depth(
249 self.to_glib_none().0,
250 mut_override(iter.to_glib_none().0),
251 )
252 }
253 }
254
255 /// Checks if the given iter is a valid iter for this [`TreeStore`][crate::TreeStore].
256 ///
257 /// This function is slow. Only use it for debugging and/or testing
258 /// purposes.
259 ///
260 /// # Deprecated since 4.10
261 ///
262 /// Use [`TreeListModel`][crate::TreeListModel] instead
263 /// ## `iter`
264 /// the iterator to check
265 ///
266 /// # Returns
267 ///
268 /// true if the iter is valid, and false otherwise
269 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
270 #[allow(deprecated)]
271 #[doc(alias = "gtk_tree_store_iter_is_valid")]
272 pub fn iter_is_valid(&self, iter: &TreeIter) -> bool {
273 unsafe {
274 from_glib(ffi::gtk_tree_store_iter_is_valid(
275 self.to_glib_none().0,
276 mut_override(iter.to_glib_none().0),
277 ))
278 }
279 }
280
281 /// Moves @iter in @self to the position after @position.
282 ///
283 /// @iter and @position should be in the same level.
284 ///
285 /// Note that this function only works with unsorted stores.
286 ///
287 /// If @position is [`None`], @iter will be moved to the start of the level.
288 ///
289 /// # Deprecated since 4.10
290 ///
291 /// Use [`TreeListModel`][crate::TreeListModel] instead
292 /// ## `iter`
293 /// A [`TreeIter`][crate::TreeIter].
294 /// ## `position`
295 /// A [`TreeIter`][crate::TreeIter].
296 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
297 #[allow(deprecated)]
298 #[doc(alias = "gtk_tree_store_move_after")]
299 pub fn move_after(&self, iter: &TreeIter, position: Option<&TreeIter>) {
300 unsafe {
301 ffi::gtk_tree_store_move_after(
302 self.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 /// Moves @iter in @self to the position before @position.
310 ///
311 /// @iter and @position should be in the same level.
312 ///
313 /// Note that this function only works with unsorted stores.
314 ///
315 /// If @position is [`None`], @iter will be moved to the end of the level.
316 ///
317 /// # Deprecated since 4.10
318 ///
319 /// Use [`TreeListModel`][crate::TreeListModel] instead
320 /// ## `iter`
321 /// A [`TreeIter`][crate::TreeIter]
322 /// ## `position`
323 /// A [`TreeIter`][crate::TreeIter]
324 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
325 #[allow(deprecated)]
326 #[doc(alias = "gtk_tree_store_move_before")]
327 pub fn move_before(&self, iter: &TreeIter, position: Option<&TreeIter>) {
328 unsafe {
329 ffi::gtk_tree_store_move_before(
330 self.to_glib_none().0,
331 mut_override(iter.to_glib_none().0),
332 mut_override(position.to_glib_none().0),
333 );
334 }
335 }
336
337 /// Prepends a new row to @self.
338 ///
339 /// If @parent is non-[`None`], then it will prepend the new row before the first
340 /// child of @parent, otherwise it will prepend a row to the top level. The
341 /// `iter` parameter will be changed to point to this new row. The row will
342 /// be empty after this function is called. To fill in values, you need to
343 /// call gtk_tree_store_set() or gtk_tree_store_set_value().
344 ///
345 /// # Deprecated since 4.10
346 ///
347 /// Use [`TreeListModel`][crate::TreeListModel] instead
348 /// ## `parent`
349 /// A valid [`TreeIter`][crate::TreeIter]
350 ///
351 /// # Returns
352 ///
353 ///
354 /// ## `iter`
355 /// An unset [`TreeIter`][crate::TreeIter] to set to the prepended row
356 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
357 #[allow(deprecated)]
358 #[doc(alias = "gtk_tree_store_prepend")]
359 pub fn prepend(&self, parent: Option<&TreeIter>) -> TreeIter {
360 unsafe {
361 let mut iter = TreeIter::uninitialized();
362 ffi::gtk_tree_store_prepend(
363 self.to_glib_none().0,
364 iter.to_glib_none_mut().0,
365 mut_override(parent.to_glib_none().0),
366 );
367 iter
368 }
369 }
370
371 /// Removes @iter from @self.
372 ///
373 /// After being removed, @iter is set to the next valid row at that level, or
374 /// invalidated if it previously pointed to the last one.
375 ///
376 /// # Deprecated since 4.10
377 ///
378 /// Use [`TreeListModel`][crate::TreeListModel] instead
379 /// ## `iter`
380 /// A valid [`TreeIter`][crate::TreeIter]
381 ///
382 /// # Returns
383 ///
384 /// true if @iter is still valid, and false otherwise
385 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
386 #[allow(deprecated)]
387 #[doc(alias = "gtk_tree_store_remove")]
388 pub fn remove(&self, iter: &TreeIter) -> bool {
389 unsafe {
390 from_glib(ffi::gtk_tree_store_remove(
391 self.to_glib_none().0,
392 mut_override(iter.to_glib_none().0),
393 ))
394 }
395 }
396
397 /// Swaps @a and @b in the same level of @self.
398 ///
399 /// Note that this function only works with unsorted stores.
400 ///
401 /// # Deprecated since 4.10
402 ///
403 /// Use [`TreeListModel`][crate::TreeListModel] instead
404 /// ## `a`
405 /// A [`TreeIter`][crate::TreeIter].
406 /// ## `b`
407 /// Another [`TreeIter`][crate::TreeIter].
408 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
409 #[allow(deprecated)]
410 #[doc(alias = "gtk_tree_store_swap")]
411 pub fn swap(&self, a: &TreeIter, b: &TreeIter) {
412 unsafe {
413 ffi::gtk_tree_store_swap(
414 self.to_glib_none().0,
415 mut_override(a.to_glib_none().0),
416 mut_override(b.to_glib_none().0),
417 );
418 }
419 }
420}