gsk4/auto/
paste_node.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::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node for a paste.
10    #[doc(alias = "GskPasteNode")]
11    pub struct PasteNode(Shared<ffi::GskPasteNode>);
12
13    match fn {
14        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
15        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
16    }
17}
18
19impl StaticType for PasteNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_paste_node_get_type()) }
22    }
23}
24
25impl PasteNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will paste copied contents.
27    /// ## `bounds`
28    /// the rectangle to render the paste into
29    /// ## `depth`
30    /// the index of which copy to paste. This will usually be 0.
31    ///
32    /// # Returns
33    ///
34    /// A new [`RenderNode`][crate::RenderNode]
35    #[doc(alias = "gsk_paste_node_new")]
36    pub fn new(bounds: &graphene::Rect, depth: usize) -> PasteNode {
37        assert_initialized_main_thread!();
38        unsafe { from_glib_full(ffi::gsk_paste_node_new(bounds.to_glib_none().0, depth)) }
39    }
40
41    /// Retrieves the index of the copy that should be pasted.
42    ///
43    /// # Returns
44    ///
45    /// the index of the copy to paste.
46    #[doc(alias = "gsk_paste_node_get_depth")]
47    #[doc(alias = "get_depth")]
48    pub fn depth(&self) -> usize {
49        unsafe { ffi::gsk_paste_node_get_depth(self.to_glib_none().0) }
50    }
51}