gtk4/auto/
tree_row_reference.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
5use crate::{ffi, TreeModel, TreePath};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A GtkTreeRowReference tracks model changes so that it always refers to the
10    /// same row (a [`TreePath`][crate::TreePath] refers to a position, not a fixed row). Create a
11    /// new GtkTreeRowReference with gtk_tree_row_reference_new().
12    ///
13    /// # Deprecated since 4.10
14    ///
15    /// Use [`gio::ListModel`][crate::gio::ListModel] instead
16    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17    pub struct TreeRowReference(Boxed<ffi::GtkTreeRowReference>);
18
19    match fn {
20        copy => |ptr| ffi::gtk_tree_row_reference_copy(mut_override(ptr)),
21        free => |ptr| ffi::gtk_tree_row_reference_free(ptr),
22        type_ => || ffi::gtk_tree_row_reference_get_type(),
23    }
24}
25
26impl TreeRowReference {
27    /// Creates a row reference based on @path.
28    ///
29    /// This reference will keep pointing to the node pointed to
30    /// by @path, so long as it exists. Any changes that occur on @model are
31    /// propagated, and the path is updated appropriately. If
32    /// @path isn’t a valid path in @model, then [`None`] is returned.
33    ///
34    /// # Deprecated since 4.10
35    ///
36    /// ## `model`
37    /// a [`TreeModel`][crate::TreeModel]
38    /// ## `path`
39    /// a valid [`TreePath`][crate::TreePath] to monitor
40    ///
41    /// # Returns
42    ///
43    /// a newly allocated [`TreeRowReference`][crate::TreeRowReference]
44    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
45    #[allow(deprecated)]
46    #[doc(alias = "gtk_tree_row_reference_new")]
47    pub fn new(model: &impl IsA<TreeModel>, path: &TreePath) -> Option<TreeRowReference> {
48        skip_assert_initialized!();
49        unsafe {
50            from_glib_full(ffi::gtk_tree_row_reference_new(
51                model.as_ref().to_glib_none().0,
52                mut_override(path.to_glib_none().0),
53            ))
54        }
55    }
56
57    /// You do not need to use this function.
58    ///
59    /// Creates a row reference based on @path.
60    ///
61    /// This reference will keep pointing to the node pointed to
62    /// by @path, so long as it exists. If @path isn’t a valid
63    /// path in @model, then [`None`] is returned. However, unlike
64    /// references created with gtk_tree_row_reference_new(), it
65    /// does not listen to the model for changes. The creator of
66    /// the row reference must do this explicitly using
67    /// gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(),
68    /// gtk_tree_row_reference_reordered().
69    ///
70    /// These functions must be called exactly once per proxy when the
71    /// corresponding signal on the model is emitted. This single call
72    /// updates all row references for that proxy. Since built-in GTK
73    /// objects like [`TreeView`][crate::TreeView] already use this mechanism internally,
74    /// using them as the proxy object will produce unpredictable results.
75    /// Further more, passing the same object as @model and @proxy
76    /// doesn’t work for reasons of internal implementation.
77    ///
78    /// This type of row reference is primarily meant by structures that
79    /// need to carefully monitor exactly when a row reference updates
80    /// itself, and is not generally needed by most applications.
81    ///
82    /// # Deprecated since 4.10
83    ///
84    /// ## `proxy`
85    /// a proxy `GObject`
86    /// ## `model`
87    /// a [`TreeModel`][crate::TreeModel]
88    /// ## `path`
89    /// a valid [`TreePath`][crate::TreePath] to monitor
90    ///
91    /// # Returns
92    ///
93    /// a newly allocated [`TreeRowReference`][crate::TreeRowReference]
94    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
95    #[allow(deprecated)]
96    #[doc(alias = "gtk_tree_row_reference_new_proxy")]
97    pub fn new_proxy(
98        proxy: &impl IsA<glib::Object>,
99        model: &impl IsA<TreeModel>,
100        path: &TreePath,
101    ) -> Option<TreeRowReference> {
102        skip_assert_initialized!();
103        unsafe {
104            from_glib_full(ffi::gtk_tree_row_reference_new_proxy(
105                proxy.as_ref().to_glib_none().0,
106                model.as_ref().to_glib_none().0,
107                mut_override(path.to_glib_none().0),
108            ))
109        }
110    }
111
112    /// Returns the model that the row reference is monitoring.
113    ///
114    /// # Deprecated since 4.10
115    ///
116    ///
117    /// # Returns
118    ///
119    /// the model
120    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
121    #[allow(deprecated)]
122    #[doc(alias = "gtk_tree_row_reference_get_model")]
123    #[doc(alias = "get_model")]
124    pub fn model(&self) -> TreeModel {
125        unsafe {
126            from_glib_none(ffi::gtk_tree_row_reference_get_model(mut_override(
127                self.to_glib_none().0,
128            )))
129        }
130    }
131
132    /// Returns a path that the row reference currently points to,
133    /// or [`None`] if the path pointed to is no longer valid.
134    ///
135    /// # Deprecated since 4.10
136    ///
137    ///
138    /// # Returns
139    ///
140    /// a current path
141    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
142    #[allow(deprecated)]
143    #[doc(alias = "gtk_tree_row_reference_get_path")]
144    #[doc(alias = "get_path")]
145    pub fn path(&self) -> Option<TreePath> {
146        unsafe {
147            from_glib_full(ffi::gtk_tree_row_reference_get_path(mut_override(
148                self.to_glib_none().0,
149            )))
150        }
151    }
152
153    /// Returns [`true`] if the @self is non-[`None`] and refers to
154    /// a current valid path.
155    ///
156    /// # Deprecated since 4.10
157    ///
158    ///
159    /// # Returns
160    ///
161    /// [`true`] if @self points to a valid path
162    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
163    #[allow(deprecated)]
164    #[doc(alias = "gtk_tree_row_reference_valid")]
165    pub fn valid(&self) -> bool {
166        unsafe {
167            from_glib(ffi::gtk_tree_row_reference_valid(mut_override(
168                self.to_glib_none().0,
169            )))
170        }
171    }
172
173    /// Lets a set of row reference created by
174    /// gtk_tree_row_reference_new_proxy() know that the
175    /// model emitted the ::row-deleted signal.
176    ///
177    /// # Deprecated since 4.10
178    ///
179    /// ## `proxy`
180    /// a `GObject`
181    /// ## `path`
182    /// the path position that was deleted
183    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
184    #[allow(deprecated)]
185    #[doc(alias = "gtk_tree_row_reference_deleted")]
186    pub fn deleted(proxy: &impl IsA<glib::Object>, path: &TreePath) {
187        assert_initialized_main_thread!();
188        unsafe {
189            ffi::gtk_tree_row_reference_deleted(
190                proxy.as_ref().to_glib_none().0,
191                mut_override(path.to_glib_none().0),
192            );
193        }
194    }
195
196    /// Lets a set of row reference created by
197    /// gtk_tree_row_reference_new_proxy() know that the
198    /// model emitted the ::row-inserted signal.
199    ///
200    /// # Deprecated since 4.10
201    ///
202    /// ## `proxy`
203    /// a `GObject`
204    /// ## `path`
205    /// the row position that was inserted
206    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
207    #[allow(deprecated)]
208    #[doc(alias = "gtk_tree_row_reference_inserted")]
209    pub fn inserted(proxy: &impl IsA<glib::Object>, path: &TreePath) {
210        assert_initialized_main_thread!();
211        unsafe {
212            ffi::gtk_tree_row_reference_inserted(
213                proxy.as_ref().to_glib_none().0,
214                mut_override(path.to_glib_none().0),
215            );
216        }
217    }
218}