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