Skip to main content

gtk4/auto/
text_child_anchor.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::{Widget, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// .
10    ///
11    /// The anchor can have multiple widgets anchored, to allow for multiple views.
12    ///
13    /// # Implements
14    ///
15    /// [`TextChildAnchorExt`][trait@crate::prelude::TextChildAnchorExt], [`trait@glib::ObjectExt`]
16    #[doc(alias = "GtkTextChildAnchor")]
17    pub struct TextChildAnchor(Object<ffi::GtkTextChildAnchor, ffi::GtkTextChildAnchorClass>);
18
19    match fn {
20        type_ => || ffi::gtk_text_child_anchor_get_type(),
21    }
22}
23
24impl TextChildAnchor {
25    pub const NONE: Option<&'static TextChildAnchor> = None;
26
27    /// Creates a new [`TextChildAnchor`][crate::TextChildAnchor].
28    ///
29    /// Usually you would then insert it into a [`TextBuffer`][crate::TextBuffer] with
30    /// [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()]. To perform the
31    /// creation and insertion in one step, use the convenience
32    /// function [`TextBufferExt::create_child_anchor()`][crate::prelude::TextBufferExt::create_child_anchor()].
33    ///
34    /// # Returns
35    ///
36    /// a new [`TextChildAnchor`][crate::TextChildAnchor]
37    #[doc(alias = "gtk_text_child_anchor_new")]
38    pub fn new() -> TextChildAnchor {
39        assert_initialized_main_thread!();
40        unsafe { from_glib_full(ffi::gtk_text_child_anchor_new()) }
41    }
42
43    /// Creates a new [`TextChildAnchor`][crate::TextChildAnchor] with the given replacement character.
44    ///
45    /// Usually you would then insert it into a [`TextBuffer`][crate::TextBuffer] with
46    /// [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()].
47    /// ## `character`
48    /// a replacement character
49    ///
50    /// # Returns
51    ///
52    /// a new [`TextChildAnchor`][crate::TextChildAnchor]
53    #[cfg(feature = "v4_6")]
54    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
55    #[doc(alias = "gtk_text_child_anchor_new_with_replacement")]
56    #[doc(alias = "new_with_replacement")]
57    pub fn with_replacement(character: &str) -> TextChildAnchor {
58        assert_initialized_main_thread!();
59        unsafe {
60            from_glib_full(ffi::gtk_text_child_anchor_new_with_replacement(
61                character.to_glib_none().0,
62            ))
63        }
64    }
65}
66
67impl Default for TextChildAnchor {
68    fn default() -> Self {
69        Self::new()
70    }
71}
72
73/// Trait containing all [`struct@TextChildAnchor`] methods.
74///
75/// # Implementors
76///
77/// [`TextChildAnchor`][struct@crate::TextChildAnchor]
78pub trait TextChildAnchorExt: IsA<TextChildAnchor> + 'static {
79    ///  otherwise all deleted child anchors will also
80    /// be finalized.
81    ///
82    /// # Returns
83    ///
84    /// [`true`] if the child anchor has been deleted from its buffer
85    #[doc(alias = "gtk_text_child_anchor_get_deleted")]
86    #[doc(alias = "get_deleted")]
87    fn is_deleted(&self) -> bool {
88        unsafe {
89            from_glib(ffi::gtk_text_child_anchor_get_deleted(
90                self.as_ref().to_glib_none().0,
91            ))
92        }
93    }
94
95    /// Gets a list of all widgets anchored at this child anchor.
96    ///
97    /// The order in which the widgets are returned is not defined.
98    ///
99    /// # Returns
100    ///
101    /// an
102    ///   array of widgets anchored at @self
103    #[doc(alias = "gtk_text_child_anchor_get_widgets")]
104    #[doc(alias = "get_widgets")]
105    fn widgets(&self) -> Vec<Widget> {
106        unsafe {
107            let mut out_len = std::mem::MaybeUninit::uninit();
108            let ret = FromGlibContainer::from_glib_container_num(
109                ffi::gtk_text_child_anchor_get_widgets(
110                    self.as_ref().to_glib_none().0,
111                    out_len.as_mut_ptr(),
112                ),
113                out_len.assume_init() as _,
114            );
115            ret
116        }
117    }
118}
119
120impl<O: IsA<TextChildAnchor>> TextChildAnchorExt for O {}