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