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 /// Marks a spot in a [`TextBuffer`][crate::TextBuffer] where child widgets can be “anchored”.
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 /// Determines whether a child anchor has been deleted from
80 /// the buffer.
81 ///
82 /// Keep in mind that the child anchor will be unreferenced
83 /// when removed from the buffer, so you need to hold your own
84 /// reference (with g_object_ref()) if you plan to use this
85 /// function — otherwise all deleted child anchors will also
86 /// be finalized.
87 ///
88 /// # Returns
89 ///
90 /// [`true`] if the child anchor has been deleted from its buffer
91 #[doc(alias = "gtk_text_child_anchor_get_deleted")]
92 #[doc(alias = "get_deleted")]
93 fn is_deleted(&self) -> bool {
94 unsafe {
95 from_glib(ffi::gtk_text_child_anchor_get_deleted(
96 self.as_ref().to_glib_none().0,
97 ))
98 }
99 }
100
101 /// Gets a list of all widgets anchored at this child anchor.
102 ///
103 /// The order in which the widgets are returned is not defined.
104 ///
105 /// # Returns
106 ///
107 /// an
108 /// array of widgets anchored at @self
109 #[doc(alias = "gtk_text_child_anchor_get_widgets")]
110 #[doc(alias = "get_widgets")]
111 fn widgets(&self) -> Vec<Widget> {
112 unsafe {
113 let mut out_len = std::mem::MaybeUninit::uninit();
114 let ret = FromGlibContainer::from_glib_container_num(
115 ffi::gtk_text_child_anchor_get_widgets(
116 self.as_ref().to_glib_none().0,
117 out_len.as_mut_ptr(),
118 ),
119 out_len.assume_init() as _,
120 );
121 ret
122 }
123 }
124}
125
126impl<O: IsA<TextChildAnchor>> TextChildAnchorExt for O {}