gtk/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;
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10 /// A [`TextChildAnchor`][crate::TextChildAnchor] is a spot in the buffer where child widgets can
11 /// be “anchored” (inserted inline, as if they were characters). The anchor
12 /// 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]. Usually you would then insert
29 /// it into a [`TextBuffer`][crate::TextBuffer] with [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()].
30 /// To perform the creation and insertion in one step, use the
31 /// convenience function [`TextBufferExt::create_child_anchor()`][crate::prelude::TextBufferExt::create_child_anchor()].
32 ///
33 /// # Returns
34 ///
35 /// a new [`TextChildAnchor`][crate::TextChildAnchor]
36 #[doc(alias = "gtk_text_child_anchor_new")]
37 pub fn new() -> TextChildAnchor {
38 assert_initialized_main_thread!();
39 unsafe { from_glib_full(ffi::gtk_text_child_anchor_new()) }
40 }
41}
42
43impl Default for TextChildAnchor {
44 fn default() -> Self {
45 Self::new()
46 }
47}
48
49mod sealed {
50 pub trait Sealed {}
51 impl<T: super::IsA<super::TextChildAnchor>> Sealed for T {}
52}
53
54/// Trait containing all [`struct@TextChildAnchor`] methods.
55///
56/// # Implementors
57///
58/// [`TextChildAnchor`][struct@crate::TextChildAnchor]
59pub trait TextChildAnchorExt: IsA<TextChildAnchor> + sealed::Sealed + 'static {
60 /// Determines whether a child anchor has been deleted from
61 /// the buffer. Keep in mind that the child anchor will be
62 /// unreferenced when removed from the buffer, so you need to
63 /// hold your own reference (with `g_object_ref()`) if you plan
64 /// to use this function — otherwise all deleted child anchors
65 /// will also be finalized.
66 ///
67 /// # Returns
68 ///
69 /// [`true`] if the child anchor has been deleted from its buffer
70 #[doc(alias = "gtk_text_child_anchor_get_deleted")]
71 #[doc(alias = "get_deleted")]
72 fn is_deleted(&self) -> bool {
73 unsafe {
74 from_glib(ffi::gtk_text_child_anchor_get_deleted(
75 self.as_ref().to_glib_none().0,
76 ))
77 }
78 }
79
80 /// Gets a list of all widgets anchored at this child anchor.
81 /// The returned list should be freed with `g_list_free()`.
82 ///
83 /// # Returns
84 ///
85 /// list of widgets anchored at `self`
86 #[doc(alias = "gtk_text_child_anchor_get_widgets")]
87 #[doc(alias = "get_widgets")]
88 fn widgets(&self) -> Vec<Widget> {
89 unsafe {
90 FromGlibPtrContainer::from_glib_container(ffi::gtk_text_child_anchor_get_widgets(
91 self.as_ref().to_glib_none().0,
92 ))
93 }
94 }
95}
96
97impl<O: IsA<TextChildAnchor>> TextChildAnchorExt for O {}
98
99impl fmt::Display for TextChildAnchor {
100 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
101 f.write_str("TextChildAnchor")
102 }
103}