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, 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    /// target gives
54    /// the required type of the data. Should robustly handle a `path` no
55    /// longer found in the model!
56    /// ## `path`
57    /// row that was dragged
58    /// ## `selection_data`
59    /// a [`SelectionData`][crate::SelectionData] to fill with data
60    ///  from the dragged row
61    ///
62    /// # Returns
63    ///
64    /// [`true`] if data of the required type was provided
65    #[doc(alias = "gtk_tree_drag_source_drag_data_get")]
66    fn drag_data_get(&self, path: &mut TreePath, selection_data: &mut SelectionData) -> bool {
67        unsafe {
68            from_glib(ffi::gtk_tree_drag_source_drag_data_get(
69                self.as_ref().to_glib_none().0,
70                path.to_glib_none_mut().0,
71                selection_data.to_glib_none_mut().0,
72            ))
73        }
74    }
75
76    /// Asks the [`TreeDragSource`][crate::TreeDragSource] whether a particular row can be used as
77    /// the source of a DND operation. If the source doesn’t implement
78    /// this interface, the row is assumed draggable.
79    /// ## `path`
80    /// row on which user is initiating a drag
81    ///
82    /// # Returns
83    ///
84    /// [`true`] if the row can be dragged
85    #[doc(alias = "gtk_tree_drag_source_row_draggable")]
86    fn row_draggable(&self, path: &mut TreePath) -> bool {
87        unsafe {
88            from_glib(ffi::gtk_tree_drag_source_row_draggable(
89                self.as_ref().to_glib_none().0,
90                path.to_glib_none_mut().0,
91            ))
92        }
93    }
94}
95
96impl<O: IsA<TreeDragSource>> TreeDragSourceExt for O {}