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