libappstream/auto/
branding.rs

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, ColorKind, ColorSchemeKind};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`BrandingExt`][trait@crate::prelude::BrandingExt]
    #[doc(alias = "AsBranding")]
    pub struct Branding(Object<ffi::AsBranding, ffi::AsBrandingClass>);

    match fn {
        type_ => || ffi::as_branding_get_type(),
    }
}

impl Branding {
    pub const NONE: Option<&'static Branding> = None;

    /// Creates a new [`Branding`][crate::Branding].
    ///
    /// # Returns
    ///
    /// a [`Branding`][crate::Branding]
    #[doc(alias = "as_branding_new")]
    pub fn new() -> Branding {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::as_branding_new()) }
    }
}

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

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Branding>> Sealed for T {}
}

/// Trait containing all [`struct@Branding`] methods.
///
/// # Implementors
///
/// [`Branding`][struct@crate::Branding]
pub trait BrandingExt: IsA<Branding> + sealed::Sealed + 'static {
    /// Retrieve a color of the given `kind` that matches `scheme_kind`.
    /// If a color has no scheme preference defined, it will be returned for either scheme type,
    /// unless a more suitable color was found.
    /// ## `kind`
    /// the [`ColorKind`][crate::ColorKind], e.g. [`ColorKind::Primary`][crate::ColorKind::Primary].
    /// ## `scheme_kind`
    /// Color scheme preference for the color, e.g. [`ColorSchemeKind::Light`][crate::ColorSchemeKind::Light]
    ///
    /// # Returns
    ///
    /// The HTML color code of the found color, or [`None`] if no color was found.
    #[doc(alias = "as_branding_get_color")]
    #[doc(alias = "get_color")]
    fn color(&self, kind: ColorKind, scheme_kind: ColorSchemeKind) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::as_branding_get_color(
                self.as_ref().to_glib_none().0,
                kind.into_glib(),
                scheme_kind.into_glib(),
            ))
        }
    }

    /// Deletes a color that matches the given type and scheme preference.
    /// ## `kind`
    /// the [`ColorKind`][crate::ColorKind], e.g. [`ColorKind::Primary`][crate::ColorKind::Primary].
    /// ## `scheme_preference`
    /// Type of color scheme preferred for this color, e.g. [`ColorSchemeKind::Light`][crate::ColorSchemeKind::Light]
    #[doc(alias = "as_branding_remove_color")]
    fn remove_color(&self, kind: ColorKind, scheme_preference: ColorSchemeKind) {
        unsafe {
            ffi::as_branding_remove_color(
                self.as_ref().to_glib_none().0,
                kind.into_glib(),
                scheme_preference.into_glib(),
            );
        }
    }

    /// Sets a new accent color. If a color of the given kind with the given scheme preference already exists,
    /// it will be overriden with the new color code.
    /// ## `kind`
    /// the [`ColorKind`][crate::ColorKind], e.g. [`ColorKind::Primary`][crate::ColorKind::Primary].
    /// ## `scheme_preference`
    /// Type of color scheme preferred for this color, e.g. [`ColorSchemeKind::Light`][crate::ColorSchemeKind::Light]
    /// ## `colorcode`
    /// a HTML color code.
    #[doc(alias = "as_branding_set_color")]
    fn set_color(&self, kind: ColorKind, scheme_preference: ColorSchemeKind, colorcode: &str) {
        unsafe {
            ffi::as_branding_set_color(
                self.as_ref().to_glib_none().0,
                kind.into_glib(),
                scheme_preference.into_glib(),
                colorcode.to_glib_none().0,
            );
        }
    }
}

impl<O: IsA<Branding>> BrandingExt for O {}