1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;

glib::wrapper! {
    /// Using [`TextAttributes`][crate::TextAttributes] directly should rarely be necessary.
    /// It’s primarily useful with [`TextIter::attributes()`][crate::TextIter::attributes()].
    /// As with most GTK+ structs, the fields in this struct should only
    /// be read, never modified directly.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct TextAttributes(Shared<ffi::GtkTextAttributes>);

    match fn {
        ref => |ptr| ffi::gtk_text_attributes_ref(ptr),
        unref => |ptr| ffi::gtk_text_attributes_unref(ptr),
        type_ => || ffi::gtk_text_attributes_get_type(),
    }
}

impl TextAttributes {
    /// Creates a [`TextAttributes`][crate::TextAttributes], which describes
    /// a set of properties on some text.
    ///
    /// # Returns
    ///
    /// a new [`TextAttributes`][crate::TextAttributes],
    ///  free with `gtk_text_attributes_unref()`.
    #[doc(alias = "gtk_text_attributes_new")]
    pub fn new() -> TextAttributes {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_text_attributes_new()) }
    }

    /// Copies `self` and returns a new [`TextAttributes`][crate::TextAttributes].
    ///
    /// # Returns
    ///
    /// a copy of `self`,
    ///  free with `gtk_text_attributes_unref()`
    #[doc(alias = "gtk_text_attributes_copy")]
    pub fn copy(&self) -> Option<TextAttributes> {
        unsafe { from_glib_full(ffi::gtk_text_attributes_copy(self.to_glib_none().0)) }
    }

    /// Copies the values from `self` to `dest` so that `dest` has
    /// the same values as `self`. Frees existing values in `dest`.
    /// ## `dest`
    /// another [`TextAttributes`][crate::TextAttributes]
    #[doc(alias = "gtk_text_attributes_copy_values")]
    pub fn copy_values(&self, dest: &TextAttributes) {
        unsafe {
            ffi::gtk_text_attributes_copy_values(self.to_glib_none().0, dest.to_glib_none().0);
        }
    }
}

impl Default for TextAttributes {
    fn default() -> Self {
        Self::new()
    }
}