Skip to main content

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