gtk/auto/tree_drag_source.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::{SelectionData, TreePath, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 ///
10 ///
11 /// # Implements
12 ///
13 /// [`TreeDragSourceExt`][trait@crate::prelude::TreeDragSourceExt]
14 #[doc(alias = "GtkTreeDragSource")]
15 pub struct TreeDragSource(Interface<ffi::GtkTreeDragSource, ffi::GtkTreeDragSourceIface>);
16
17 match fn {
18 type_ => || ffi::gtk_tree_drag_source_get_type(),
19 }
20}
21
22impl TreeDragSource {
23 pub const NONE: Option<&'static TreeDragSource> = None;
24}
25
26/// Trait containing all [`struct@TreeDragSource`] methods.
27///
28/// # Implementors
29///
30/// [`ListStore`][struct@crate::ListStore], [`TreeDragSource`][struct@crate::TreeDragSource], [`TreeModelFilter`][struct@crate::TreeModelFilter], [`TreeModelSort`][struct@crate::TreeModelSort], [`TreeStore`][struct@crate::TreeStore]
31pub trait TreeDragSourceExt: IsA<TreeDragSource> + 'static {
32 /// Asks the [`TreeDragSource`][crate::TreeDragSource] to delete the row at `path`, because
33 /// it was moved somewhere else via drag-and-drop. Returns [`false`]
34 /// if the deletion fails because `path` no longer exists, or for
35 /// some model-specific reason. Should robustly handle a `path` no
36 /// longer found in the model!
37 /// ## `path`
38 /// row that was being dragged
39 ///
40 /// # Returns
41 ///
42 /// [`true`] if the row was successfully deleted
43 #[doc(alias = "gtk_tree_drag_source_drag_data_delete")]
44 fn drag_data_delete(&self, path: &mut TreePath) -> bool {
45 unsafe {
46 from_glib(ffi::gtk_tree_drag_source_drag_data_delete(
47 self.as_ref().to_glib_none().0,
48 path.to_glib_none_mut().0,
49 ))
50 }
51 }
52
53 /// Asks the [`TreeDragSource`][crate::TreeDragSource] to fill in `selection_data` with a
54 /// representation of the row at `path`. `selection_data`->target gives
55 /// the required type of the data. Should robustly handle a `path` no
56 /// longer found in the model!
57 /// ## `path`
58 /// row that was dragged
59 /// ## `selection_data`
60 /// a [`SelectionData`][crate::SelectionData] to fill with data
61 /// from the dragged row
62 ///
63 /// # Returns
64 ///
65 /// [`true`] if data of the required type was provided
66 #[doc(alias = "gtk_tree_drag_source_drag_data_get")]
67 fn drag_data_get(&self, path: &mut TreePath, selection_data: &mut SelectionData) -> bool {
68 unsafe {
69 from_glib(ffi::gtk_tree_drag_source_drag_data_get(
70 self.as_ref().to_glib_none().0,
71 path.to_glib_none_mut().0,
72 selection_data.to_glib_none_mut().0,
73 ))
74 }
75 }
76
77 /// Asks the [`TreeDragSource`][crate::TreeDragSource] whether a particular row can be used as
78 /// the source of a DND operation. If the source doesn’t implement
79 /// this interface, the row is assumed draggable.
80 /// ## `path`
81 /// row on which user is initiating a drag
82 ///
83 /// # Returns
84 ///
85 /// [`true`] if the row can be dragged
86 #[doc(alias = "gtk_tree_drag_source_row_draggable")]
87 fn row_draggable(&self, path: &mut TreePath) -> bool {
88 unsafe {
89 from_glib(ffi::gtk_tree_drag_source_row_draggable(
90 self.as_ref().to_glib_none().0,
91 path.to_glib_none_mut().0,
92 ))
93 }
94 }
95}
96
97impl<O: IsA<TreeDragSource>> TreeDragSourceExt for O {}