gtk/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
5use crate::{TreeIter, TreeModelFlags, TreePath, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// iter);
16 /// row_count++;
17 /// }
18 /// ]|
19 ///
20 /// The [`TreeModel`][crate::TreeModel] interface contains two methods for reference
21 /// counting: `gtk_tree_model_ref_node()` and `gtk_tree_model_unref_node()`.
22 /// These two methods are optional to implement. The reference counting
23 /// is meant as a way for views to let models know when nodes are being
24 /// displayed. [`TreeView`][crate::TreeView] will take a reference on a node when it is
25 /// visible, which means the node is either in the toplevel or expanded.
26 /// Being displayed does not mean that the node is currently directly
27 /// visible to the user in the viewport. Based on this reference counting
28 /// scheme a caching model, for example, can decide whether or not to cache
29 /// a node based on the reference count. A file-system based model would
30 /// not want to keep the entire file hierarchy in memory, but just the
31 /// folders that are currently expanded in every current view.
32 ///
33 /// When working with reference counting, the following rules must be taken
34 /// into account:
35 ///
36 /// - Never take a reference on a node without owning a reference on its parent.
37 /// This means that all parent nodes of a referenced node must be referenced
38 /// as well.
39 ///
40 /// - Outstanding references on a deleted node are not released. This is not
41 /// possible because the node has already been deleted by the time the
42 /// row-deleted signal is received.
43 ///
44 /// - Models are not obligated to emit a signal on rows of which none of its
45 /// siblings are referenced. To phrase this differently, signals are only
46 /// required for levels in which nodes are referenced. For the root level
47 /// however, signals must be emitted at all times (however the root level
48 /// is always referenced when any view is attached).
49 ///
50 /// ## Signals
51 ///
52 ///
53 /// #### `row-changed`
54 /// This signal is emitted when a row in the model has changed.
55 ///
56 ///
57 ///
58 ///
59 /// #### `row-deleted`
60 /// This signal is emitted when a row has been deleted.
61 ///
62 /// Note that no iterator is passed to the signal handler,
63 /// since the row is already deleted.
64 ///
65 /// This should be called by models after a row has been removed.
66 /// The location pointed to by `path` should be the location that
67 /// the row previously was at. It may not be a valid location anymore.
68 ///
69 ///
70 ///
71 ///
72 /// #### `row-has-child-toggled`
73 /// This signal is emitted when a row has gotten the first child
74 /// row or lost its last child row.
75 ///
76 ///
77 ///
78 ///
79 /// #### `row-inserted`
80 /// This signal is emitted when a new row has been inserted in
81 /// the model.
82 ///
83 /// Note that the row may still be empty at this point, since
84 /// it is a common pattern to first insert an empty row, and
85 /// then fill it with the desired values.
86 ///
87 ///
88 ///
89 ///
90 /// #### `rows-reordered`
91 /// This signal is emitted when the children of a node in the
92 /// [`TreeModel`][crate::TreeModel] have been reordered.
93 ///
94 /// Note that this signal is not emitted
95 /// when rows are reordered by DND, since this is implemented
96 /// by removing and then reinserting the row.
97 ///
98 ///
99 ///
100 /// # Implements
101 ///
102 /// [`TreeModelExt`][trait@crate::prelude::TreeModelExt]
103 #[doc(alias = "GtkTreeModel")]
104 pub struct TreeModel(Interface<ffi::GtkTreeModel, ffi::GtkTreeModelIface>);
105
106 match fn {
107 type_ => || ffi::gtk_tree_model_get_type(),
108 }
109}
110
111impl TreeModel {
112 pub const NONE: Option<&'static TreeModel> = None;
113}
114
115/// Trait containing all [`struct@TreeModel`] methods.
116///
117/// # Implementors
118///
119/// [`ListStore`][struct@crate::ListStore], [`TreeModelFilter`][struct@crate::TreeModelFilter], [`TreeModelSort`][struct@crate::TreeModelSort], [`TreeModel`][struct@crate::TreeModel], [`TreeSortable`][struct@crate::TreeSortable], [`TreeStore`][struct@crate::TreeStore]
120pub trait TreeModelExt: IsA<TreeModel> + 'static {
121 /// Calls func on each node in model in a depth-first fashion.
122 ///
123 /// If `func` returns [`true`], then the tree ceases to be walked,
124 /// and [`foreach()`][Self::foreach()] returns.
125 /// ## `func`
126 /// a function to be called on each row
127 #[doc(alias = "gtk_tree_model_foreach")]
128 fn foreach<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(&self, func: P) {
129 let mut func_data: P = func;
130 unsafe extern "C" fn func_func<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(
131 model: *mut ffi::GtkTreeModel,
132 path: *mut ffi::GtkTreePath,
133 iter: *mut ffi::GtkTreeIter,
134 data: glib::ffi::gpointer,
135 ) -> glib::ffi::gboolean {
136 unsafe {
137 let model = from_glib_borrow(model);
138 let path = from_glib_borrow(path);
139 let iter = from_glib_borrow(iter);
140 let callback = data as *mut P;
141 (*callback)(&model, &path, &iter).into_glib()
142 }
143 }
144 let func = Some(func_func::<P> as _);
145 let super_callback0: &mut P = &mut func_data;
146 unsafe {
147 ffi::gtk_tree_model_foreach(
148 self.as_ref().to_glib_none().0,
149 func,
150 super_callback0 as *mut _ as *mut _,
151 );
152 }
153 }
154
155 //#[doc(alias = "gtk_tree_model_get")]
156 //fn get(&self, iter: &TreeIter, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
157 // unsafe { TODO: call ffi:gtk_tree_model_get() }
158 //}
159
160 /// Returns the type of the column.
161 /// ## `index_`
162 /// the column index
163 ///
164 /// # Returns
165 ///
166 /// the type of the column
167 #[doc(alias = "gtk_tree_model_get_column_type")]
168 #[doc(alias = "get_column_type")]
169 fn column_type(&self, index_: i32) -> glib::types::Type {
170 unsafe {
171 from_glib(ffi::gtk_tree_model_get_column_type(
172 self.as_ref().to_glib_none().0,
173 index_,
174 ))
175 }
176 }
177
178 /// Returns a set of flags supported by this interface.
179 ///
180 /// The flags are a bitwise combination of [`TreeModelFlags`][crate::TreeModelFlags].
181 /// The flags supported should not change during the lifetime
182 /// of the `self`.
183 ///
184 /// # Returns
185 ///
186 /// the flags supported by this interface
187 #[doc(alias = "gtk_tree_model_get_flags")]
188 #[doc(alias = "get_flags")]
189 fn flags(&self) -> TreeModelFlags {
190 unsafe {
191 from_glib(ffi::gtk_tree_model_get_flags(
192 self.as_ref().to_glib_none().0,
193 ))
194 }
195 }
196
197 /// Sets `iter` to a valid iterator pointing to `path`. If `path` does
198 /// not exist, `iter` is set to an invalid iterator and [`false`] is returned.
199 /// ## `path`
200 /// the [`TreePath`][crate::TreePath]-struct
201 ///
202 /// # Returns
203 ///
204 /// [`true`], if `iter` was set
205 ///
206 /// ## `iter`
207 /// the uninitialized [`TreeIter`][crate::TreeIter]-struct
208 #[doc(alias = "gtk_tree_model_get_iter")]
209 #[doc(alias = "get_iter")]
210 fn iter(&self, path: &TreePath) -> Option<TreeIter> {
211 unsafe {
212 let mut iter = TreeIter::uninitialized();
213 let ret = from_glib(ffi::gtk_tree_model_get_iter(
214 self.as_ref().to_glib_none().0,
215 iter.to_glib_none_mut().0,
216 mut_override(path.to_glib_none().0),
217 ));
218 if ret { Some(iter) } else { None }
219 }
220 }
221
222 /// Initializes `iter` with the first iterator in the tree
223 /// (the one at the path "0") and returns [`true`]. Returns
224 /// [`false`] if the tree is empty.
225 ///
226 /// # Returns
227 ///
228 /// [`true`], if `iter` was set
229 ///
230 /// ## `iter`
231 /// the uninitialized [`TreeIter`][crate::TreeIter]-struct
232 #[doc(alias = "gtk_tree_model_get_iter_first")]
233 #[doc(alias = "get_iter_first")]
234 fn iter_first(&self) -> Option<TreeIter> {
235 unsafe {
236 let mut iter = TreeIter::uninitialized();
237 let ret = from_glib(ffi::gtk_tree_model_get_iter_first(
238 self.as_ref().to_glib_none().0,
239 iter.to_glib_none_mut().0,
240 ));
241 if ret { Some(iter) } else { None }
242 }
243 }
244
245 /// Sets `iter` to a valid iterator pointing to `path_string`, if it
246 /// exists. Otherwise, `iter` is left invalid and [`false`] is returned.
247 /// ## `path_string`
248 /// a string representation of a [`TreePath`][crate::TreePath]-struct
249 ///
250 /// # Returns
251 ///
252 /// [`true`], if `iter` was set
253 ///
254 /// ## `iter`
255 /// an uninitialized [`TreeIter`][crate::TreeIter]-struct
256 #[doc(alias = "gtk_tree_model_get_iter_from_string")]
257 #[doc(alias = "get_iter_from_string")]
258 fn iter_from_string(&self, path_string: &str) -> Option<TreeIter> {
259 unsafe {
260 let mut iter = TreeIter::uninitialized();
261 let ret = from_glib(ffi::gtk_tree_model_get_iter_from_string(
262 self.as_ref().to_glib_none().0,
263 iter.to_glib_none_mut().0,
264 path_string.to_glib_none().0,
265 ));
266 if ret { Some(iter) } else { None }
267 }
268 }
269
270 /// Returns the number of columns supported by `self`.
271 ///
272 /// # Returns
273 ///
274 /// the number of columns
275 #[doc(alias = "gtk_tree_model_get_n_columns")]
276 #[doc(alias = "get_n_columns")]
277 fn n_columns(&self) -> i32 {
278 unsafe { ffi::gtk_tree_model_get_n_columns(self.as_ref().to_glib_none().0) }
279 }
280
281 /// Returns a newly-created [`TreePath`][crate::TreePath]-struct referenced by `iter`.
282 ///
283 /// This path should be freed with `gtk_tree_path_free()`.
284 /// ## `iter`
285 /// the [`TreeIter`][crate::TreeIter]-struct
286 ///
287 /// # Returns
288 ///
289 /// a newly-created [`TreePath`][crate::TreePath]-struct
290 #[doc(alias = "gtk_tree_model_get_path")]
291 #[doc(alias = "get_path")]
292 fn path(&self, iter: &TreeIter) -> Option<TreePath> {
293 unsafe {
294 from_glib_full(ffi::gtk_tree_model_get_path(
295 self.as_ref().to_glib_none().0,
296 mut_override(iter.to_glib_none().0),
297 ))
298 }
299 }
300
301 /// Generates a string representation of the iter.
302 ///
303 /// This string is a “:” separated list of numbers.
304 /// For example, “4:10:0:3” would be an acceptable
305 /// return value for this string.
306 /// ## `iter`
307 /// a [`TreeIter`][crate::TreeIter]-struct
308 ///
309 /// # Returns
310 ///
311 /// a newly-allocated string.
312 /// Must be freed with `g_free()`.
313 #[doc(alias = "gtk_tree_model_get_string_from_iter")]
314 #[doc(alias = "get_string_from_iter")]
315 fn string_from_iter(&self, iter: &TreeIter) -> Option<glib::GString> {
316 unsafe {
317 from_glib_full(ffi::gtk_tree_model_get_string_from_iter(
318 self.as_ref().to_glib_none().0,
319 mut_override(iter.to_glib_none().0),
320 ))
321 }
322 }
323
324 //#[doc(alias = "gtk_tree_model_get_valist")]
325 //#[doc(alias = "get_valist")]
326 //fn valist(&self, iter: &TreeIter, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
327 // unsafe { TODO: call ffi:gtk_tree_model_get_valist() }
328 //}
329
330 /// Initializes and sets `value` to that at `column`.
331 ///
332 /// When done with `value`, [`glib::Value::unset()`][crate::glib::Value::unset()] needs to be called
333 /// to free any allocated memory.
334 /// ## `iter`
335 /// the [`TreeIter`][crate::TreeIter]-struct
336 /// ## `column`
337 /// the column to lookup the value at
338 ///
339 /// # Returns
340 ///
341 ///
342 /// ## `value`
343 /// an empty [`glib::Value`][crate::glib::Value] to set
344 #[doc(alias = "gtk_tree_model_get_value")]
345 #[doc(alias = "get_value")]
346 fn value(&self, iter: &TreeIter, column: i32) -> glib::Value {
347 unsafe {
348 let mut value = glib::Value::uninitialized();
349 ffi::gtk_tree_model_get_value(
350 self.as_ref().to_glib_none().0,
351 mut_override(iter.to_glib_none().0),
352 column,
353 value.to_glib_none_mut().0,
354 );
355 value
356 }
357 }
358
359 /// Sets `iter` to point to the first child of `parent`.
360 ///
361 /// If `parent` has no children, [`false`] is returned and `iter` is
362 /// set to be invalid. `parent` will remain a valid node after this
363 /// function has been called.
364 ///
365 /// If `parent` is [`None`] returns the first node, equivalent to
366 /// `gtk_tree_model_get_iter_first (tree_model, iter);`
367 /// ## `parent`
368 /// the [`TreeIter`][crate::TreeIter]-struct, or [`None`]
369 ///
370 /// # Returns
371 ///
372 /// [`true`], if `iter` has been set to the first child
373 ///
374 /// ## `iter`
375 /// the new [`TreeIter`][crate::TreeIter]-struct to be set to the child
376 #[doc(alias = "gtk_tree_model_iter_children")]
377 fn iter_children(&self, parent: Option<&TreeIter>) -> Option<TreeIter> {
378 unsafe {
379 let mut iter = TreeIter::uninitialized();
380 let ret = from_glib(ffi::gtk_tree_model_iter_children(
381 self.as_ref().to_glib_none().0,
382 iter.to_glib_none_mut().0,
383 mut_override(parent.to_glib_none().0),
384 ));
385 if ret { Some(iter) } else { None }
386 }
387 }
388
389 /// Returns [`true`] if `iter` has children, [`false`] otherwise.
390 /// ## `iter`
391 /// the [`TreeIter`][crate::TreeIter]-struct to test for children
392 ///
393 /// # Returns
394 ///
395 /// [`true`] if `iter` has children
396 #[doc(alias = "gtk_tree_model_iter_has_child")]
397 fn iter_has_child(&self, iter: &TreeIter) -> bool {
398 unsafe {
399 from_glib(ffi::gtk_tree_model_iter_has_child(
400 self.as_ref().to_glib_none().0,
401 mut_override(iter.to_glib_none().0),
402 ))
403 }
404 }
405
406 /// Returns the number of children that `iter` has.
407 ///
408 /// As a special case, if `iter` is [`None`], then the number
409 /// of toplevel nodes is returned.
410 /// ## `iter`
411 /// the [`TreeIter`][crate::TreeIter]-struct, or [`None`]
412 ///
413 /// # Returns
414 ///
415 /// the number of children of `iter`
416 #[doc(alias = "gtk_tree_model_iter_n_children")]
417 fn iter_n_children(&self, iter: Option<&TreeIter>) -> i32 {
418 unsafe {
419 ffi::gtk_tree_model_iter_n_children(
420 self.as_ref().to_glib_none().0,
421 mut_override(iter.to_glib_none().0),
422 )
423 }
424 }
425
426 /// Sets `iter` to point to the node following it at the current level.
427 ///
428 /// If there is no next `iter`, [`false`] is returned and `iter` is set
429 /// to be invalid.
430 /// ## `iter`
431 /// the [`TreeIter`][crate::TreeIter]-struct
432 ///
433 /// # Returns
434 ///
435 /// [`true`] if `iter` has been changed to the next node
436 #[doc(alias = "gtk_tree_model_iter_next")]
437 fn iter_next(&self, iter: &TreeIter) -> bool {
438 unsafe {
439 from_glib(ffi::gtk_tree_model_iter_next(
440 self.as_ref().to_glib_none().0,
441 mut_override(iter.to_glib_none().0),
442 ))
443 }
444 }
445
446 /// Sets `iter` to be the child of `parent`, using the given index.
447 ///
448 /// The first index is 0. If `n` is too big, or `parent` has no children,
449 /// `iter` is set to an invalid iterator and [`false`] is returned. `parent`
450 /// will remain a valid node after this function has been called. As a
451 /// special case, if `parent` is [`None`], then the `n`-th root node
452 /// is set.
453 /// ## `parent`
454 /// the [`TreeIter`][crate::TreeIter]-struct to get the child from, or [`None`].
455 /// ## `n`
456 /// the index of the desired child
457 ///
458 /// # Returns
459 ///
460 /// [`true`], if `parent` has an `n`-th child
461 ///
462 /// ## `iter`
463 /// the [`TreeIter`][crate::TreeIter]-struct to set to the nth child
464 #[doc(alias = "gtk_tree_model_iter_nth_child")]
465 fn iter_nth_child(&self, parent: Option<&TreeIter>, n: i32) -> Option<TreeIter> {
466 unsafe {
467 let mut iter = TreeIter::uninitialized();
468 let ret = from_glib(ffi::gtk_tree_model_iter_nth_child(
469 self.as_ref().to_glib_none().0,
470 iter.to_glib_none_mut().0,
471 mut_override(parent.to_glib_none().0),
472 n,
473 ));
474 if ret { Some(iter) } else { None }
475 }
476 }
477
478 /// Sets `iter` to be the parent of `child`.
479 ///
480 /// If `child` is at the toplevel, and doesn’t have a parent, then
481 /// `iter` is set to an invalid iterator and [`false`] is returned.
482 /// `child` will remain a valid node after this function has been
483 /// called.
484 ///
485 /// `iter` will be initialized before the lookup is performed, so `child`
486 /// and `iter` cannot point to the same memory location.
487 /// ## `child`
488 /// the [`TreeIter`][crate::TreeIter]-struct
489 ///
490 /// # Returns
491 ///
492 /// [`true`], if `iter` is set to the parent of `child`
493 ///
494 /// ## `iter`
495 /// the new [`TreeIter`][crate::TreeIter]-struct to set to the parent
496 #[doc(alias = "gtk_tree_model_iter_parent")]
497 fn iter_parent(&self, child: &TreeIter) -> Option<TreeIter> {
498 unsafe {
499 let mut iter = TreeIter::uninitialized();
500 let ret = from_glib(ffi::gtk_tree_model_iter_parent(
501 self.as_ref().to_glib_none().0,
502 iter.to_glib_none_mut().0,
503 mut_override(child.to_glib_none().0),
504 ));
505 if ret { Some(iter) } else { None }
506 }
507 }
508
509 /// Sets `iter` to point to the previous node at the current level.
510 ///
511 /// If there is no previous `iter`, [`false`] is returned and `iter` is
512 /// set to be invalid.
513 /// ## `iter`
514 /// the [`TreeIter`][crate::TreeIter]-struct
515 ///
516 /// # Returns
517 ///
518 /// [`true`] if `iter` has been changed to the previous node
519 #[doc(alias = "gtk_tree_model_iter_previous")]
520 fn iter_previous(&self, iter: &TreeIter) -> bool {
521 unsafe {
522 from_glib(ffi::gtk_tree_model_iter_previous(
523 self.as_ref().to_glib_none().0,
524 mut_override(iter.to_glib_none().0),
525 ))
526 }
527 }
528
529 /// Emits the [`row-changed`][struct@crate::TreeModel#row-changed] signal on `self`.
530 /// ## `path`
531 /// a [`TreePath`][crate::TreePath]-struct pointing to the changed row
532 /// ## `iter`
533 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the changed row
534 #[doc(alias = "gtk_tree_model_row_changed")]
535 fn row_changed(&self, path: &TreePath, iter: &TreeIter) {
536 unsafe {
537 ffi::gtk_tree_model_row_changed(
538 self.as_ref().to_glib_none().0,
539 mut_override(path.to_glib_none().0),
540 mut_override(iter.to_glib_none().0),
541 );
542 }
543 }
544
545 /// Emits the [`row-deleted`][struct@crate::TreeModel#row-deleted] signal on `self`.
546 ///
547 /// This should be called by models after a row has been removed.
548 /// The location pointed to by `path` should be the location that
549 /// the row previously was at. It may not be a valid location anymore.
550 ///
551 /// Nodes that are deleted are not unreffed, this means that any
552 /// outstanding references on the deleted node should not be released.
553 /// ## `path`
554 /// a [`TreePath`][crate::TreePath]-struct pointing to the previous location of
555 /// the deleted row
556 #[doc(alias = "gtk_tree_model_row_deleted")]
557 fn row_deleted(&self, path: &TreePath) {
558 unsafe {
559 ffi::gtk_tree_model_row_deleted(
560 self.as_ref().to_glib_none().0,
561 mut_override(path.to_glib_none().0),
562 );
563 }
564 }
565
566 /// Emits the [`row-has-child-toggled`][struct@crate::TreeModel#row-has-child-toggled] signal on
567 /// `self`. This should be called by models after the child
568 /// state of a node changes.
569 /// ## `path`
570 /// a [`TreePath`][crate::TreePath]-struct pointing to the changed row
571 /// ## `iter`
572 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the changed row
573 #[doc(alias = "gtk_tree_model_row_has_child_toggled")]
574 fn row_has_child_toggled(&self, path: &TreePath, iter: &TreeIter) {
575 unsafe {
576 ffi::gtk_tree_model_row_has_child_toggled(
577 self.as_ref().to_glib_none().0,
578 mut_override(path.to_glib_none().0),
579 mut_override(iter.to_glib_none().0),
580 );
581 }
582 }
583
584 /// Emits the [`row-inserted`][struct@crate::TreeModel#row-inserted] signal on `self`.
585 /// ## `path`
586 /// a [`TreePath`][crate::TreePath]-struct pointing to the inserted row
587 /// ## `iter`
588 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the inserted row
589 #[doc(alias = "gtk_tree_model_row_inserted")]
590 fn row_inserted(&self, path: &TreePath, iter: &TreeIter) {
591 unsafe {
592 ffi::gtk_tree_model_row_inserted(
593 self.as_ref().to_glib_none().0,
594 mut_override(path.to_glib_none().0),
595 mut_override(iter.to_glib_none().0),
596 );
597 }
598 }
599
600 /// Emits the [`rows-reordered`][struct@crate::TreeModel#rows-reordered] signal on `self`.
601 ///
602 /// This should be called by models when their rows have been
603 /// reordered.
604 /// ## `path`
605 /// a [`TreePath`][crate::TreePath]-struct pointing to the tree node whose children
606 /// have been reordered
607 /// ## `iter`
608 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the node
609 /// whose children have been reordered, or [`None`] if the depth
610 /// of `path` is 0
611 /// ## `new_order`
612 /// an array of integers
613 /// mapping the current position of each child to its old
614 /// position before the re-ordering,
615 /// i.e. `new_order``[newpos] = oldpos`
616 #[doc(alias = "gtk_tree_model_rows_reordered_with_length")]
617 fn rows_reordered_with_length(
618 &self,
619 path: &TreePath,
620 iter: Option<&TreeIter>,
621 new_order: &[i32],
622 ) {
623 let length = new_order.len() as _;
624 unsafe {
625 ffi::gtk_tree_model_rows_reordered_with_length(
626 self.as_ref().to_glib_none().0,
627 mut_override(path.to_glib_none().0),
628 mut_override(iter.to_glib_none().0),
629 new_order.to_glib_none().0,
630 length,
631 );
632 }
633 }
634
635 /// This signal is emitted when a row in the model has changed.
636 /// ## `path`
637 /// a [`TreePath`][crate::TreePath]-struct identifying the changed row
638 /// ## `iter`
639 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the changed row
640 #[doc(alias = "row-changed")]
641 fn connect_row_changed<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
642 &self,
643 f: F,
644 ) -> SignalHandlerId {
645 unsafe extern "C" fn row_changed_trampoline<
646 P: IsA<TreeModel>,
647 F: Fn(&P, &TreePath, &TreeIter) + 'static,
648 >(
649 this: *mut ffi::GtkTreeModel,
650 path: *mut ffi::GtkTreePath,
651 iter: *mut ffi::GtkTreeIter,
652 f: glib::ffi::gpointer,
653 ) {
654 unsafe {
655 let f: &F = &*(f as *const F);
656 f(
657 TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
658 &from_glib_borrow(path),
659 &from_glib_borrow(iter),
660 )
661 }
662 }
663 unsafe {
664 let f: Box_<F> = Box_::new(f);
665 connect_raw(
666 self.as_ptr() as *mut _,
667 c"row-changed".as_ptr(),
668 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
669 row_changed_trampoline::<Self, F> as *const (),
670 )),
671 Box_::into_raw(f),
672 )
673 }
674 }
675
676 /// This signal is emitted when a row has been deleted.
677 ///
678 /// Note that no iterator is passed to the signal handler,
679 /// since the row is already deleted.
680 ///
681 /// This should be called by models after a row has been removed.
682 /// The location pointed to by `path` should be the location that
683 /// the row previously was at. It may not be a valid location anymore.
684 /// ## `path`
685 /// a [`TreePath`][crate::TreePath]-struct identifying the row
686 #[doc(alias = "row-deleted")]
687 fn connect_row_deleted<F: Fn(&Self, &TreePath) + 'static>(&self, f: F) -> SignalHandlerId {
688 unsafe extern "C" fn row_deleted_trampoline<
689 P: IsA<TreeModel>,
690 F: Fn(&P, &TreePath) + 'static,
691 >(
692 this: *mut ffi::GtkTreeModel,
693 path: *mut ffi::GtkTreePath,
694 f: glib::ffi::gpointer,
695 ) {
696 unsafe {
697 let f: &F = &*(f as *const F);
698 f(
699 TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
700 &from_glib_borrow(path),
701 )
702 }
703 }
704 unsafe {
705 let f: Box_<F> = Box_::new(f);
706 connect_raw(
707 self.as_ptr() as *mut _,
708 c"row-deleted".as_ptr(),
709 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
710 row_deleted_trampoline::<Self, F> as *const (),
711 )),
712 Box_::into_raw(f),
713 )
714 }
715 }
716
717 /// This signal is emitted when a row has gotten the first child
718 /// row or lost its last child row.
719 /// ## `path`
720 /// a [`TreePath`][crate::TreePath]-struct identifying the row
721 /// ## `iter`
722 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the row
723 #[doc(alias = "row-has-child-toggled")]
724 fn connect_row_has_child_toggled<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
725 &self,
726 f: F,
727 ) -> SignalHandlerId {
728 unsafe extern "C" fn row_has_child_toggled_trampoline<
729 P: IsA<TreeModel>,
730 F: Fn(&P, &TreePath, &TreeIter) + 'static,
731 >(
732 this: *mut ffi::GtkTreeModel,
733 path: *mut ffi::GtkTreePath,
734 iter: *mut ffi::GtkTreeIter,
735 f: glib::ffi::gpointer,
736 ) {
737 unsafe {
738 let f: &F = &*(f as *const F);
739 f(
740 TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
741 &from_glib_borrow(path),
742 &from_glib_borrow(iter),
743 )
744 }
745 }
746 unsafe {
747 let f: Box_<F> = Box_::new(f);
748 connect_raw(
749 self.as_ptr() as *mut _,
750 c"row-has-child-toggled".as_ptr(),
751 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
752 row_has_child_toggled_trampoline::<Self, F> as *const (),
753 )),
754 Box_::into_raw(f),
755 )
756 }
757 }
758
759 /// This signal is emitted when a new row has been inserted in
760 /// the model.
761 ///
762 /// Note that the row may still be empty at this point, since
763 /// it is a common pattern to first insert an empty row, and
764 /// then fill it with the desired values.
765 /// ## `path`
766 /// a [`TreePath`][crate::TreePath]-struct identifying the new row
767 /// ## `iter`
768 /// a valid [`TreeIter`][crate::TreeIter]-struct pointing to the new row
769 #[doc(alias = "row-inserted")]
770 fn connect_row_inserted<F: Fn(&Self, &TreePath, &TreeIter) + 'static>(
771 &self,
772 f: F,
773 ) -> SignalHandlerId {
774 unsafe extern "C" fn row_inserted_trampoline<
775 P: IsA<TreeModel>,
776 F: Fn(&P, &TreePath, &TreeIter) + 'static,
777 >(
778 this: *mut ffi::GtkTreeModel,
779 path: *mut ffi::GtkTreePath,
780 iter: *mut ffi::GtkTreeIter,
781 f: glib::ffi::gpointer,
782 ) {
783 unsafe {
784 let f: &F = &*(f as *const F);
785 f(
786 TreeModel::from_glib_borrow(this).unsafe_cast_ref(),
787 &from_glib_borrow(path),
788 &from_glib_borrow(iter),
789 )
790 }
791 }
792 unsafe {
793 let f: Box_<F> = Box_::new(f);
794 connect_raw(
795 self.as_ptr() as *mut _,
796 c"row-inserted".as_ptr(),
797 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
798 row_inserted_trampoline::<Self, F> as *const (),
799 )),
800 Box_::into_raw(f),
801 )
802 }
803 }
804
805 //#[doc(alias = "rows-reordered")]
806 //fn connect_rows_reordered<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
807 // Unimplemented new_order: *.Pointer
808 //}
809}
810
811impl<O: IsA<TreeModel>> TreeModelExt for O {}