Skip to main content

gtk4/auto/
tree_model_filter.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::{TreeDragSource, TreeIter, TreeModel, TreePath, ffi};
7use glib::{prelude::*, translate::*};
8use std::boxed::Box as Box_;
9
10glib::wrapper! {
11    /// Use [`FilterListModel`][crate::FilterListModel] instead.
12    /// s child level (2 levels deeper) are visible, you are on your
13    /// own. In this case, either rely on [`TreeStore`][crate::TreeStore] to emit all signals
14    /// because it does not implement reference counting, or for models that
15    /// do implement reference counting, obtain references on these child levels
16    /// yourself.
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `child-model`
22    ///  The child model of the tree model filter.
23    ///
24    /// Readable | Writable | Construct Only
25    ///
26    ///
27    /// #### `virtual-root`
28    ///  The virtual root of the tree model filter.
29    ///
30    /// Readable | Writable | Construct Only
31    ///
32    /// # Implements
33    ///
34    /// [`TreeModelFilterExt`][trait@crate::prelude::TreeModelFilterExt], [`trait@glib::ObjectExt`], [`TreeDragSourceExt`][trait@crate::prelude::TreeDragSourceExt], [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeModelFilterExtManual`][trait@crate::prelude::TreeModelFilterExtManual], [`TreeModelExtManual`][trait@crate::prelude::TreeModelExtManual]
35    #[doc(alias = "GtkTreeModelFilter")]
36    pub struct TreeModelFilter(Object<ffi::GtkTreeModelFilter, ffi::GtkTreeModelFilterClass>) @implements TreeDragSource, TreeModel;
37
38    match fn {
39        type_ => || ffi::gtk_tree_model_filter_get_type(),
40    }
41}
42
43impl TreeModelFilter {
44    pub const NONE: Option<&'static TreeModelFilter> = None;
45}
46
47/// Trait containing all [`struct@TreeModelFilter`] methods.
48///
49/// # Implementors
50///
51/// [`TreeModelFilter`][struct@crate::TreeModelFilter]
52pub trait TreeModelFilterExt: IsA<TreeModelFilter> + 'static {
53    /// t change often) and there has been
54    /// a lot of unreffed access to nodes. As a side effect of this function,
55    /// all unreffed iters will be invalid.
56    ///
57    /// # Deprecated since 4.10
58    ///
59    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
60    #[allow(deprecated)]
61    #[doc(alias = "gtk_tree_model_filter_clear_cache")]
62    fn clear_cache(&self) {
63        unsafe {
64            ffi::gtk_tree_model_filter_clear_cache(self.as_ref().to_glib_none().0);
65        }
66    }
67
68    /// Sets @filter_iter to point to the row in @self that corresponds to the
69    /// row pointed at by @child_iter.  If @filter_iter was not set, [`false`] is
70    /// returned.
71    ///
72    /// # Deprecated since 4.10
73    ///
74    /// ## `child_iter`
75    /// A valid [`TreeIter`][crate::TreeIter] pointing to a row on the child model.
76    ///
77    /// # Returns
78    ///
79    /// [`true`], if @filter_iter was set, i.e. if @child_iter is a
80    /// valid iterator pointing to a visible row in child model.
81    ///
82    /// ## `filter_iter`
83    /// An uninitialized [`TreeIter`][crate::TreeIter]
84    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
85    #[allow(deprecated)]
86    #[doc(alias = "gtk_tree_model_filter_convert_child_iter_to_iter")]
87    fn convert_child_iter_to_iter(&self, child_iter: &TreeIter) -> Option<TreeIter> {
88        unsafe {
89            let mut filter_iter = TreeIter::uninitialized();
90            let ret = from_glib(ffi::gtk_tree_model_filter_convert_child_iter_to_iter(
91                self.as_ref().to_glib_none().0,
92                filter_iter.to_glib_none_mut().0,
93                mut_override(child_iter.to_glib_none().0),
94            ));
95            if ret { Some(filter_iter) } else { None }
96        }
97    }
98
99    /// t a valid path on the
100    /// child model or points to a row which is not visible in @self, then [`None`]
101    /// is returned.
102    ///
103    /// # Deprecated since 4.10
104    ///
105    /// ## `child_path`
106    /// A [`TreePath`][crate::TreePath] to convert.
107    ///
108    /// # Returns
109    ///
110    /// A newly allocated [`TreePath`][crate::TreePath]
111    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
112    #[allow(deprecated)]
113    #[doc(alias = "gtk_tree_model_filter_convert_child_path_to_path")]
114    fn convert_child_path_to_path(&self, child_path: &TreePath) -> Option<TreePath> {
115        unsafe {
116            from_glib_full(ffi::gtk_tree_model_filter_convert_child_path_to_path(
117                self.as_ref().to_glib_none().0,
118                mut_override(child_path.to_glib_none().0),
119            ))
120        }
121    }
122
123    /// Sets @child_iter to point to the row pointed to by @filter_iter.
124    ///
125    /// # Deprecated since 4.10
126    ///
127    /// ## `filter_iter`
128    /// A valid [`TreeIter`][crate::TreeIter] pointing to a row on @self.
129    ///
130    /// # Returns
131    ///
132    ///
133    /// ## `child_iter`
134    /// An uninitialized [`TreeIter`][crate::TreeIter]
135    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
136    #[allow(deprecated)]
137    #[doc(alias = "gtk_tree_model_filter_convert_iter_to_child_iter")]
138    fn convert_iter_to_child_iter(&self, filter_iter: &TreeIter) -> TreeIter {
139        unsafe {
140            let mut child_iter = TreeIter::uninitialized();
141            ffi::gtk_tree_model_filter_convert_iter_to_child_iter(
142                self.as_ref().to_glib_none().0,
143                child_iter.to_glib_none_mut().0,
144                mut_override(filter_iter.to_glib_none().0),
145            );
146            child_iter
147        }
148    }
149
150    /// Converts @filter_path to a path on the child model of @self. That is,
151    /// @filter_path points to a location in @self. The returned path will
152    /// point to the same location in the model not being filtered. If @filter_path
153    /// does not point to a location in the child model, [`None`] is returned.
154    ///
155    /// # Deprecated since 4.10
156    ///
157    /// ## `filter_path`
158    /// A [`TreePath`][crate::TreePath] to convert.
159    ///
160    /// # Returns
161    ///
162    /// A newly allocated [`TreePath`][crate::TreePath]
163    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
164    #[allow(deprecated)]
165    #[doc(alias = "gtk_tree_model_filter_convert_path_to_child_path")]
166    fn convert_path_to_child_path(&self, filter_path: &TreePath) -> Option<TreePath> {
167        unsafe {
168            from_glib_full(ffi::gtk_tree_model_filter_convert_path_to_child_path(
169                self.as_ref().to_glib_none().0,
170                mut_override(filter_path.to_glib_none().0),
171            ))
172        }
173    }
174
175    /// Returns a pointer to the child model of @self.
176    ///
177    /// # Deprecated since 4.10
178    ///
179    ///
180    /// # Returns
181    ///
182    /// A pointer to a [`TreeModel`][crate::TreeModel]
183    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
184    #[allow(deprecated)]
185    #[doc(alias = "gtk_tree_model_filter_get_model")]
186    #[doc(alias = "get_model")]
187    fn model(&self) -> TreeModel {
188        unsafe {
189            from_glib_none(ffi::gtk_tree_model_filter_get_model(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    /// Emits ::row_changed for each row in the child model, which causes
196    /// the filter to re-evaluate whether a row is visible or not.
197    ///
198    /// # Deprecated since 4.10
199    ///
200    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
201    #[allow(deprecated)]
202    #[doc(alias = "gtk_tree_model_filter_refilter")]
203    fn refilter(&self) {
204        unsafe {
205            ffi::gtk_tree_model_filter_refilter(self.as_ref().to_glib_none().0);
206        }
207    }
208
209    /// Sets @column of the child_model to be the column where @self should
210    /// look for visibility information. @columns should be a column of type
211    /// `G_TYPE_BOOLEAN`, where [`true`] means that a row is visible, and [`false`]
212    /// if not.
213    ///
214    /// Note that gtk_tree_model_filter_set_visible_func() or
215    /// gtk_tree_model_filter_set_visible_column() can only be called
216    /// once for a given filter model.
217    ///
218    /// # Deprecated since 4.10
219    ///
220    /// ## `column`
221    /// A `int` which is the column containing the visible information
222    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
223    #[allow(deprecated)]
224    #[doc(alias = "gtk_tree_model_filter_set_visible_column")]
225    fn set_visible_column(&self, column: i32) {
226        unsafe {
227            ffi::gtk_tree_model_filter_set_visible_column(self.as_ref().to_glib_none().0, column);
228        }
229    }
230
231    ///  strcmp (str, "HI") == 0)
232    ///     visible = TRUE;
233    ///   g_free (str);
234    ///
235    ///   return visible;
236    /// }
237    /// ```text
238    ///
239    /// Note that gtk_tree_model_filter_set_visible_func() or
240    /// gtk_tree_model_filter_set_visible_column() can only be called
241    /// once for a given filter model.
242    ///
243    /// # Deprecated since 4.10
244    ///
245    /// ## `func`
246    /// A `GtkTreeModelFilterVisibleFunc`, the visible function
247    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
248    #[allow(deprecated)]
249    #[doc(alias = "gtk_tree_model_filter_set_visible_func")]
250    fn set_visible_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(&self, func: P) {
251        let func_data: Box_<P> = Box_::new(func);
252        unsafe extern "C" fn func_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
253            model: *mut ffi::GtkTreeModel,
254            iter: *mut ffi::GtkTreeIter,
255            data: glib::ffi::gpointer,
256        ) -> glib::ffi::gboolean {
257            unsafe {
258                let model = from_glib_borrow(model);
259                let iter = from_glib_borrow(iter);
260                let callback = &*(data as *mut P);
261                (*callback)(&model, &iter).into_glib()
262            }
263        }
264        let func = Some(func_func::<P> as _);
265        unsafe extern "C" fn destroy_func<P: Fn(&TreeModel, &TreeIter) -> bool + 'static>(
266            data: glib::ffi::gpointer,
267        ) {
268            unsafe {
269                let _callback = Box_::from_raw(data as *mut P);
270            }
271        }
272        let destroy_call3 = Some(destroy_func::<P> as _);
273        let super_callback0: Box_<P> = func_data;
274        unsafe {
275            ffi::gtk_tree_model_filter_set_visible_func(
276                self.as_ref().to_glib_none().0,
277                func,
278                Box_::into_raw(super_callback0) as *mut _,
279                destroy_call3,
280            );
281        }
282    }
283
284    /// The child model of the tree model filter.
285    #[doc(alias = "child-model")]
286    fn child_model(&self) -> Option<TreeModel> {
287        ObjectExt::property(self.as_ref(), "child-model")
288    }
289}
290
291impl<O: IsA<TreeModelFilter>> TreeModelFilterExt for O {}