gtk/auto/list_store.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::{Buildable, TreeDragDest, TreeDragSource, TreeIter, TreeModel, TreeSortable, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 ///
10 /// ]|
11 ///
12 /// # Implements
13 ///
14 /// [`GtkListStoreExt`][trait@crate::prelude::GtkListStoreExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`TreeDragDestExt`][trait@crate::prelude::TreeDragDestExt], [`TreeDragSourceExt`][trait@crate::prelude::TreeDragSourceExt], [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeSortableExt`][trait@crate::prelude::TreeSortableExt], [`GtkListStoreExtManual`][trait@crate::prelude::GtkListStoreExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual], [`TreeSortableExtManual`][trait@crate::prelude::TreeSortableExtManual]
15 #[doc(alias = "GtkListStore")]
16 pub struct ListStore(Object<ffi::GtkListStore, ffi::GtkListStoreClass>) @implements Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable;
17
18 match fn {
19 type_ => || ffi::gtk_list_store_get_type(),
20 }
21}
22
23impl ListStore {
24 pub const NONE: Option<&'static ListStore> = None;
25
26 //#[doc(alias = "gtk_list_store_new")]
27 //pub fn new(n_columns: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> ListStore {
28 // unsafe { TODO: call ffi:gtk_list_store_new() }
29 //}
30
31 //#[doc(alias = "gtk_list_store_newv")]
32 //pub fn newv(types: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 30 }) -> ListStore {
33 // unsafe { TODO: call ffi:gtk_list_store_newv() }
34 //}
35}
36
37/// Trait containing all [`struct@ListStore`] methods.
38///
39/// # Implementors
40///
41/// [`ListStore`][struct@crate::ListStore]
42pub trait GtkListStoreExt: IsA<ListStore> + 'static {
43 /// Appends a new row to `self`. `iter` will be changed to point to this new
44 /// row. The row will be empty after this function is called. To fill in
45 /// values, you need to call [`GtkListStoreExtManual::set()`][crate::prelude::GtkListStoreExtManual::set()] or [`GtkListStoreExtManual::set_value()`][crate::prelude::GtkListStoreExtManual::set_value()].
46 ///
47 /// # Returns
48 ///
49 ///
50 /// ## `iter`
51 /// An unset [`TreeIter`][crate::TreeIter] to set to the appended row
52 #[doc(alias = "gtk_list_store_append")]
53 fn append(&self) -> TreeIter {
54 unsafe {
55 let mut iter = TreeIter::uninitialized();
56 ffi::gtk_list_store_append(self.as_ref().to_glib_none().0, iter.to_glib_none_mut().0);
57 iter
58 }
59 }
60
61 /// Removes all rows from the list store.
62 #[doc(alias = "gtk_list_store_clear")]
63 fn clear(&self) {
64 unsafe {
65 ffi::gtk_list_store_clear(self.as_ref().to_glib_none().0);
66 }
67 }
68
69 /// Creates a new row at `position`. `iter` will be changed to point to this new
70 /// row. If `position` is -1 or is larger than the number of rows on the list,
71 /// then the new row will be appended to the list. The row will be empty after
72 /// this function is called. To fill in values, you need to call
73 /// [`GtkListStoreExtManual::set()`][crate::prelude::GtkListStoreExtManual::set()] or [`GtkListStoreExtManual::set_value()`][crate::prelude::GtkListStoreExtManual::set_value()].
74 /// ## `position`
75 /// position to insert the new row, or -1 for last
76 ///
77 /// # Returns
78 ///
79 ///
80 /// ## `iter`
81 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
82 #[doc(alias = "gtk_list_store_insert")]
83 fn insert(&self, position: i32) -> TreeIter {
84 unsafe {
85 let mut iter = TreeIter::uninitialized();
86 ffi::gtk_list_store_insert(
87 self.as_ref().to_glib_none().0,
88 iter.to_glib_none_mut().0,
89 position,
90 );
91 iter
92 }
93 }
94
95 /// Inserts a new row after `sibling`. If `sibling` is [`None`], then the row will be
96 /// prepended to the beginning of the list. `iter` will be changed to point to
97 /// this new row. The row will be empty after this function is called. To fill
98 /// in values, you need to call [`GtkListStoreExtManual::set()`][crate::prelude::GtkListStoreExtManual::set()] or [`GtkListStoreExtManual::set_value()`][crate::prelude::GtkListStoreExtManual::set_value()].
99 /// ## `sibling`
100 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
101 ///
102 /// # Returns
103 ///
104 ///
105 /// ## `iter`
106 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
107 #[doc(alias = "gtk_list_store_insert_after")]
108 fn insert_after(&self, sibling: Option<&TreeIter>) -> TreeIter {
109 unsafe {
110 let mut iter = TreeIter::uninitialized();
111 ffi::gtk_list_store_insert_after(
112 self.as_ref().to_glib_none().0,
113 iter.to_glib_none_mut().0,
114 mut_override(sibling.to_glib_none().0),
115 );
116 iter
117 }
118 }
119
120 /// Inserts a new row before `sibling`. If `sibling` is [`None`], then the row will
121 /// be appended to the end of the list. `iter` will be changed to point to this
122 /// new row. The row will be empty after this function is called. To fill in
123 /// values, you need to call [`GtkListStoreExtManual::set()`][crate::prelude::GtkListStoreExtManual::set()] or [`GtkListStoreExtManual::set_value()`][crate::prelude::GtkListStoreExtManual::set_value()].
124 /// ## `sibling`
125 /// A valid [`TreeIter`][crate::TreeIter], or [`None`]
126 ///
127 /// # Returns
128 ///
129 ///
130 /// ## `iter`
131 /// An unset [`TreeIter`][crate::TreeIter] to set to the new row
132 #[doc(alias = "gtk_list_store_insert_before")]
133 fn insert_before(&self, sibling: Option<&TreeIter>) -> TreeIter {
134 unsafe {
135 let mut iter = TreeIter::uninitialized();
136 ffi::gtk_list_store_insert_before(
137 self.as_ref().to_glib_none().0,
138 iter.to_glib_none_mut().0,
139 mut_override(sibling.to_glib_none().0),
140 );
141 iter
142 }
143 }
144
145 //#[doc(alias = "gtk_list_store_insert_with_values")]
146 //fn insert_with_values(&self, position: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> TreeIter {
147 // unsafe { TODO: call ffi:gtk_list_store_insert_with_values() }
148 //}
149
150 //#[doc(alias = "gtk_list_store_insert_with_valuesv")]
151 //fn insert_with_valuesv(&self, position: i32, columns: &[i32], values: &[&glib::Value]) -> TreeIter {
152 // unsafe { TODO: call ffi:gtk_list_store_insert_with_valuesv() }
153 //}
154
155 /// purposes.
156 ///
157 /// Checks if the given iter is a valid iter for this [`ListStore`][crate::ListStore].
158 /// ## `iter`
159 /// A [`TreeIter`][crate::TreeIter].
160 ///
161 /// # Returns
162 ///
163 /// [`true`] if the iter is valid, [`false`] if the iter is invalid.
164 #[doc(alias = "gtk_list_store_iter_is_valid")]
165 fn iter_is_valid(&self, iter: &TreeIter) -> bool {
166 unsafe {
167 from_glib(ffi::gtk_list_store_iter_is_valid(
168 self.as_ref().to_glib_none().0,
169 mut_override(iter.to_glib_none().0),
170 ))
171 }
172 }
173
174 /// Moves `iter` in `self` to the position after `position`. Note that this
175 /// function only works with unsorted stores. If `position` is [`None`], `iter`
176 /// will be moved to the start of the list.
177 /// ## `iter`
178 /// A [`TreeIter`][crate::TreeIter].
179 /// ## `position`
180 /// A [`TreeIter`][crate::TreeIter] or [`None`].
181 #[doc(alias = "gtk_list_store_move_after")]
182 fn move_after(&self, iter: &TreeIter, position: Option<&TreeIter>) {
183 unsafe {
184 ffi::gtk_list_store_move_after(
185 self.as_ref().to_glib_none().0,
186 mut_override(iter.to_glib_none().0),
187 mut_override(position.to_glib_none().0),
188 );
189 }
190 }
191
192 /// Moves `iter` in `self` to the position before `position`. Note that this
193 /// function only works with unsorted stores. If `position` is [`None`], `iter`
194 /// will be moved to the end of the list.
195 /// ## `iter`
196 /// A [`TreeIter`][crate::TreeIter].
197 /// ## `position`
198 /// A [`TreeIter`][crate::TreeIter], or [`None`].
199 #[doc(alias = "gtk_list_store_move_before")]
200 fn move_before(&self, iter: &TreeIter, position: Option<&TreeIter>) {
201 unsafe {
202 ffi::gtk_list_store_move_before(
203 self.as_ref().to_glib_none().0,
204 mut_override(iter.to_glib_none().0),
205 mut_override(position.to_glib_none().0),
206 );
207 }
208 }
209
210 /// Prepends a new row to `self`. `iter` will be changed to point to this new
211 /// row. The row will be empty after this function is called. To fill in
212 /// values, you need to call [`GtkListStoreExtManual::set()`][crate::prelude::GtkListStoreExtManual::set()] or [`GtkListStoreExtManual::set_value()`][crate::prelude::GtkListStoreExtManual::set_value()].
213 ///
214 /// # Returns
215 ///
216 ///
217 /// ## `iter`
218 /// An unset [`TreeIter`][crate::TreeIter] to set to the prepend row
219 #[doc(alias = "gtk_list_store_prepend")]
220 fn prepend(&self) -> TreeIter {
221 unsafe {
222 let mut iter = TreeIter::uninitialized();
223 ffi::gtk_list_store_prepend(self.as_ref().to_glib_none().0, iter.to_glib_none_mut().0);
224 iter
225 }
226 }
227
228 /// Removes the given row from the list store. After being removed,
229 /// `iter` is set to be the next valid row, or invalidated if it pointed
230 /// to the last row in `self`.
231 /// ## `iter`
232 /// A valid [`TreeIter`][crate::TreeIter]
233 ///
234 /// # Returns
235 ///
236 /// [`true`] if `iter` is valid, [`false`] if not.
237 #[doc(alias = "gtk_list_store_remove")]
238 fn remove(&self, iter: &TreeIter) -> bool {
239 unsafe {
240 from_glib(ffi::gtk_list_store_remove(
241 self.as_ref().to_glib_none().0,
242 mut_override(iter.to_glib_none().0),
243 ))
244 }
245 }
246
247 //#[doc(alias = "gtk_list_store_set_column_types")]
248 //fn set_column_types(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 30 }) {
249 // unsafe { TODO: call ffi:gtk_list_store_set_column_types() }
250 //}
251
252 //#[doc(alias = "gtk_list_store_set_valist")]
253 //fn set_valist(&self, iter: &TreeIter, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
254 // unsafe { TODO: call ffi:gtk_list_store_set_valist() }
255 //}
256
257 //#[doc(alias = "gtk_list_store_set_valuesv")]
258 //fn set_valuesv(&self, iter: &TreeIter, columns: &[i32], values: &[&glib::Value]) {
259 // unsafe { TODO: call ffi:gtk_list_store_set_valuesv() }
260 //}
261
262 /// Swaps `a` and `b` in `self`. Note that this function only works with
263 /// unsorted stores.
264 /// ## `a`
265 /// A [`TreeIter`][crate::TreeIter].
266 /// ## `b`
267 /// Another [`TreeIter`][crate::TreeIter].
268 #[doc(alias = "gtk_list_store_swap")]
269 fn swap(&self, a: &TreeIter, b: &TreeIter) {
270 unsafe {
271 ffi::gtk_list_store_swap(
272 self.as_ref().to_glib_none().0,
273 mut_override(a.to_glib_none().0),
274 mut_override(b.to_glib_none().0),
275 );
276 }
277 }
278}
279
280impl<O: IsA<ListStore>> GtkListStoreExt for O {}