[go: up one dir, main page]

gtk4/auto/
text_mark.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, TextBuffer};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    #[doc(alias = "GtkTextMark")]
10    pub struct TextMark(Object<ffi::GtkTextMark, ffi::GtkTextMarkClass>);
11
12    match fn {
13        type_ => || ffi::gtk_text_mark_get_type(),
14    }
15}
16
17impl TextMark {
18    pub const NONE: Option<&'static TextMark> = None;
19
20    #[doc(alias = "gtk_text_mark_new")]
21    pub fn new(name: Option<&str>, left_gravity: bool) -> TextMark {
22        assert_initialized_main_thread!();
23        unsafe {
24            from_glib_full(ffi::gtk_text_mark_new(
25                name.to_glib_none().0,
26                left_gravity.into_glib(),
27            ))
28        }
29    }
30
31    // rustdoc-stripper-ignore-next
32    /// Creates a new builder-pattern struct instance to construct [`TextMark`] objects.
33    ///
34    /// This method returns an instance of [`TextMarkBuilder`](crate::builders::TextMarkBuilder) which can be used to create [`TextMark`] objects.
35    pub fn builder() -> TextMarkBuilder {
36        TextMarkBuilder::new()
37    }
38}
39
40impl Default for TextMark {
41    fn default() -> Self {
42        glib::object::Object::new::<Self>()
43    }
44}
45
46// rustdoc-stripper-ignore-next
47/// A [builder-pattern] type to construct [`TextMark`] objects.
48///
49/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
50#[must_use = "The builder must be built to be used"]
51pub struct TextMarkBuilder {
52    builder: glib::object::ObjectBuilder<'static, TextMark>,
53}
54
55impl TextMarkBuilder {
56    fn new() -> Self {
57        Self {
58            builder: glib::object::Object::builder(),
59        }
60    }
61
62    pub fn left_gravity(self, left_gravity: bool) -> Self {
63        Self {
64            builder: self.builder.property("left-gravity", left_gravity),
65        }
66    }
67
68    pub fn name(self, name: impl Into<glib::GString>) -> Self {
69        Self {
70            builder: self.builder.property("name", name.into()),
71        }
72    }
73
74    // rustdoc-stripper-ignore-next
75    /// Build the [`TextMark`].
76    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
77    pub fn build(self) -> TextMark {
78        assert_initialized_main_thread!();
79        self.builder.build()
80    }
81}
82
83pub trait TextMarkExt: IsA<TextMark> + 'static {
84    #[doc(alias = "gtk_text_mark_get_buffer")]
85    #[doc(alias = "get_buffer")]
86    fn buffer(&self) -> Option<TextBuffer> {
87        unsafe {
88            from_glib_none(ffi::gtk_text_mark_get_buffer(
89                self.as_ref().to_glib_none().0,
90            ))
91        }
92    }
93
94    #[doc(alias = "gtk_text_mark_get_deleted")]
95    #[doc(alias = "get_deleted")]
96    fn is_deleted(&self) -> bool {
97        unsafe {
98            from_glib(ffi::gtk_text_mark_get_deleted(
99                self.as_ref().to_glib_none().0,
100            ))
101        }
102    }
103
104    #[doc(alias = "gtk_text_mark_get_left_gravity")]
105    #[doc(alias = "get_left_gravity")]
106    #[doc(alias = "left-gravity")]
107    fn is_left_gravity(&self) -> bool {
108        unsafe {
109            from_glib(ffi::gtk_text_mark_get_left_gravity(
110                self.as_ref().to_glib_none().0,
111            ))
112        }
113    }
114
115    #[doc(alias = "gtk_text_mark_get_name")]
116    #[doc(alias = "get_name")]
117    fn name(&self) -> Option<glib::GString> {
118        unsafe { from_glib_none(ffi::gtk_text_mark_get_name(self.as_ref().to_glib_none().0)) }
119    }
120
121    #[doc(alias = "gtk_text_mark_get_visible")]
122    #[doc(alias = "get_visible")]
123    fn is_visible(&self) -> bool {
124        unsafe {
125            from_glib(ffi::gtk_text_mark_get_visible(
126                self.as_ref().to_glib_none().0,
127            ))
128        }
129    }
130
131    #[doc(alias = "gtk_text_mark_set_visible")]
132    fn set_visible(&self, setting: bool) {
133        unsafe {
134            ffi::gtk_text_mark_set_visible(self.as_ref().to_glib_none().0, setting.into_glib());
135        }
136    }
137}
138
139impl<O: IsA<TextMark>> TextMarkExt for O {}