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