1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::TreeModel;
use crate::TreePath;
use glib::object::IsA;
use glib::translate::*;

glib::wrapper! {
    /// A GtkTreeRowReference tracks model changes so that it always refers to the
    /// same row (a [`TreePath`][crate::TreePath] refers to a position, not a fixed row). Create a
    /// new GtkTreeRowReference with gtk_tree_row_reference_new().
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct TreeRowReference(Boxed<ffi::GtkTreeRowReference>);

    match fn {
        copy => |ptr| ffi::gtk_tree_row_reference_copy(mut_override(ptr)),
        free => |ptr| ffi::gtk_tree_row_reference_free(ptr),
        type_ => || ffi::gtk_tree_row_reference_get_type(),
    }
}

impl TreeRowReference {
    /// Creates a row reference based on @path.
    ///
    /// This reference will keep pointing to the node pointed to
    /// by @path, so long as it exists. Any changes that occur on @model are
    /// propagated, and the path is updated appropriately. If
    /// @path isn’t a valid path in @model, then [`None`] is returned.
    /// ## `model`
    /// a [`TreeModel`][crate::TreeModel]
    /// ## `path`
    /// a valid [`TreePath`][crate::TreePath] to monitor
    ///
    /// # Returns
    ///
    /// a newly allocated [`TreeRowReference`][crate::TreeRowReference]
    #[doc(alias = "gtk_tree_row_reference_new")]
    pub fn new(model: &impl IsA<TreeModel>, path: &TreePath) -> Option<TreeRowReference> {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::gtk_tree_row_reference_new(
                model.as_ref().to_glib_none().0,
                mut_override(path.to_glib_none().0),
            ))
        }
    }

    /// You do not need to use this function.
    ///
    /// Creates a row reference based on @path.
    ///
    /// This reference will keep pointing to the node pointed to
    /// by @path, so long as it exists. If @path isn’t a valid
    /// path in @model, then [`None`] is returned. However, unlike
    /// references created with gtk_tree_row_reference_new(), it
    /// does not listen to the model for changes. The creator of
    /// the row reference must do this explicitly using
    /// gtk_tree_row_reference_inserted(), gtk_tree_row_reference_deleted(),
    /// gtk_tree_row_reference_reordered().
    ///
    /// These functions must be called exactly once per proxy when the
    /// corresponding signal on the model is emitted. This single call
    /// updates all row references for that proxy. Since built-in GTK
    /// objects like [`TreeView`][crate::TreeView] already use this mechanism internally,
    /// using them as the proxy object will produce unpredictable results.
    /// Further more, passing the same object as @model and @proxy
    /// doesn’t work for reasons of internal implementation.
    ///
    /// This type of row reference is primarily meant by structures that
    /// need to carefully monitor exactly when a row reference updates
    /// itself, and is not generally needed by most applications.
    /// ## `proxy`
    /// a proxy `GObject`
    /// ## `model`
    /// a [`TreeModel`][crate::TreeModel]
    /// ## `path`
    /// a valid [`TreePath`][crate::TreePath] to monitor
    ///
    /// # Returns
    ///
    /// a newly allocated [`TreeRowReference`][crate::TreeRowReference]
    #[doc(alias = "gtk_tree_row_reference_new_proxy")]
    pub fn new_proxy(
        proxy: &impl IsA<glib::Object>,
        model: &impl IsA<TreeModel>,
        path: &TreePath,
    ) -> Option<TreeRowReference> {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::gtk_tree_row_reference_new_proxy(
                proxy.as_ref().to_glib_none().0,
                model.as_ref().to_glib_none().0,
                mut_override(path.to_glib_none().0),
            ))
        }
    }

    /// Returns the model that the row reference is monitoring.
    ///
    /// # Returns
    ///
    /// the model
    #[doc(alias = "gtk_tree_row_reference_get_model")]
    #[doc(alias = "get_model")]
    pub fn model(&self) -> TreeModel {
        unsafe {
            from_glib_none(ffi::gtk_tree_row_reference_get_model(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    /// Returns a path that the row reference currently points to,
    /// or [`None`] if the path pointed to is no longer valid.
    ///
    /// # Returns
    ///
    /// a current path
    #[doc(alias = "gtk_tree_row_reference_get_path")]
    #[doc(alias = "get_path")]
    pub fn path(&self) -> Option<TreePath> {
        unsafe {
            from_glib_full(ffi::gtk_tree_row_reference_get_path(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    /// Returns [`true`] if the @self is non-[`None`] and refers to
    /// a current valid path.
    ///
    /// # Returns
    ///
    /// [`true`] if @self points to a valid path
    #[doc(alias = "gtk_tree_row_reference_valid")]
    pub fn valid(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_tree_row_reference_valid(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    /// Lets a set of row reference created by
    /// gtk_tree_row_reference_new_proxy() know that the
    /// model emitted the ::row-deleted signal.
    /// ## `proxy`
    /// a `GObject`
    /// ## `path`
    /// the path position that was deleted
    #[doc(alias = "gtk_tree_row_reference_deleted")]
    pub fn deleted(proxy: &impl IsA<glib::Object>, path: &TreePath) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_tree_row_reference_deleted(
                proxy.as_ref().to_glib_none().0,
                mut_override(path.to_glib_none().0),
            );
        }
    }

    /// Lets a set of row reference created by
    /// gtk_tree_row_reference_new_proxy() know that the
    /// model emitted the ::row-inserted signal.
    /// ## `proxy`
    /// a `GObject`
    /// ## `path`
    /// the row position that was inserted
    #[doc(alias = "gtk_tree_row_reference_inserted")]
    pub fn inserted(proxy: &impl IsA<glib::Object>, path: &TreePath) {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gtk_tree_row_reference_inserted(
                proxy.as_ref().to_glib_none().0,
                mut_override(path.to_glib_none().0),
            );
        }
    }
}