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