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 /// s children.
118 ///
119 /// If @parent and @sibling are [`None`], then the row will be prepended to the
120 /// toplevel.
121 ///
122 /// If both @sibling and @parent are set, then @parent must be the parent
123 /// of @sibling. When @sibling is set, @parent is optional.
124 ///
125 /// The @iter parameter will be changed to point to this new row. The row will
126 /// be empty after this function is called. To fill in values, you need to call
127 /// gtk_tree_store_set() or gtk_tree_store_set_value().
128 ///
129 /// # Deprecated since 4.10
130 ///
131 /// Use [`TreeListModel`][crate::TreeListModel] instead
132 /// ## `parent`
133 /// A valid [`TreeIter`][crate::TreeIter]
134 /// ## `sibling`
135 /// A valid [`TreeIter`][crate::TreeIter]
136 ///
137 /// # Returns
138 ///
139 ///
140 /// ## `iter`
141 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
142 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
143 #[allow(deprecated)]
144 #[doc(alias = "gtk_tree_store_insert_after")]
145 pub fn insert_after(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
146 unsafe {
147 let mut iter = TreeIter::uninitialized();
148 ffi::gtk_tree_store_insert_after(
149 self.to_glib_none().0,
150 iter.to_glib_none_mut().0,
151 mut_override(parent.to_glib_none().0),
152 mut_override(sibling.to_glib_none().0),
153 );
154 iter
155 }
156 }
157
158 /// s children.
159 ///
160 /// If @parent and @sibling are [`None`], then the row will be appended to the
161 /// toplevel.
162 ///
163 /// If both @sibling and @parent are set, then @parent must be the parent
164 /// of @sibling. When @sibling is set, @parent is optional.
165 ///
166 /// The @iter parameter will be changed to point to this new row. The row will
167 /// be empty after this function is called. To fill in values, you need to call
168 /// gtk_tree_store_set() or gtk_tree_store_set_value().
169 ///
170 /// # Deprecated since 4.10
171 ///
172 /// Use [`TreeListModel`][crate::TreeListModel] instead
173 /// ## `parent`
174 /// A valid [`TreeIter`][crate::TreeIter]
175 /// ## `sibling`
176 /// A valid [`TreeIter`][crate::TreeIter]
177 ///
178 /// # Returns
179 ///
180 ///
181 /// ## `iter`
182 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
183 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
184 #[allow(deprecated)]
185 #[doc(alias = "gtk_tree_store_insert_before")]
186 pub fn insert_before(&self, parent: Option<&TreeIter>, sibling: Option<&TreeIter>) -> TreeIter {
187 unsafe {
188 let mut iter = TreeIter::uninitialized();
189 ffi::gtk_tree_store_insert_before(
190 self.to_glib_none().0,
191 iter.to_glib_none_mut().0,
192 mut_override(parent.to_glib_none().0),
193 mut_override(sibling.to_glib_none().0),
194 );
195 iter
196 }
197 }
198
199 /// Checks if @iter is an ancestor of @descendant.
200 ///
201 /// # Deprecated since 4.10
202 ///
203 /// Use [`TreeListModel`][crate::TreeListModel] instead
204 /// ## `iter`
205 /// A valid [`TreeIter`][crate::TreeIter]
206 /// ## `descendant`
207 /// A valid [`TreeIter`][crate::TreeIter]
208 ///
209 /// # Returns
210 ///
211 /// true if @iter is an ancestor of @descendant, and false otherwise
212 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
213 #[allow(deprecated)]
214 #[doc(alias = "gtk_tree_store_is_ancestor")]
215 pub fn is_ancestor(&self, iter: &TreeIter, descendant: &TreeIter) -> bool {
216 unsafe {
217 from_glib(ffi::gtk_tree_store_is_ancestor(
218 self.to_glib_none().0,
219 mut_override(iter.to_glib_none().0),
220 mut_override(descendant.to_glib_none().0),
221 ))
222 }
223 }
224
225 /// Returns the depth of the position pointed by the iterator
226 ///
227 /// The depth will be 0 for anything on the root level, 1 for anything down
228 /// a level, etc.
229 ///
230 /// # Deprecated since 4.10
231 ///
232 /// Use [`TreeListModel`][crate::TreeListModel] instead
233 /// ## `iter`
234 /// A valid [`TreeIter`][crate::TreeIter]
235 ///
236 /// # Returns
237 ///
238 /// The depth of the position pointed by the iterator
239 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
240 #[allow(deprecated)]
241 #[doc(alias = "gtk_tree_store_iter_depth")]
242 pub fn iter_depth(&self, iter: &TreeIter) -> i32 {
243 unsafe {
244 ffi::gtk_tree_store_iter_depth(
245 self.to_glib_none().0,
246 mut_override(iter.to_glib_none().0),
247 )
248 }
249 }
250
251 /// Checks if the given iter is a valid iter for this [`TreeStore`][crate::TreeStore].
252 ///
253 /// This function is slow. Only use it for debugging and/or testing
254 /// purposes.
255 ///
256 /// # Deprecated since 4.10
257 ///
258 /// Use [`TreeListModel`][crate::TreeListModel] instead
259 /// ## `iter`
260 /// the iterator to check
261 ///
262 /// # Returns
263 ///
264 /// true if the iter is valid, and false otherwise
265 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
266 #[allow(deprecated)]
267 #[doc(alias = "gtk_tree_store_iter_is_valid")]
268 pub fn iter_is_valid(&self, iter: &TreeIter) -> bool {
269 unsafe {
270 from_glib(ffi::gtk_tree_store_iter_is_valid(
271 self.to_glib_none().0,
272 mut_override(iter.to_glib_none().0),
273 ))
274 }
275 }
276
277 /// Moves @iter in @self to the position after @position.
278 ///
279 /// @iter and @position should be in the same level.
280 ///
281 /// Note that this function only works with unsorted stores.
282 ///
283 /// If @position is [`None`], @iter will be moved to the start of the level.
284 ///
285 /// # Deprecated since 4.10
286 ///
287 /// Use [`TreeListModel`][crate::TreeListModel] instead
288 /// ## `iter`
289 /// A [`TreeIter`][crate::TreeIter].
290 /// ## `position`
291 /// A [`TreeIter`][crate::TreeIter].
292 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
293 #[allow(deprecated)]
294 #[doc(alias = "gtk_tree_store_move_after")]
295 pub fn move_after(&self, iter: &TreeIter, position: Option<&TreeIter>) {
296 unsafe {
297 ffi::gtk_tree_store_move_after(
298 self.to_glib_none().0,
299 mut_override(iter.to_glib_none().0),
300 mut_override(position.to_glib_none().0),
301 );
302 }
303 }
304
305 /// Moves @iter in @self to the position before @position.
306 ///
307 /// @iter and @position should be in the same level.
308 ///
309 /// Note that this function only works with unsorted stores.
310 ///
311 /// If @position is [`None`], @iter will be moved to the end of the level.
312 ///
313 /// # Deprecated since 4.10
314 ///
315 /// Use [`TreeListModel`][crate::TreeListModel] instead
316 /// ## `iter`
317 /// A [`TreeIter`][crate::TreeIter]
318 /// ## `position`
319 /// A [`TreeIter`][crate::TreeIter]
320 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
321 #[allow(deprecated)]
322 #[doc(alias = "gtk_tree_store_move_before")]
323 pub fn move_before(&self, iter: &TreeIter, position: Option<&TreeIter>) {
324 unsafe {
325 ffi::gtk_tree_store_move_before(
326 self.to_glib_none().0,
327 mut_override(iter.to_glib_none().0),
328 mut_override(position.to_glib_none().0),
329 );
330 }
331 }
332
333 /// Prepends a new row to @self.
334 ///
335 /// If @parent is non-[`None`], then it will prepend the new row before the first
336 /// child of @parent, otherwise it will prepend a row to the top level. The
337 /// `iter` parameter will be changed to point to this new row. The row will
338 /// be empty after this function is called. To fill in values, you need to
339 /// call gtk_tree_store_set() or gtk_tree_store_set_value().
340 ///
341 /// # Deprecated since 4.10
342 ///
343 /// Use [`TreeListModel`][crate::TreeListModel] instead
344 /// ## `parent`
345 /// A valid [`TreeIter`][crate::TreeIter]
346 ///
347 /// # Returns
348 ///
349 ///
350 /// ## `iter`
351 /// An unset [`TreeIter`][crate::TreeIter] to set to the prepended row
352 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
353 #[allow(deprecated)]
354 #[doc(alias = "gtk_tree_store_prepend")]
355 pub fn prepend(&self, parent: Option<&TreeIter>) -> TreeIter {
356 unsafe {
357 let mut iter = TreeIter::uninitialized();
358 ffi::gtk_tree_store_prepend(
359 self.to_glib_none().0,
360 iter.to_glib_none_mut().0,
361 mut_override(parent.to_glib_none().0),
362 );
363 iter
364 }
365 }
366
367 /// Removes @iter from @self.
368 ///
369 /// After being removed, @iter is set to the next valid row at that level, or
370 /// invalidated if it previously pointed to the last one.
371 ///
372 /// # Deprecated since 4.10
373 ///
374 /// Use [`TreeListModel`][crate::TreeListModel] instead
375 /// ## `iter`
376 /// A valid [`TreeIter`][crate::TreeIter]
377 ///
378 /// # Returns
379 ///
380 /// true if @iter is still valid, and false otherwise
381 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
382 #[allow(deprecated)]
383 #[doc(alias = "gtk_tree_store_remove")]
384 pub fn remove(&self, iter: &TreeIter) -> bool {
385 unsafe {
386 from_glib(ffi::gtk_tree_store_remove(
387 self.to_glib_none().0,
388 mut_override(iter.to_glib_none().0),
389 ))
390 }
391 }
392
393 /// Swaps @a and @b in the same level of @self.
394 ///
395 /// Note that this function only works with unsorted stores.
396 ///
397 /// # Deprecated since 4.10
398 ///
399 /// Use [`TreeListModel`][crate::TreeListModel] instead
400 /// ## `a`
401 /// A [`TreeIter`][crate::TreeIter].
402 /// ## `b`
403 /// Another [`TreeIter`][crate::TreeIter].
404 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
405 #[allow(deprecated)]
406 #[doc(alias = "gtk_tree_store_swap")]
407 pub fn swap(&self, a: &TreeIter, b: &TreeIter) {
408 unsafe {
409 ffi::gtk_tree_store_swap(
410 self.to_glib_none().0,
411 mut_override(a.to_glib_none().0),
412 mut_override(b.to_glib_none().0),
413 );
414 }
415 }
416}