Skip to main content

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::{TreeIter, TreeModelFlags, TreePath, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
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            unsafe {
310                let model = from_glib_borrow(model);
311                let path = from_glib_borrow(path);
312                let iter = from_glib_borrow(iter);
313                let callback = data as *mut P;
314                (*callback)(&model, &path, &iter).into_glib()
315            }
316        }
317        let func = Some(func_func::<P> as _);
318        let super_callback0: &mut P = &mut func_data;
319        unsafe {
320            ffi::gtk_tree_model_foreach(
321                self.as_ref().to_glib_none().0,
322                func,
323                super_callback0 as *mut _ as *mut _,
324            );
325        }
326    }
327
328    /// Returns the type of the column.
329    ///
330    /// # Deprecated since 4.10
331    ///
332    /// ## `index_`
333    /// the column index
334    ///
335    /// # Returns
336    ///
337    /// the type of the column
338    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
339    #[allow(deprecated)]
340    #[doc(alias = "gtk_tree_model_get_column_type")]
341    #[doc(alias = "get_column_type")]
342    fn column_type(&self, index_: i32) -> glib::types::Type {
343        unsafe {
344            from_glib(ffi::gtk_tree_model_get_column_type(
345                self.as_ref().to_glib_none().0,
346                index_,
347            ))
348        }
349    }
350
351    /// Returns a set of flags supported by this interface.
352    ///
353    /// The flags are a bitwise combination of [`TreeModel`][crate::TreeModel]Flags.
354    /// The flags supported should not change during the lifetime
355    /// of the @self.
356    ///
357    /// # Deprecated since 4.10
358    ///
359    ///
360    /// # Returns
361    ///
362    /// the flags supported by this interface
363    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
364    #[allow(deprecated)]
365    #[doc(alias = "gtk_tree_model_get_flags")]
366    #[doc(alias = "get_flags")]
367    fn flags(&self) -> TreeModelFlags {
368        unsafe {
369            from_glib(ffi::gtk_tree_model_get_flags(
370                self.as_ref().to_glib_none().0,
371            ))
372        }
373    }
374
375    /// Sets @iter to a valid iterator pointing to @path.
376    ///
377    /// If @path does not exist, @iter is set to an invalid
378    /// iterator and [`false`] is returned.
379    ///
380    /// # Deprecated since 4.10
381    ///
382    /// ## `path`
383    /// the [`TreePath`][crate::TreePath]
384    ///
385    /// # Returns
386    ///
387    /// [`true`], if @iter was set
388    ///
389    /// ## `iter`
390    /// the uninitialized [`TreeIter`][crate::TreeIter]
391    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
392    #[allow(deprecated)]
393    #[doc(alias = "gtk_tree_model_get_iter")]
394    #[doc(alias = "get_iter")]
395    fn iter(&self, path: &TreePath) -> Option<TreeIter> {
396        unsafe {
397            let mut iter = TreeIter::uninitialized();
398            let ret = from_glib(ffi::gtk_tree_model_get_iter(
399                self.as_ref().to_glib_none().0,
400                iter.to_glib_none_mut().0,
401                mut_override(path.to_glib_none().0),
402            ));
403            if ret { Some(iter) } else { None }
404        }
405    }
406
407    /// Initializes @iter with the first iterator in the tree
408    /// (the one at the path "0").
409    ///
410    /// Returns [`false`] if the tree is empty, [`true`] otherwise.
411    ///
412    /// # Deprecated since 4.10
413    ///
414    ///
415    /// # Returns
416    ///
417    /// [`true`], if @iter was set
418    ///
419    /// ## `iter`
420    /// the uninitialized [`TreeIter`][crate::TreeIter]
421    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
422    #[allow(deprecated)]
423    #[doc(alias = "gtk_tree_model_get_iter_first")]
424    #[doc(alias = "get_iter_first")]
425    fn iter_first(&self) -> Option<TreeIter> {
426        unsafe {
427            let mut iter = TreeIter::uninitialized();
428            let ret = from_glib(ffi::gtk_tree_model_get_iter_first(
429                self.as_ref().to_glib_none().0,
430                iter.to_glib_none_mut().0,
431            ));
432            if ret { Some(iter) } else { None }
433        }
434    }
435
436    /// Sets @iter to a valid iterator pointing to @path_string, if it
437    /// exists.
438    ///
439    /// Otherwise, @iter is left invalid and [`false`] is returned.
440    ///
441    /// # Deprecated since 4.10
442    ///
443    /// ## `path_string`
444    /// a string representation of a [`TreePath`][crate::TreePath]
445    ///
446    /// # Returns
447    ///
448    /// [`true`], if @iter was set
449    ///
450    /// ## `iter`
451    /// an uninitialized [`TreeIter`][crate::TreeIter]
452    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
453    #[allow(deprecated)]
454    #[doc(alias = "gtk_tree_model_get_iter_from_string")]
455    #[doc(alias = "get_iter_from_string")]
456    fn iter_from_string(&self, path_string: &str) -> Option<TreeIter> {
457        unsafe {
458            let mut iter = TreeIter::uninitialized();
459            let ret = from_glib(ffi::gtk_tree_model_get_iter_from_string(
460                self.as_ref().to_glib_none().0,
461                iter.to_glib_none_mut().0,
462                path_string.to_glib_none().0,
463            ));
464            if ret { Some(iter) } else { None }
465        }
466    }
467
468    /// Returns the number of columns supported by @self.
469    ///
470    /// # Deprecated since 4.10
471    ///
472    ///
473    /// # Returns
474    ///
475    /// the number of columns
476    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
477    #[allow(deprecated)]
478    #[doc(alias = "gtk_tree_model_get_n_columns")]
479    #[doc(alias = "get_n_columns")]
480    fn n_columns(&self) -> i32 {
481        unsafe { ffi::gtk_tree_model_get_n_columns(self.as_ref().to_glib_none().0) }
482    }
483
484    /// Returns a newly-created [`TreePath`][crate::TreePath] referenced by @iter.
485    ///
486    /// This path should be freed with gtk_tree_path_free().
487    ///
488    /// # Deprecated since 4.10
489    ///
490    /// ## `iter`
491    /// the [`TreeIter`][crate::TreeIter]
492    ///
493    /// # Returns
494    ///
495    /// a newly-created [`TreePath`][crate::TreePath]
496    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
497    #[allow(deprecated)]
498    #[doc(alias = "gtk_tree_model_get_path")]
499    #[doc(alias = "get_path")]
500    fn path(&self, iter: &TreeIter) -> TreePath {
501        unsafe {
502            from_glib_full(ffi::gtk_tree_model_get_path(
503                self.as_ref().to_glib_none().0,
504                mut_override(iter.to_glib_none().0),
505            ))
506        }
507    }
508
509    /// Generates a string representation of the iter.
510    ///
511    /// This string is a “:” separated list of numbers.
512    /// For example, “4:10:0:3” would be an acceptable
513    /// return value for this string.
514    ///
515    /// # Deprecated since 4.10
516    ///
517    /// ## `iter`
518    /// a [`TreeIter`][crate::TreeIter]
519    ///
520    /// # Returns
521    ///
522    /// a newly-allocated string
523    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
524    #[allow(deprecated)]
525    #[doc(alias = "gtk_tree_model_get_string_from_iter")]
526    #[doc(alias = "get_string_from_iter")]
527    fn string_from_iter(&self, iter: &TreeIter) -> Option<glib::GString> {
528        unsafe {
529            from_glib_full(ffi::gtk_tree_model_get_string_from_iter(
530                self.as_ref().to_glib_none().0,
531                mut_override(iter.to_glib_none().0),
532            ))
533        }
534    }
535
536    /// Sets @iter to point to the first child of @parent.
537    ///
538    /// If @parent has no children, [`false`] is returned and @iter is
539    /// set to be invalid. @parent will remain a valid node after this
540    /// function has been called.
541    ///
542    /// If @parent is [`None`] returns the first node, equivalent to
543    /// `gtk_tree_model_get_iter_first (tree_model, iter);`
544    ///
545    /// # Deprecated since 4.10
546    ///
547    /// ## `parent`
548    /// the [`TreeIter`][crate::TreeIter]
549    ///
550    /// # Returns
551    ///
552    /// [`true`], if @iter has been set to the first child
553    ///
554    /// ## `iter`
555    /// the new [`TreeIter`][crate::TreeIter] to be set to the child
556    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
557    #[allow(deprecated)]
558    #[doc(alias = "gtk_tree_model_iter_children")]
559    fn iter_children(&self, parent: Option<&TreeIter>) -> Option<TreeIter> {
560        unsafe {
561            let mut iter = TreeIter::uninitialized();
562            let ret = from_glib(ffi::gtk_tree_model_iter_children(
563                self.as_ref().to_glib_none().0,
564                iter.to_glib_none_mut().0,
565                mut_override(parent.to_glib_none().0),
566            ));
567            if ret { Some(iter) } else { None }
568        }
569    }
570
571    /// Returns [`true`] if @iter has children, [`false`] otherwise.
572    ///
573    /// # Deprecated since 4.10
574    ///
575    /// ## `iter`
576    /// the [`TreeIter`][crate::TreeIter] to test for children
577    ///
578    /// # Returns
579    ///
580    /// [`true`] if @iter has children
581    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
582    #[allow(deprecated)]
583    #[doc(alias = "gtk_tree_model_iter_has_child")]
584    fn iter_has_child(&self, iter: &TreeIter) -> bool {
585        unsafe {
586            from_glib(ffi::gtk_tree_model_iter_has_child(
587                self.as_ref().to_glib_none().0,
588                mut_override(iter.to_glib_none().0),
589            ))
590        }
591    }
592
593    /// Returns the number of children that @iter has.
594    ///
595    /// As a special case, if @iter is [`None`], then the number
596    /// of toplevel nodes is returned.
597    ///
598    /// # Deprecated since 4.10
599    ///
600    /// ## `iter`
601    /// the [`TreeIter`][crate::TreeIter]
602    ///
603    /// # Returns
604    ///
605    /// the number of children of @iter
606    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
607    #[allow(deprecated)]
608    #[doc(alias = "gtk_tree_model_iter_n_children")]
609    fn iter_n_children(&self, iter: Option<&TreeIter>) -> i32 {
610        unsafe {
611            ffi::gtk_tree_model_iter_n_children(
612                self.as_ref().to_glib_none().0,
613                mut_override(iter.to_glib_none().0),
614            )
615        }
616    }
617
618    /// Sets @iter to be the child of @parent, using the given index.
619    ///
620    /// The first index is 0. If @n is too big, or @parent has no children,
621    /// @iter is set to an invalid iterator and [`false`] is returned. @parent
622    /// will remain a valid node after this function has been called. As a
623    /// special case, if @parent is [`None`], then the @n-th root node
624    /// is set.
625    ///
626    /// # Deprecated since 4.10
627    ///
628    /// ## `parent`
629    /// the [`TreeIter`][crate::TreeIter] to get the child from
630    /// ## `n`
631    /// the index of the desired child
632    ///
633    /// # Returns
634    ///
635    /// [`true`], if @parent has an @n-th child
636    ///
637    /// ## `iter`
638    /// the [`TreeIter`][crate::TreeIter] to set to the nth child
639    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
640    #[allow(deprecated)]
641    #[doc(alias = "gtk_tree_model_iter_nth_child")]
642    fn iter_nth_child(&self, parent: Option<&TreeIter>, n: i32) -> Option<TreeIter> {
643        unsafe {
644            let mut iter = TreeIter::uninitialized();
645            let ret = from_glib(ffi::gtk_tree_model_iter_nth_child(
646                self.as_ref().to_glib_none().0,
647                iter.to_glib_none_mut().0,
648                mut_override(parent.to_glib_none().0),
649                n,
650            ));
651            if ret { Some(iter) } else { None }
652        }
653    }
654
655    /// Sets @iter to be the parent of @child.
656    ///
657    /// If @child is at the toplevel, and doesn’t have a parent, then
658    /// @iter is set to an invalid iterator and [`false`] is returned.
659    /// @child will remain a valid node after this function has been
660    /// called.
661    ///
662    /// @iter will be initialized before the lookup is performed, so @child
663    /// and @iter cannot point to the same memory location.
664    ///
665    /// # Deprecated since 4.10
666    ///
667    /// ## `child`
668    /// the [`TreeIter`][crate::TreeIter]
669    ///
670    /// # Returns
671    ///
672    /// [`true`], if @iter is set to the parent of @child
673    ///
674    /// ## `iter`
675    /// the new [`TreeIter`][crate::TreeIter] to set to the parent
676    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
677    #[allow(deprecated)]
678    #[doc(alias = "gtk_tree_model_iter_parent")]
679    fn iter_parent(&self, child: &TreeIter) -> Option<TreeIter> {
680        unsafe {
681            let mut iter = TreeIter::uninitialized();
682            let ret = from_glib(ffi::gtk_tree_model_iter_parent(
683                self.as_ref().to_glib_none().0,
684                iter.to_glib_none_mut().0,
685                mut_override(child.to_glib_none().0),
686            ));
687            if ret { Some(iter) } else { None }
688        }
689    }
690
691    /// Emits the ::row-changed signal on @self.
692    ///
693    /// See [`row-changed`][struct@crate::TreeModel#row-changed].
694    ///
695    /// # Deprecated since 4.10
696    ///
697    /// ## `path`
698    /// a [`TreePath`][crate::TreePath] pointing to the changed row
699    /// ## `iter`
700    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
701    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
702    #[allow(deprecated)]
703    #[doc(alias = "gtk_tree_model_row_changed")]
704    fn row_changed(&self, path: &TreePath, iter: &TreeIter) {
705        unsafe {
706            ffi::gtk_tree_model_row_changed(
707                self.as_ref().to_glib_none().0,
708                mut_override(path.to_glib_none().0),
709                mut_override(iter.to_glib_none().0),
710            );
711        }
712    }
713
714    /// Emits the ::row-deleted signal on @self.
715    ///
716    /// See [`row-deleted`][struct@crate::TreeModel#row-deleted].
717    ///
718    /// This should be called by models after a row has been removed.
719    /// The location pointed to by @path should be the location that
720    /// the row previously was at. It may not be a valid location anymore.
721    ///
722    /// Nodes that are deleted are not unreffed, this means that any
723    /// outstanding references on the deleted node should not be released.
724    ///
725    /// # Deprecated since 4.10
726    ///
727    /// ## `path`
728    /// a [`TreePath`][crate::TreePath] pointing to the previous location of
729    ///   the deleted row
730    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
731    #[allow(deprecated)]
732    #[doc(alias = "gtk_tree_model_row_deleted")]
733    fn row_deleted(&self, path: &TreePath) {
734        unsafe {
735            ffi::gtk_tree_model_row_deleted(
736                self.as_ref().to_glib_none().0,
737                mut_override(path.to_glib_none().0),
738            );
739        }
740    }
741
742    /// Emits the ::row-has-child-toggled signal on @self.
743    ///
744    /// See [`row-has-child-toggled`][struct@crate::TreeModel#row-has-child-toggled].
745    ///
746    /// This should be called by models after the child
747    /// state of a node changes.
748    ///
749    /// # Deprecated since 4.10
750    ///
751    /// ## `path`
752    /// a [`TreePath`][crate::TreePath] pointing to the changed row
753    /// ## `iter`
754    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
755    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
756    #[allow(deprecated)]
757    #[doc(alias = "gtk_tree_model_row_has_child_toggled")]
758    fn row_has_child_toggled(&self, path: &TreePath, iter: &TreeIter) {
759        unsafe {
760            ffi::gtk_tree_model_row_has_child_toggled(
761                self.as_ref().to_glib_none().0,
762                mut_override(path.to_glib_none().0),
763                mut_override(iter.to_glib_none().0),
764            );
765        }
766    }
767
768    /// Emits the ::row-inserted signal on @self.
769    ///
770    /// See [`row-inserted`][struct@crate::TreeModel#row-inserted].
771    ///
772    /// # Deprecated since 4.10
773    ///
774    /// ## `path`
775    /// a [`TreePath`][crate::TreePath] pointing to the inserted row
776    /// ## `iter`
777    /// a valid [`TreeIter`][crate::TreeIter] pointing to the inserted row
778    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
779    #[allow(deprecated)]
780    #[doc(alias = "gtk_tree_model_row_inserted")]
781    fn row_inserted(&self, path: &TreePath, iter: &TreeIter) {
782        unsafe {
783            ffi::gtk_tree_model_row_inserted(
784                self.as_ref().to_glib_none().0,
785                mut_override(path.to_glib_none().0),
786                mut_override(iter.to_glib_none().0),
787            );
788        }
789    }
790
791    /// This signal is emitted when a row in the model has changed.
792    /// ## `path`
793    /// a [`TreePath`][crate::TreePath] identifying the changed row
794    /// ## `iter`
795    /// a valid [`TreeIter`][crate::TreeIter] pointing to the changed row
796    #[doc(alias = "row-changed")]
797    fn connect_row_changed<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
798        &self,
799        f: F,
800    ) -> SignalHandlerId {
801        unsafe extern "C" fn row_changed_trampoline<
802            P: IsA<TreeModel>,
803            F: Fn(&P, &TreePath, &TreeIter) + 'static,
804        >(
805            this: *mut ffi::GtkTreeModel,
806            path: *mut ffi::GtkTreePath,
807            iter: *mut ffi::GtkTreeIter,
808            f: glib::ffi::gpointer,
809        ) {
810            unsafe {
811                let f: &F = &*(f as *const F);
812                f(
813                    TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
814                    &from_glib_borrow(path),
815                    &from_glib_borrow(iter),
816                )
817            }
818        }
819        unsafe {
820            let f: Box_<F> = Box_::new(f);
821            connect_raw(
822                self.as_ptr() as *mut _,
823                c"row-changed".as_ptr() as *const _,
824                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
825                    row_changed_trampoline::<Self, F> as *const (),
826                )),
827                Box_::into_raw(f),
828            )
829        }
830    }
831
832    /// This signal is emitted when a row has been deleted.
833    ///
834    /// Note that no iterator is passed to the signal handler,
835    /// since the row is already deleted.
836    ///
837    /// This should be called by models after a row has been removed.
838    /// The location pointed to by @path should be the location that
839    /// the row previously was at. It may not be a valid location anymore.
840    /// ## `path`
841    /// a [`TreePath`][crate::TreePath] identifying the row
842    #[doc(alias = "row-deleted")]
843    fn connect_row_deleted<F: Fn(&Self, &TreePath) + 'static>(&self, f: F) -> SignalHandlerId {
844        unsafe extern "C" fn row_deleted_trampoline<
845            P: IsA<TreeModel>,
846            F: Fn(&P, &TreePath) + 'static,
847        >(
848            this: *mut ffi::GtkTreeModel,
849            path: *mut ffi::GtkTreePath,
850            f: glib::ffi::gpointer,
851        ) {
852            unsafe {
853                let f: &F = &*(f as *const F);
854                f(
855                    TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
856                    &from_glib_borrow(path),
857                )
858            }
859        }
860        unsafe {
861            let f: Box_<F> = Box_::new(f);
862            connect_raw(
863                self.as_ptr() as *mut _,
864                c"row-deleted".as_ptr() as *const _,
865                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
866                    row_deleted_trampoline::<Self, F> as *const (),
867                )),
868                Box_::into_raw(f),
869            )
870        }
871    }
872
873    /// This signal is emitted when a row has gotten the first child
874    /// row or lost its last child row.
875    /// ## `path`
876    /// a [`TreePath`][crate::TreePath] identifying the row
877    /// ## `iter`
878    /// a valid [`TreeIter`][crate::TreeIter] pointing to the row
879    #[doc(alias = "row-has-child-toggled")]
880    fn connect_row_has_child_toggled<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
881        &self,
882        f: F,
883    ) -> SignalHandlerId {
884        unsafe extern "C" fn row_has_child_toggled_trampoline<
885            P: IsA<TreeModel>,
886            F: Fn(&P, &TreePath, &TreeIter) + 'static,
887        >(
888            this: *mut ffi::GtkTreeModel,
889            path: *mut ffi::GtkTreePath,
890            iter: *mut ffi::GtkTreeIter,
891            f: glib::ffi::gpointer,
892        ) {
893            unsafe {
894                let f: &F = &*(f as *const F);
895                f(
896                    TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
897                    &from_glib_borrow(path),
898                    &from_glib_borrow(iter),
899                )
900            }
901        }
902        unsafe {
903            let f: Box_<F> = Box_::new(f);
904            connect_raw(
905                self.as_ptr() as *mut _,
906                c"row-has-child-toggled".as_ptr() as *const _,
907                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
908                    row_has_child_toggled_trampoline::<Self, F> as *const (),
909                )),
910                Box_::into_raw(f),
911            )
912        }
913    }
914
915    /// This signal is emitted when a new row has been inserted in
916    /// the model.
917    ///
918    /// Note that the row may still be empty at this point, since
919    /// it is a common pattern to first insert an empty row, and
920    /// then fill it with the desired values.
921    /// ## `path`
922    /// a [`TreePath`][crate::TreePath] identifying the new row
923    /// ## `iter`
924    /// a valid [`TreeIter`][crate::TreeIter] pointing to the new row
925    #[doc(alias = "row-inserted")]
926    fn connect_row_inserted<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
927        &self,
928        f: F,
929    ) -> SignalHandlerId {
930        unsafe extern "C" fn row_inserted_trampoline<
931            P: IsA<TreeModel>,
932            F: Fn(&P, &TreePath, &TreeIter) + 'static,
933        >(
934            this: *mut ffi::GtkTreeModel,
935            path: *mut ffi::GtkTreePath,
936            iter: *mut ffi::GtkTreeIter,
937            f: glib::ffi::gpointer,
938        ) {
939            unsafe {
940                let f: &F = &*(f as *const F);
941                f(
942                    TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
943                    &from_glib_borrow(path),
944                    &from_glib_borrow(iter),
945                )
946            }
947        }
948        unsafe {
949            let f: Box_<F> = Box_::new(f);
950            connect_raw(
951                self.as_ptr() as *mut _,
952                c"row-inserted".as_ptr() as *const _,
953                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
954                    row_inserted_trampoline::<Self, F> as *const (),
955                )),
956                Box_::into_raw(f),
957            )
958        }
959    }
960
961    //#[doc(alias = "rows-reordered")]
962    //fn connect_rows_reordered<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
963    //    Unimplemented new_order: *.Pointer
964    //}
965}
966
967impl<O: IsA<TreeModel>> TreeModelExt for O {}