Skip to main content

gtk/auto/
text_attributes.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Using [`TextAttributes`][crate::TextAttributes] directly should rarely be necessary.
10    /// It’s primarily useful with [`TextIter::is_attributes()`][crate::TextIter::is_attributes()].
11    /// As with most GTK+ structs, the fields in this struct should only
12    /// be read, never modified directly.
13    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
14    pub struct TextAttributes(Shared<ffi::GtkTextAttributes>);
15
16    match fn {
17        ref => |ptr| ffi::gtk_text_attributes_ref(ptr),
18        unref => |ptr| ffi::gtk_text_attributes_unref(ptr),
19        type_ => || ffi::gtk_text_attributes_get_type(),
20    }
21}
22
23impl TextAttributes {
24    /// Creates a [`TextAttributes`][crate::TextAttributes], which describes
25    /// a set of properties on some text.
26    ///
27    /// # Returns
28    ///
29    /// a new [`TextAttributes`][crate::TextAttributes],
30    ///  free with `gtk_text_attributes_unref()`.
31    #[doc(alias = "gtk_text_attributes_new")]
32    pub fn new() -> TextAttributes {
33        assert_initialized_main_thread!();
34        unsafe { from_glib_full(ffi::gtk_text_attributes_new()) }
35    }
36
37    #[doc(alias = "gtk_text_attributes_copy")]
38    #[must_use]
39    pub fn copy(&self) -> Option<TextAttributes> {
40        unsafe { from_glib_full(ffi::gtk_text_attributes_copy(self.to_glib_none().0)) }
41    }
42
43    /// Copies the values from `self` to `dest` so that `dest` has
44    /// the same values as `self`. Frees existing values in `dest`.
45    /// ## `dest`
46    /// another [`TextAttributes`][crate::TextAttributes]
47    #[doc(alias = "gtk_text_attributes_copy_values")]
48    pub fn copy_values(&self, dest: &TextAttributes) {
49        unsafe {
50            ffi::gtk_text_attributes_copy_values(self.to_glib_none().0, dest.to_glib_none().0);
51        }
52    }
53}
54
55impl Default for TextAttributes {
56    fn default() -> Self {
57        Self::new()
58    }
59}