gtk4/auto/
text_child_anchor.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, Widget};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// A [`TextChildAnchor`][crate::TextChildAnchor] is a spot in a [`TextBuffer`][crate::TextBuffer] where child widgets can
    /// be “anchored”.
    ///
    /// The anchor can have multiple widgets anchored, to allow for multiple views.
    ///
    /// # Implements
    ///
    /// [`TextChildAnchorExt`][trait@crate::prelude::TextChildAnchorExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkTextChildAnchor")]
    pub struct TextChildAnchor(Object<ffi::GtkTextChildAnchor, ffi::GtkTextChildAnchorClass>);

    match fn {
        type_ => || ffi::gtk_text_child_anchor_get_type(),
    }
}

impl TextChildAnchor {
    pub const NONE: Option<&'static TextChildAnchor> = None;

    /// Creates a new [`TextChildAnchor`][crate::TextChildAnchor].
    ///
    /// Usually you would then insert it into a [`TextBuffer`][crate::TextBuffer] with
    /// [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()]. To perform the
    /// creation and insertion in one step, use the convenience
    /// function [`TextBufferExt::create_child_anchor()`][crate::prelude::TextBufferExt::create_child_anchor()].
    ///
    /// # Returns
    ///
    /// a new [`TextChildAnchor`][crate::TextChildAnchor]
    #[doc(alias = "gtk_text_child_anchor_new")]
    pub fn new() -> TextChildAnchor {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_text_child_anchor_new()) }
    }

    /// Creates a new [`TextChildAnchor`][crate::TextChildAnchor] with the given replacement character.
    ///
    /// Usually you would then insert it into a [`TextBuffer`][crate::TextBuffer] with
    /// [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()].
    /// ## `character`
    /// a replacement character
    ///
    /// # Returns
    ///
    /// a new [`TextChildAnchor`][crate::TextChildAnchor]
    #[cfg(feature = "v4_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
    #[doc(alias = "gtk_text_child_anchor_new_with_replacement")]
    #[doc(alias = "new_with_replacement")]
    pub fn with_replacement(character: &str) -> TextChildAnchor {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_text_child_anchor_new_with_replacement(
                character.to_glib_none().0,
            ))
        }
    }
}

impl Default for TextChildAnchor {
    fn default() -> Self {
        Self::new()
    }
}

/// Trait containing all [`struct@TextChildAnchor`] methods.
///
/// # Implementors
///
/// [`TextChildAnchor`][struct@crate::TextChildAnchor]
pub trait TextChildAnchorExt: IsA<TextChildAnchor> + 'static {
    /// Determines whether a child anchor has been deleted from
    /// the buffer.
    ///
    /// Keep in mind that the child anchor will be unreferenced
    /// when removed from the buffer, so you need to hold your own
    /// reference (with g_object_ref()) if you plan to use this
    /// function — otherwise all deleted child anchors will also
    /// be finalized.
    ///
    /// # Returns
    ///
    /// [`true`] if the child anchor has been deleted from its buffer
    #[doc(alias = "gtk_text_child_anchor_get_deleted")]
    #[doc(alias = "get_deleted")]
    fn is_deleted(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_child_anchor_get_deleted(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets a list of all widgets anchored at this child anchor.
    ///
    /// The order in which the widgets are returned is not defined.
    ///
    /// # Returns
    ///
    /// an
    ///   array of widgets anchored at @self
    #[doc(alias = "gtk_text_child_anchor_get_widgets")]
    #[doc(alias = "get_widgets")]
    fn widgets(&self) -> Vec<Widget> {
        unsafe {
            let mut out_len = std::mem::MaybeUninit::uninit();
            let ret = FromGlibContainer::from_glib_container_num(
                ffi::gtk_text_child_anchor_get_widgets(
                    self.as_ref().to_glib_none().0,
                    out_len.as_mut_ptr(),
                ),
                out_len.assume_init() as _,
            );
            ret
        }
    }
}

impl<O: IsA<TextChildAnchor>> TextChildAnchorExt for O {}