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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{ConditionPhenomenon, ConditionQualifier, FormatOptions};

use glib::translate::*;

glib::wrapper! {
    /// A convenient way to describe the current or forecast
    /// weather phenomenon, if significant, and its associated
    /// modifier. If the value is not significant, the weather conditions
    /// are described by gweather_info_get_sky() instead.
    ///
    /// In general it is discouraged to use this value directly to compute
    /// the forecast icon: applications should instead use
    /// gweather_info_get_icon_name() or
    /// gweather_info_get_symbolic_icon_name().
    #[doc(alias = "GWeatherConditions")]
    pub struct Conditions(BoxedInline<ffi::GWeatherConditions>);
}

impl Conditions {
    #[inline]
    pub fn new(
        significant: bool,
        phenomenon: ConditionPhenomenon,
        qualifier: ConditionQualifier,
    ) -> Self {
        assert_initialized_main_thread!();
        unsafe {
            Self::unsafe_from(ffi::GWeatherConditions {
                significant: significant.into_glib(),
                phenomenon: phenomenon.into_glib(),
                qualifier: qualifier.into_glib(),
            })
        }
    }

    #[inline]
    pub fn significant(&self) -> bool {
        unsafe { from_glib(self.inner.significant) }
    }

    #[inline]
    pub fn phenomenon(&self) -> ConditionPhenomenon {
        unsafe { from_glib(self.inner.phenomenon) }
    }

    #[inline]
    pub fn qualifier(&self) -> ConditionQualifier {
        unsafe { from_glib(self.inner.qualifier) }
    }

    #[doc(alias = "gweather_conditions_to_string")]
    #[doc(alias = "to_string")]
    pub fn to_str(&mut self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_conditions_to_string(
                self.to_glib_none_mut().0,
            ))
        }
    }

    #[doc(alias = "gweather_conditions_to_string_full")]
    #[doc(alias = "to_string_full")]
    pub fn to_str_full(&mut self, options: &FormatOptions) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_conditions_to_string_full(
                self.to_glib_none_mut().0,
                options.into_glib(),
            ))
        }
    }
}