gtk4/auto/
tree_model.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::{ffi, TreeIter, TreeModelFlags, TreePath};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// Use [`gio::ListModel`][crate::gio::ListModel] instead
17    /// The tree interface used by GtkTreeView
18    ///
19    /// The [`TreeModel`][crate::TreeModel] interface defines a generic tree interface for
20    /// use by the [`TreeView`][crate::TreeView] widget. It is an abstract interface, and
21    /// is designed to be usable with any appropriate data structure. The
22    /// programmer just has to implement this interface on their own data
23    /// type for it to be viewable by a [`TreeView`][crate::TreeView] widget.
24    ///
25    /// The model is represented as a hierarchical tree of strongly-typed,
26    /// columned data. In other words, the model can be seen as a tree where
27    /// every node has different values depending on which column is being
28    /// queried. The type of data found in a column is determined by using
29    /// the GType system (ie. `G_TYPE_INT`, `GTK_TYPE_BUTTON`, `G_TYPE_POINTER`,
30    /// etc). The types are homogeneous per column across all nodes. It is
31    /// important to note that this interface only provides a way of examining
32    /// a model and observing changes. The implementation of each individual
33    /// model decides how and if changes are made.
34    ///
35    /// In order to make life simpler for programmers who do not need to
36    /// write their own specialized model, two generic models are provided
37    /// — the [`TreeStore`][crate::TreeStore] and the [`ListStore`][crate::ListStore]. To use these, the
38    /// developer simply pushes data into these models as necessary. These
39    /// models provide the data structure as well as all appropriate tree
40    /// interfaces. As a result, implementing drag and drop, sorting, and
41    /// storing data is trivial. For the vast majority of trees and lists,
42    /// these two models are sufficient.
43    ///
44    /// Models are accessed on a node/column level of granularity. One can
45    /// query for the value of a model at a certain node and a certain
46    /// column on that node. There are two structures used to reference a
47    /// particular node in a model. They are the [`TreePath`][crate::TreePath] and
48    /// the [`TreeIter`][crate::TreeIter] (“iter” is short for iterator). Most of the
49    /// interface consists of operations on a [`TreeIter`][crate::TreeIter].
50    ///
51    /// A path is essentially a potential node. It is a location on a model
52    /// that may or may not actually correspond to a node on a specific
53    /// model. A [`TreePath`][crate::TreePath] can be converted into either an
54    /// array of unsigned integers or a string. The string form is a list
55    /// of numbers separated by a colon. Each number refers to the offset
56    /// at that level. Thus, the path `0` refers to the root
57    /// node and the path `2:4` refers to the fifth child of
58    /// the third node.
59    ///
60    /// By contrast, a [`TreeIter`][crate::TreeIter] is a reference to a specific node on
61    /// a specific model. It is a generic struct with an integer and three
62    /// generic pointers. These are filled in by the model in a model-specific
63    /// way. One can convert a path to an iterator by calling
64    /// gtk_tree_model_get_iter(). These iterators are the primary way
65    /// of accessing a model and are similar to the iterators used by
66    /// [`TextBuffer`][crate::TextBuffer]. They are generally statically allocated on the
67    /// stack and only used for a short time. The model interface defines
68    /// a set of operations using them for navigating the model.
69    ///
70    /// It is expected that models fill in the iterator with private data.
71    /// For example, the [`ListStore`][crate::ListStore] model, which is internally a simple
72    /// linked list, stores a list node in one of the pointers. The
73    /// [`TreeModel`][crate::TreeModel]Sort stores an array and an offset in two of the
74    /// pointers. Additionally, there is an integer field. This field is
75    /// generally filled with a unique stamp per model. This stamp is for
76    /// catching errors resulting from using invalid iterators with a model.
77    ///
78    /// The lifecycle of an iterator can be a little confusing at first.
79    /// Iterators are expected to always be valid for as long as the model
80    /// is unchanged (and doesn’t emit a signal). The model is considered
81    /// to own all outstanding iterators and nothing needs to be done to
82    /// free them from the user’s point of view. Additionally, some models
83    /// guarantee that an iterator is valid for as long as the node it refers
84    /// to is valid (most notably the [`TreeStore`][crate::TreeStore] and [`ListStore`][crate::ListStore]).
85    /// Although generally uninteresting, as one always has to allow for
86    /// the case where iterators do not persist beyond a signal, some very
87    /// important performance enhancements were made in the sort model.
88    /// As a result, the [`TreeModelFlags::ITERS_PERSIST`][crate::TreeModelFlags::ITERS_PERSIST] flag was added to
89    /// indicate this behavior.
90    ///
91    /// To help show some common operation of a model, some examples are
92    /// provided. The first example shows three ways of getting the iter at
93    /// the location `3:2:5`. While the first method shown is
94    /// easier, the second is much more common, as you often get paths from
95    /// callbacks.
96    ///
97    /// ## Acquiring a [`TreeIter`][crate::TreeIter]
98    ///
99    /// **⚠️ The following code is in c ⚠️**
100    ///
101    /// ```c
102    /// // Three ways of getting the iter pointing to the location
103    /// GtkTreePath *path;
104    /// GtkTreeIter iter;
105    /// GtkTreeIter parent_iter;
106    ///
107    /// // get the iterator from a string
108    /// gtk_tree_model_get_iter_from_string (model,
109    ///                                      &iter,
110    ///                                      "3:2:5");
111    ///
112    /// // get the iterator from a path
113    /// path = gtk_tree_path_new_from_string ("3:2:5");
114    /// gtk_tree_model_get_iter (model, &iter, path);
115    /// gtk_tree_path_free (path);
116    ///
117    /// // walk the tree to find the iterator
118    /// gtk_tree_model_iter_nth_child (model, &iter,
119    ///                                NULL, 3);
120    /// parent_iter = iter;
121    /// gtk_tree_model_iter_nth_child (model, &iter,
122    ///                                &parent_iter, 2);
123    /// parent_iter = iter;
124    /// gtk_tree_model_iter_nth_child (model, &iter,
125    ///                                &parent_iter, 5);
126    /// ```
127    ///
128    /// This second example shows a quick way of iterating through a list
129    /// and getting a string and an integer from each row. The
130    /// populate_model() function used below is not
131    /// shown, as it is specific to the [`ListStore`][crate::ListStore]. For information on
132    /// how to write such a function, see the [`ListStore`][crate::ListStore] documentation.
133    ///
134    /// ## Reading data from a [`TreeModel`][crate::TreeModel]
135    ///
136    /// **⚠️ The following code is in c ⚠️**
137    ///
138    /// ```c
139    /// enum
140    /// {
141    ///   STRING_COLUMN,
142    ///   INT_COLUMN,
143    ///   N_COLUMNS
144    /// };
145    ///
146    /// ...
147    ///
148    /// GtkTreeModel *list_store;
149    /// GtkTreeIter iter;
150    /// gboolean valid;
151    /// int row_count = 0;
152    ///
153    /// // make a new list_store
154    /// list_store = gtk_list_store_new (N_COLUMNS,
155    ///                                  G_TYPE_STRING,
156    ///                                  G_TYPE_INT);
157    ///
158    /// // Fill the list store with data
159    /// populate_model (list_store);
160    ///
161    /// // Get the first iter in the list, check it is valid and walk
162    /// // through the list, reading each row.
163    ///
164    /// valid = gtk_tree_model_get_iter_first (list_store,
165    ///                                        &iter);
166    /// while (valid)
167    ///  {
168    ///    char *str_data;
169    ///    int    int_data;
170    ///
171    ///    // Make sure you terminate calls to gtk_tree_model_get() with a “-1” value
172    ///    gtk_tree_model_get (list_store, &iter,
173    ///                        STRING_COLUMN, &str_data,
174    ///                        INT_COLUMN, &int_data,
175    ///                        -1);
176    ///
177    ///    // Do something with the data
178    ///    g_print ("Row %d: (%s,%d)\n",
179    ///             row_count, str_data, int_data);
180    ///    g_free (str_data);
181    ///
182    ///    valid = gtk_tree_model_iter_next (list_store,
183    ///                                      &iter);
184    ///    row_count++;
185    ///  }
186    /// ```
187    ///
188    /// The [`TreeModel`][crate::TreeModel] interface contains two methods for reference
189    /// counting: gtk_tree_model_ref_node() and gtk_tree_model_unref_node().
190    /// These two methods are optional to implement. The reference counting
191    /// is meant as a way for views to let models know when nodes are being
192    /// displayed. [`TreeView`][crate::TreeView] will take a reference on a node when it is
193    /// visible, which means the node is either in the toplevel or expanded.
194    /// Being displayed does not mean that the node is currently directly
195    /// visible to the user in the viewport. Based on this reference counting
196    /// scheme a caching model, for example, can decide whether or not to cache
197    /// a node based on the reference count. A file-system based model would
198    /// not want to keep the entire file hierarchy in memory, but just the
199    /// folders that are currently expanded in every current view.
200    ///
201    /// When working with reference counting, the following rules must be taken
202    /// into account:
203    ///
204    /// - Never take a reference on a node without owning a reference on its parent.
205    ///   This means that all parent nodes of a referenced node must be referenced
206    ///   as well.
207    ///
208    /// - Outstanding references on a deleted node are not released. This is not
209    ///   possible because the node has already been deleted by the time the
210    ///   row-deleted signal is received.
211    ///
212    /// - Models are not obligated to emit a signal on rows of which none of its
213    ///   siblings are referenced. To phrase this differently, signals are only
214    ///   required for levels in which nodes are referenced. For the root level
215    ///   however, signals must be emitted at all times (however the root level
216    ///   is always referenced when any view is attached).
217    ///
218    /// ## Signals
219    ///
220    ///
221    /// #### `row-changed`
222    ///  This signal is emitted when a row in the model has changed.
223    ///
224    ///
225    ///
226    ///
227    /// #### `row-deleted`
228    ///  This signal is emitted when a row has been deleted.
229    ///
230    /// Note that no iterator is passed to the signal handler,
231    /// since the row is already deleted.
232    ///
233    /// This should be called by models after a row has been removed.
234    /// The location pointed to by @path should be the location that
235    /// the row previously was at. It may not be a valid location anymore.
236    ///
237    ///
238    ///
239    ///
240    /// #### `row-has-child-toggled`
241    ///  This signal is emitted when a row has gotten the first child
242    /// row or lost its last child row.
243    ///
244    ///
245    ///
246    ///
247    /// #### `row-inserted`
248    ///  This signal is emitted when a new row has been inserted in
249    /// the model.
250    ///
251    /// Note that the row may still be empty at this point, since
252    /// it is a common pattern to first insert an empty row, and
253    /// then fill it with the desired values.
254    ///
255    ///
256    ///
257    ///
258    /// #### `rows-reordered`
259    ///  This signal is emitted when the children of a node in the
260    /// [`TreeModel`][crate::TreeModel] have been reordered.
261    ///
262    /// Note that this signal is not emitted
263    /// when rows are reordered by DND, since this is implemented
264    /// by removing and then reinserting the row.
265    ///
266    ///
267    ///
268    /// # Implements
269    ///
270    /// [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeModelExtManual`][trait@crate::prelude::TreeModelExtManual]
271    #[doc(alias = "GtkTreeModel")]
272    pub struct TreeModel(Interface<ffi::GtkTreeModel, ffi::GtkTreeModelIface>);
273
274    match fn {
275        type_ => || ffi::gtk_tree_model_get_type(),
276    }
277}
278
279impl TreeModel {
280    pub const NONE: Option<&'static TreeModel> = None;
281}
282
283/// Trait containing all [`struct@TreeModel`] methods.
284///
285/// # Implementors
286///
287/// [`ListStore`][struct@crate::ListStore], [`TreeModelFilter`][struct@crate::TreeModelFilter], [`TreeModelSort`][struct@crate::TreeModelSort], [`TreeModel`][struct@crate::TreeModel], [`TreeSortable`][struct@crate::TreeSortable], [`TreeStore`][struct@crate::TreeStore]
288pub trait TreeModelExt: IsA<TreeModel> + 'static {
289    /// Calls @func on each node in model in a depth-first fashion.
290    ///
291    /// If @func returns [`true`], then the tree ceases to be walked,
292    /// and gtk_tree_model_foreach() returns.
293    ///
294    /// # Deprecated since 4.10
295    ///
296    /// ## `func`
297    /// a function to be called on each row
298    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
299    #[allow(deprecated)]
300    #[doc(alias = "gtk_tree_model_foreach")]
301    fn foreach<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(&self, func: P) {
302        let mut func_data: P = func;
303        unsafe extern "C" fn func_func<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(
304            model: *mut ffi::GtkTreeModel,
305            path: *mut ffi::GtkTreePath,
306            iter: *mut ffi::GtkTreeIter,
307            data: glib::ffi::gpointer,
308        ) -> glib::ffi::gboolean {
309            let model = from_glib_borrow(model);
310            let path = from_glib_borrow(path);
311            let iter = from_glib_borrow(iter);
312            let callback = data as *mut P;
313            (*callback)(&model, &path, &iter).into_glib()
314        }
315        let func = Some(func_func::<P> as _);
316        let super_callback0: &mut P = &mut func_data;
317        unsafe {
318            ffi::gtk_tree_model_foreach(
319                self.as_ref().to_glib_none().0,
320                func,
321                super_callback0 as *mut _ as *mut _,
322            );
323        }
324    }
325
326    /// Returns the type of the column.
327    ///
328    /// # Deprecated since 4.10
329    ///
330    /// ## `index_`
331    /// the column index
332    ///
333    /// # Returns
334    ///
335    /// the type of the column
336    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
337    #[allow(deprecated)]
338    #[doc(alias = "gtk_tree_model_get_column_type")]
339    #[doc(alias = "get_column_type")]
340    fn column_type(&self, index_: i32) -> glib::types::Type {
341        unsafe {
342            from_glib(ffi::gtk_tree_model_get_column_type(
343                self.as_ref().to_glib_none().0,
344                index_,
345            ))
346        }
347    }
348
349    /// Returns a set of flags supported by this interface.
350    ///
351    /// The flags are a bitwise combination of [`TreeModel`][crate::TreeModel]Flags.
352    /// The flags supported should not change during the lifetime
353    /// of the @self.
354    ///
355    /// # Deprecated since 4.10
356    ///
357    ///
358    /// # Returns
359    ///
360    /// the flags supported by this interface
361    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
362    #[allow(deprecated)]
363    #[doc(alias = "gtk_tree_model_get_flags")]
364    #[doc(alias = "get_flags")]
365    fn flags(&self) -> TreeModelFlags {
366        unsafe {
367            from_glib(ffi::gtk_tree_model_get_flags(
368                self.as_ref().to_glib_none().0,
369            ))
370        }
371    }
372
373    /// Sets @iter to a valid iterator pointing to @path.
374    ///
375    /// If @path does not exist, @iter is set to an invalid
376    /// iterator and [`false`] is returned.
377    ///
378    /// # Deprecated since 4.10
379    ///
380    /// ## `path`
381    /// the [`TreePath`][crate::TreePath]
382    ///
383    /// # Returns
384    ///
385    /// [`true`], if @iter was set
386    ///
387    /// ## `iter`
388    /// the uninitialized [`TreeIter`][crate::TreeIter]
389    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
390    #[allow(deprecated)]
391    #[doc(alias = "gtk_tree_model_get_iter")]
392    #[doc(alias = "get_iter")]
393    fn iter(&self, path: &TreePath) -> Option<TreeIter> {
394        unsafe {
395            let mut iter = TreeIter::uninitialized();
396            let ret = from_glib(ffi::gtk_tree_model_get_iter(
397                self.as_ref().to_glib_none().0,
398                iter.to_glib_none_mut().0,
399                mut_override(path.to_glib_none().0),
400            ));
401            if ret {
402                Some(iter)
403            } else {
404                None
405            }
406        }
407    }
408
409    /// Initializes @iter with the first iterator in the tree
410    /// (the one at the path "0").
411    ///
412    /// Returns [`false`] if the tree is empty, [`true`] otherwise.
413    ///
414    /// # Deprecated since 4.10
415    ///
416    ///
417    /// # Returns
418    ///
419    /// [`true`], if @iter was set
420    ///
421    /// ## `iter`
422    /// the uninitialized [`TreeIter`][crate::TreeIter]
423    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
424    #[allow(deprecated)]
425    #[doc(alias = "gtk_tree_model_get_iter_first")]
426    #[doc(alias = "get_iter_first")]
427    fn iter_first(&self) -> Option<TreeIter> {
428        unsafe {
429            let mut iter = TreeIter::uninitialized();
430            let ret = from_glib(ffi::gtk_tree_model_get_iter_first(
431                self.as_ref().to_glib_none().0,
432                iter.to_glib_none_mut().0,
433            ));
434            if ret {
435                Some(iter)
436            } else {
437                None
438            }
439        }
440    }
441
442    /// Sets @iter to a valid iterator pointing to @path_string, if it
443    /// exists.
444    ///
445    /// Otherwise, @iter is left invalid and [`false`] is returned.
446    ///
447    /// # Deprecated since 4.10
448    ///
449    /// ## `path_string`
450    /// a string representation of a [`TreePath`][crate::TreePath]
451    ///
452    /// # Returns
453    ///
454    /// [`true`], if @iter was set
455    ///
456    /// ## `iter`
457    /// an uninitialized [`TreeIter`][crate::TreeIter]
458    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
459    #[allow(deprecated)]
460    #[doc(alias = "gtk_tree_model_get_iter_from_string")]
461    #[doc(alias = "get_iter_from_string")]
462    fn iter_from_string(&self, path_string: &str) -> Option<TreeIter> {
463        unsafe {
464            let mut iter = TreeIter::uninitialized();
465            let ret = from_glib(ffi::gtk_tree_model_get_iter_from_string(
466                self.as_ref().to_glib_none().0,
467                iter.to_glib_none_mut().0,
468                path_string.to_glib_none().0,
469            ));
470            if ret {
471                Some(iter)
472            } else {
473                None
474            }
475        }
476    }
477
478    /// Returns the number of columns supported by @self.
479    ///
480    /// # Deprecated since 4.10
481    ///
482    ///
483    /// # Returns
484    ///
485    /// the number of columns
486    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
487    #[allow(deprecated)]
488    #[doc(alias = "gtk_tree_model_get_n_columns")]
489    #[doc(alias = "get_n_columns")]
490    fn n_columns(&self) -> i32 {
491        unsafe { ffi::gtk_tree_model_get_n_columns(self.as_ref().to_glib_none().0) }
492    }
493
494    /// Returns a newly-created [`TreePath`][crate::TreePath] referenced by @iter.
495    ///
496    /// This path should be freed with gtk_tree_path_free().
497    ///
498    /// # Deprecated since 4.10
499    ///
500    /// ## `iter`
501    /// the [`TreeIter`][crate::TreeIter]
502    ///
503    /// # Returns
504    ///
505    /// a newly-created [`TreePath`][crate::TreePath]
506    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
507    #[allow(deprecated)]
508    #[doc(alias = "gtk_tree_model_get_path")]
509    #[doc(alias = "get_path")]
510    fn path(&self, iter: &TreeIter) -> TreePath {
511        unsafe {
512            from_glib_full(ffi::gtk_tree_model_get_path(
513                self.as_ref().to_glib_none().0,
514                mut_override(iter.to_glib_none().0),
515            ))
516        }
517    }
518
519    /// Generates a string representation of the iter.
520    ///
521    /// This string is a “:” separated list of numbers.
522    /// For example, “4:10:0:3” would be an acceptable
523    /// return value for this string.
524    ///
525    /// # Deprecated since 4.10
526    ///
527    /// ## `iter`
528    /// a [`TreeIter`][crate::TreeIter]
529    ///
530    /// # Returns
531    ///
532    /// a newly-allocated string
533    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
534    #[allow(deprecated)]
535    #[doc(alias = "gtk_tree_model_get_string_from_iter")]
536    #[doc(alias = "get_string_from_iter")]
537    fn string_from_iter(&self, iter: &TreeIter) -> Option<glib::GString> {
538        unsafe {
539            from_glib_full(ffi::gtk_tree_model_get_string_from_iter(
540                self.as_ref().to_glib_none().0,
541                mut_override(iter.to_glib_none().0),
542            ))
543        }
544    }
545
546    /// Sets @iter to point to the first child of @parent.
547    ///
548    /// If @parent has no children, [`false`] is returned and @iter is
549    /// set to be invalid. @parent will remain a valid node after this
550    /// function has been called.
551    ///
552    /// If @parent is [`None`] returns the first node, equivalent to
553    /// `gtk_tree_model_get_iter_first (tree_model, iter);`
554    ///
555    /// # Deprecated since 4.10
556    ///
557    /// ## `parent`
558    /// the [`TreeIter`][crate::TreeIter]
559    ///
560    /// # Returns
561    ///
562    /// [`true`], if @iter has been set to the first child
563    ///
564    /// ## `iter`
565    /// the new [`TreeIter`][crate::TreeIter] to be set to the child
566    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
567    #[allow(deprecated)]
568    #[doc(alias = "gtk_tree_model_iter_children")]
569    fn iter_children(&self, parent: Option<&TreeIter>) -> Option<TreeIter> {
570        unsafe {
571            let mut iter = TreeIter::uninitialized();
572            let ret = from_glib(ffi::gtk_tree_model_iter_children(
573                self.as_ref().to_glib_none().0,
574                iter.to_glib_none_mut().0,
575                mut_override(parent.to_glib_none().0),
576            ));
577            if ret {
578                Some(iter)
579            } else {
580                None
581            }
582        }
583    }
584
585    /// Returns [`true`] if @iter has children, [`false`] otherwise.
586    ///
587    /// # Deprecated since 4.10
588    ///
589    /// ## `iter`
590    /// the [`TreeIter`][crate::TreeIter] to test for children
591    ///
592    /// # Returns
593    ///
594    /// [`true`] if @iter has children
595    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
596    #[allow(deprecated)]
597    #[doc(alias = "gtk_tree_model_iter_has_child")]
598    fn iter_has_child(&self, iter: &TreeIter) -> bool {
599        unsafe {
600            from_glib(ffi::gtk_tree_model_iter_has_child(
601                self.as_ref().to_glib_none().0,
602                mut_override(iter.to_glib_none().0),
603            ))
604        }
605    }
606
607    /// Returns the number of children that @iter has.
608    ///
609    /// As a special case, if @iter is [`None`], then the number
610    /// of toplevel nodes is returned.
611    ///
612    /// # Deprecated since 4.10
613    ///
614    /// ## `iter`
615    /// the [`TreeIter`][crate::TreeIter]
616    ///
617    /// # Returns
618    ///
619    /// the number of children of @iter
620    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
621    #[allow(deprecated)]
622    #[doc(alias = "gtk_tree_model_iter_n_children")]
623    fn iter_n_children(&self, iter: Option<&TreeIter>) -> i32 {
624        unsafe {
625            ffi::gtk_tree_model_iter_n_children(
626                self.as_ref().to_glib_none().0,
627                mut_override(iter.to_glib_none().0),
628            )
629        }
630    }
631
632    /// Sets @iter to point to the node following it at the current level.
633    ///
634    /// If there is no next @iter, [`false`] is returned and @iter is set
635    /// to be invalid.
636    ///
637    /// # Deprecated since 4.10
638    ///
639    /// ## `iter`
640    /// the [`TreeIter`][crate::TreeIter]
641    ///
642    /// # Returns
643    ///
644    /// [`true`] if @iter has been changed to the next node
645    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
646    #[allow(deprecated)]
647    #[doc(alias = "gtk_tree_model_iter_next")]
648    fn iter_next(&self, iter: &TreeIter) -> bool {
649        unsafe {
650            from_glib(ffi::gtk_tree_model_iter_next(
651                self.as_ref().to_glib_none().0,
652                mut_override(iter.to_glib_none().0),
653            ))
654        }
655    }
656
657    /// Sets @iter to be the child of @parent, using the given index.
658    ///
659    /// The first index is 0. If @n is too big, or @parent has no children,
660    /// @iter is set to an invalid iterator and [`false`] is returned. @parent
661    /// will remain a valid node after this function has been called. As a
662    /// special case, if @parent is [`None`], then the @n-th root node
663    /// is set.
664    ///
665    /// # Deprecated since 4.10
666    ///
667    /// ## `parent`
668    /// the [`TreeIter`][crate::TreeIter] to get the child from
669    /// ## `n`
670    /// the index of the desired child
671    ///
672    /// # Returns
673    ///
674    /// [`true`], if @parent has an @n-th child
675    ///
676    /// ## `iter`
677    /// the [`TreeIter`][crate::TreeIter] to set to the nth child
678    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
679    #[allow(deprecated)]
680    #[doc(alias = "gtk_tree_model_iter_nth_child")]
681    fn iter_nth_child(&self, parent: Option<&TreeIter>, n: i32) -> Option<TreeIter> {
682        unsafe {
683            let mut iter = TreeIter::uninitialized();
684            let ret = from_glib(ffi::gtk_tree_model_iter_nth_child(
685                self.as_ref().to_glib_none().0,
686                iter.to_glib_none_mut().0,
687                mut_override(parent.to_glib_none().0),
688                n,
689            ));
690            if ret {
691                Some(iter)
692            } else {
693                None
694            }
695        }
696    }
697
698    /// Sets @iter to be the parent of @child.
699    ///
700    /// If @child is at the toplevel, and doesn’t have a parent, then
701    /// @iter is set to an invalid iterator and [`false`] is returned.
702    /// @child will remain a valid node after this function has been
703    /// called.
704    ///
705    /// @iter will be initialized before the lookup is performed, so @child
706    /// and @iter cannot point to the same memory location.
707    ///
708    /// # Deprecated since 4.10
709    ///
710    /// ## `child`
711    /// the [`TreeIter`][crate::TreeIter]
712    ///
713    /// # Returns
714    ///
715    /// [`true`], if @iter is set to the parent of @child
716    ///
717    /// ## `iter`
718    /// the new [`TreeIter`][crate::TreeIter] to set to the parent
719    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
720    #[allow(deprecated)]
721    #[doc(alias = "gtk_tree_model_iter_parent")]
722    fn iter_parent(&self, child: &TreeIter) -> Option<TreeIter> {
723        unsafe {
724            let mut iter = TreeIter::uninitialized();
725            let ret = from_glib(ffi::gtk_tree_model_iter_parent(
726                self.as_ref().to_glib_none().0,
727                iter.to_glib_none_mut().0,
728                mut_override(child.to_glib_none().0),
729            ));
730            if ret {
731                Some(iter)
732            } else {
733                None
734            }
735        }
736    }
737
738    /// Sets @iter to point to the previous node at the current level.
739    ///
740    /// If there is no previous @iter, [`false`] is returned and @iter is
741    /// set to be invalid.
742    ///
743    /// # Deprecated since 4.10
744    ///
745    /// ## `iter`
746    /// the [`TreeIter`][crate::TreeIter]
747    ///
748    /// # Returns
749    ///
750    /// [`true`] if @iter has been changed to the previous node
751    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
752    #[allow(deprecated)]
753    #[doc(alias = "gtk_tree_model_iter_previous")]
754    fn iter_previous(&self, iter: &TreeIter) -> bool {
755        unsafe {
756            from_glib(ffi::gtk_tree_model_iter_previous(
757                self.as_ref().to_glib_none().0,
758                mut_override(iter.to_glib_none().0),
759            ))
760        }
761    }
762
763    /// Emits the ::row-changed signal on @self.
764    ///
765    /// See [`row-changed`][struct@crate::TreeModel#row-changed].
766    ///
767    /// # Deprecated since 4.10
768    ///
769    /// ## `path`
770    /// a [`TreePath`][crate::TreePath] pointing to the changed row
771    /// ## `iter`
772    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
773    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
774    #[allow(deprecated)]
775    #[doc(alias = "gtk_tree_model_row_changed")]
776    fn row_changed(&self, path: &TreePath, iter: &TreeIter) {
777        unsafe {
778            ffi::gtk_tree_model_row_changed(
779                self.as_ref().to_glib_none().0,
780                mut_override(path.to_glib_none().0),
781                mut_override(iter.to_glib_none().0),
782            );
783        }
784    }
785
786    /// Emits the ::row-deleted signal on @self.
787    ///
788    /// See [`row-deleted`][struct@crate::TreeModel#row-deleted].
789    ///
790    /// This should be called by models after a row has been removed.
791    /// The location pointed to by @path should be the location that
792    /// the row previously was at. It may not be a valid location anymore.
793    ///
794    /// Nodes that are deleted are not unreffed, this means that any
795    /// outstanding references on the deleted node should not be released.
796    ///
797    /// # Deprecated since 4.10
798    ///
799    /// ## `path`
800    /// a [`TreePath`][crate::TreePath] pointing to the previous location of
801    ///   the deleted row
802    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
803    #[allow(deprecated)]
804    #[doc(alias = "gtk_tree_model_row_deleted")]
805    fn row_deleted(&self, path: &TreePath) {
806        unsafe {
807            ffi::gtk_tree_model_row_deleted(
808                self.as_ref().to_glib_none().0,
809                mut_override(path.to_glib_none().0),
810            );
811        }
812    }
813
814    /// Emits the ::row-has-child-toggled signal on @self.
815    ///
816    /// See [`row-has-child-toggled`][struct@crate::TreeModel#row-has-child-toggled].
817    ///
818    /// This should be called by models after the child
819    /// state of a node changes.
820    ///
821    /// # Deprecated since 4.10
822    ///
823    /// ## `path`
824    /// a [`TreePath`][crate::TreePath] pointing to the changed row
825    /// ## `iter`
826    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
827    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
828    #[allow(deprecated)]
829    #[doc(alias = "gtk_tree_model_row_has_child_toggled")]
830    fn row_has_child_toggled(&self, path: &TreePath, iter: &TreeIter) {
831        unsafe {
832            ffi::gtk_tree_model_row_has_child_toggled(
833                self.as_ref().to_glib_none().0,
834                mut_override(path.to_glib_none().0),
835                mut_override(iter.to_glib_none().0),
836            );
837        }
838    }
839
840    /// Emits the ::row-inserted signal on @self.
841    ///
842    /// See [`row-inserted`][struct@crate::TreeModel#row-inserted].
843    ///
844    /// # Deprecated since 4.10
845    ///
846    /// ## `path`
847    /// a [`TreePath`][crate::TreePath] pointing to the inserted row
848    /// ## `iter`
849    /// a valid [`TreeIter`][crate::TreeIter] pointing to the inserted row
850    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
851    #[allow(deprecated)]
852    #[doc(alias = "gtk_tree_model_row_inserted")]
853    fn row_inserted(&self, path: &TreePath, iter: &TreeIter) {
854        unsafe {
855            ffi::gtk_tree_model_row_inserted(
856                self.as_ref().to_glib_none().0,
857                mut_override(path.to_glib_none().0),
858                mut_override(iter.to_glib_none().0),
859            );
860        }
861    }
862
863    /// This signal is emitted when a row in the model has changed.
864    /// ## `path`
865    /// a [`TreePath`][crate::TreePath] identifying the changed row
866    /// ## `iter`
867    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
868    #[doc(alias = "row-changed")]
869    fn connect_row_changed<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
870        &self,
871        f: F,
872    ) -> SignalHandlerId {
873        unsafe extern "C" fn row_changed_trampoline<
874            P: IsA<TreeModel>,
875            F: Fn(&P, &TreePath, &TreeIter) + 'static,
876        >(
877            this: *mut ffi::GtkTreeModel,
878            path: *mut ffi::GtkTreePath,
879            iter: *mut ffi::GtkTreeIter,
880            f: glib::ffi::gpointer,
881        ) {
882            let f: &F = &*(f as *const F);
883            f(
884                TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
885                &from_glib_borrow(path),
886                &from_glib_borrow(iter),
887            )
888        }
889        unsafe {
890            let f: Box_<F> = Box_::new(f);
891            connect_raw(
892                self.as_ptr() as *mut _,
893                c"row-changed".as_ptr() as *const _,
894                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
895                    row_changed_trampoline::<Self, F> as *const (),
896                )),
897                Box_::into_raw(f),
898            )
899        }
900    }
901
902    /// This signal is emitted when a row has been deleted.
903    ///
904    /// Note that no iterator is passed to the signal handler,
905    /// since the row is already deleted.
906    ///
907    /// This should be called by models after a row has been removed.
908    /// The location pointed to by @path should be the location that
909    /// the row previously was at. It may not be a valid location anymore.
910    /// ## `path`
911    /// a [`TreePath`][crate::TreePath] identifying the row
912    #[doc(alias = "row-deleted")]
913    fn connect_row_deleted<F: Fn(&Self, &TreePath) + 'static>(&self, f: F) -> SignalHandlerId {
914        unsafe extern "C" fn row_deleted_trampoline<
915            P: IsA<TreeModel>,
916            F: Fn(&P, &TreePath) + 'static,
917        >(
918            this: *mut ffi::GtkTreeModel,
919            path: *mut ffi::GtkTreePath,
920            f: glib::ffi::gpointer,
921        ) {
922            let f: &F = &*(f as *const F);
923            f(
924                TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
925                &from_glib_borrow(path),
926            )
927        }
928        unsafe {
929            let f: Box_<F> = Box_::new(f);
930            connect_raw(
931                self.as_ptr() as *mut _,
932                c"row-deleted".as_ptr() as *const _,
933                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
934                    row_deleted_trampoline::<Self, F> as *const (),
935                )),
936                Box_::into_raw(f),
937            )
938        }
939    }
940
941    /// This signal is emitted when a row has gotten the first child
942    /// row or lost its last child row.
943    /// ## `path`
944    /// a [`TreePath`][crate::TreePath] identifying the row
945    /// ## `iter`
946    /// a valid [`TreeIter`][crate::TreeIter] pointing to the row
947    #[doc(alias = "row-has-child-toggled")]
948    fn connect_row_has_child_toggled<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
949        &self,
950        f: F,
951    ) -> SignalHandlerId {
952        unsafe extern "C" fn row_has_child_toggled_trampoline<
953            P: IsA<TreeModel>,
954            F: Fn(&P, &TreePath, &TreeIter) + 'static,
955        >(
956            this: *mut ffi::GtkTreeModel,
957            path: *mut ffi::GtkTreePath,
958            iter: *mut ffi::GtkTreeIter,
959            f: glib::ffi::gpointer,
960        ) {
961            let f: &F = &*(f as *const F);
962            f(
963                TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
964                &from_glib_borrow(path),
965                &from_glib_borrow(iter),
966            )
967        }
968        unsafe {
969            let f: Box_<F> = Box_::new(f);
970            connect_raw(
971                self.as_ptr() as *mut _,
972                c"row-has-child-toggled".as_ptr() as *const _,
973                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
974                    row_has_child_toggled_trampoline::<Self, F> as *const (),
975                )),
976                Box_::into_raw(f),
977            )
978        }
979    }
980
981    /// This signal is emitted when a new row has been inserted in
982    /// the model.
983    ///
984    /// Note that the row may still be empty at this point, since
985    /// it is a common pattern to first insert an empty row, and
986    /// then fill it with the desired values.
987    /// ## `path`
988    /// a [`TreePath`][crate::TreePath] identifying the new row
989    /// ## `iter`
990    /// a valid [`TreeIter`][crate::TreeIter] pointing to the new row
991    #[doc(alias = "row-inserted")]
992    fn connect_row_inserted<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
993        &self,
994        f: F,
995    ) -> SignalHandlerId {
996        unsafe extern "C" fn row_inserted_trampoline<
997            P: IsA<TreeModel>,
998            F: Fn(&P, &TreePath, &TreeIter) + 'static,
999        >(
1000            this: *mut ffi::GtkTreeModel,
1001            path: *mut ffi::GtkTreePath,
1002            iter: *mut ffi::GtkTreeIter,
1003            f: glib::ffi::gpointer,
1004        ) {
1005            let f: &F = &*(f as *const F);
1006            f(
1007                TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
1008                &from_glib_borrow(path),
1009                &from_glib_borrow(iter),
1010            )
1011        }
1012        unsafe {
1013            let f: Box_<F> = Box_::new(f);
1014            connect_raw(
1015                self.as_ptr() as *mut _,
1016                c"row-inserted".as_ptr() as *const _,
1017                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1018                    row_inserted_trampoline::<Self, F> as *const (),
1019                )),
1020                Box_::into_raw(f),
1021            )
1022        }
1023    }
1024
1025    //#[doc(alias = "rows-reordered")]
1026    //fn connect_rows_reordered<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
1027    //    Unimplemented new_order: *.Pointer
1028    //}
1029}
1030
1031impl<O: IsA<TreeModel>> TreeModelExt for O {}