// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ..
// from ../gir-files
// DO NOT EDIT

use crate::{ConditionPhenomenon,ConditionQualifier,DistanceUnit,Location,MoonLatitude,MoonPhase,PressureUnit,Provider,Sky,SpeedUnit,TemperatureUnit,WindDirection};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    #[doc(alias = "GWeatherInfo")]
    pub struct Info(Object<ffi::GWeatherInfo, ffi::GWeatherInfoClass>);

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

impl Info {
    #[doc(alias = "gweather_info_new")]
    pub fn new(location: Option<&Location>) -> Info {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gweather_info_new(location.to_glib_none().0))
        }
    }

            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`Info`] objects.
            ///
            /// This method returns an instance of [`InfoBuilder`](crate::builders::InfoBuilder) which can be used to create [`Info`] objects.
            pub fn builder() -> InfoBuilder {
                InfoBuilder::new()
            }
        

    #[doc(alias = "gweather_info_abort")]
    pub fn abort(&self) {
        unsafe {
            ffi::gweather_info_abort(self.to_glib_none().0);
        }
    }

    #[doc(alias = "gweather_info_get_apparent")]
    #[doc(alias = "get_apparent")]
    pub fn apparent(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_apparent(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_application_id")]
    #[doc(alias = "get_application_id")]
    pub fn application_id(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gweather_info_get_application_id(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_attribution")]
    #[doc(alias = "get_attribution")]
    pub fn attribution(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gweather_info_get_attribution(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_conditions")]
    #[doc(alias = "get_conditions")]
    pub fn conditions(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_conditions(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_contact_info")]
    #[doc(alias = "get_contact_info")]
    pub fn contact_info(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gweather_info_get_contact_info(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_dew")]
    #[doc(alias = "get_dew")]
    pub fn dew(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_dew(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_enabled_providers")]
    #[doc(alias = "get_enabled_providers")]
    pub fn enabled_providers(&self) -> Provider {
        unsafe {
            from_glib(ffi::gweather_info_get_enabled_providers(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_forecast_list")]
    #[doc(alias = "get_forecast_list")]
    pub fn forecast_list(&self) -> Vec<Info> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::gweather_info_get_forecast_list(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_humidity")]
    #[doc(alias = "get_humidity")]
    pub fn humidity(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_humidity(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_icon_name")]
    #[doc(alias = "get_icon_name")]
    pub fn icon_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gweather_info_get_icon_name(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_location")]
    #[doc(alias = "get_location")]
    pub fn location(&self) -> Location {
        unsafe {
            from_glib_none(ffi::gweather_info_get_location(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_location_name")]
    #[doc(alias = "get_location_name")]
    pub fn location_name(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_location_name(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_pressure")]
    #[doc(alias = "get_pressure")]
    pub fn pressure(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_pressure(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_sky")]
    #[doc(alias = "get_sky")]
    pub fn sky(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_sky(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_sunrise")]
    #[doc(alias = "get_sunrise")]
    pub fn sunrise(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_sunrise(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_sunset")]
    #[doc(alias = "get_sunset")]
    pub fn sunset(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_sunset(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_symbolic_icon_name")]
    #[doc(alias = "get_symbolic_icon_name")]
    pub fn symbolic_icon_name(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::gweather_info_get_symbolic_icon_name(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_temp")]
    #[doc(alias = "get_temp")]
    pub fn temp(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_temp(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_temp_max")]
    #[doc(alias = "get_temp_max")]
    pub fn temp_max(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_temp_max(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_temp_min")]
    #[doc(alias = "get_temp_min")]
    pub fn temp_min(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_temp_min(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_temp_summary")]
    #[doc(alias = "get_temp_summary")]
    pub fn temp_summary(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_temp_summary(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_update")]
    pub fn get_update(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_update(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_value_apparent")]
    #[doc(alias = "get_value_apparent")]
    pub fn value_apparent(&self, unit: TemperatureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_apparent(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_conditions")]
    #[doc(alias = "get_value_conditions")]
    pub fn value_conditions(&self) -> Option<(ConditionPhenomenon, ConditionQualifier)> {
        unsafe {
            let mut phenomenon = std::mem::MaybeUninit::uninit();
            let mut qualifier = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_conditions(self.to_glib_none().0, phenomenon.as_mut_ptr(), qualifier.as_mut_ptr()));
            if ret { Some((from_glib(phenomenon.assume_init()), from_glib(qualifier.assume_init()))) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_dew")]
    #[doc(alias = "get_value_dew")]
    pub fn value_dew(&self, unit: TemperatureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_dew(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_moonphase")]
    #[doc(alias = "get_value_moonphase")]
    pub fn value_moonphase(&self) -> Option<(MoonPhase, MoonLatitude)> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let mut lat = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_moonphase(self.to_glib_none().0, value.as_mut_ptr(), lat.as_mut_ptr()));
            if ret { Some((value.assume_init(), lat.assume_init())) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_pressure")]
    #[doc(alias = "get_value_pressure")]
    pub fn value_pressure(&self, unit: PressureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_pressure(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_sky")]
    #[doc(alias = "get_value_sky")]
    pub fn value_sky(&self) -> Option<Sky> {
        unsafe {
            let mut sky = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_sky(self.to_glib_none().0, sky.as_mut_ptr()));
            if ret { Some(from_glib(sky.assume_init())) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_sunrise")]
    #[doc(alias = "get_value_sunrise")]
    pub fn value_sunrise(&self) -> Option<libc::c_ulong> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_sunrise(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_sunset")]
    #[doc(alias = "get_value_sunset")]
    pub fn value_sunset(&self) -> Option<libc::c_ulong> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_sunset(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_temp")]
    #[doc(alias = "get_value_temp")]
    pub fn value_temp(&self, unit: TemperatureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_temp(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_temp_max")]
    #[doc(alias = "get_value_temp_max")]
    pub fn value_temp_max(&self, unit: TemperatureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_temp_max(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_temp_min")]
    #[doc(alias = "get_value_temp_min")]
    pub fn value_temp_min(&self, unit: TemperatureUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_temp_min(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_update")]
    #[doc(alias = "get_value_update")]
    pub fn value_update(&self) -> Option<libc::c_long> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_update(self.to_glib_none().0, value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_visibility")]
    #[doc(alias = "get_value_visibility")]
    pub fn value_visibility(&self, unit: DistanceUnit) -> Option<f64> {
        unsafe {
            let mut value = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_visibility(self.to_glib_none().0, unit.into_glib(), value.as_mut_ptr()));
            if ret { Some(value.assume_init()) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_value_wind")]
    #[doc(alias = "get_value_wind")]
    pub fn value_wind(&self, unit: SpeedUnit) -> Option<(f64, WindDirection)> {
        unsafe {
            let mut speed = std::mem::MaybeUninit::uninit();
            let mut direction = std::mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gweather_info_get_value_wind(self.to_glib_none().0, unit.into_glib(), speed.as_mut_ptr(), direction.as_mut_ptr()));
            if ret { Some((speed.assume_init(), from_glib(direction.assume_init()))) } else { None }
        }
    }

    #[doc(alias = "gweather_info_get_visibility")]
    #[doc(alias = "get_visibility")]
    pub fn visibility(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_visibility(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_weather_summary")]
    #[doc(alias = "get_weather_summary")]
    pub fn weather_summary(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_weather_summary(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_get_wind")]
    #[doc(alias = "get_wind")]
    pub fn wind(&self) -> glib::GString {
        unsafe {
            from_glib_full(ffi::gweather_info_get_wind(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_is_daytime")]
    pub fn is_daytime(&self) -> bool {
        unsafe {
            from_glib(ffi::gweather_info_is_daytime(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_is_valid")]
    pub fn is_valid(&self) -> bool {
        unsafe {
            from_glib(ffi::gweather_info_is_valid(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_network_error")]
    pub fn network_error(&self) -> bool {
        unsafe {
            from_glib(ffi::gweather_info_network_error(self.to_glib_none().0))
        }
    }

    #[doc(alias = "gweather_info_next_sun_event")]
    pub fn next_sun_event(&self) -> i32 {
        unsafe {
            ffi::gweather_info_next_sun_event(self.to_glib_none().0)
        }
    }

    #[doc(alias = "gweather_info_set_application_id")]
    pub fn set_application_id(&self, application_id: &str) {
        unsafe {
            ffi::gweather_info_set_application_id(self.to_glib_none().0, application_id.to_glib_none().0);
        }
    }

    #[doc(alias = "gweather_info_set_contact_info")]
    pub fn set_contact_info(&self, contact_info: &str) {
        unsafe {
            ffi::gweather_info_set_contact_info(self.to_glib_none().0, contact_info.to_glib_none().0);
        }
    }

    #[doc(alias = "gweather_info_set_enabled_providers")]
    pub fn set_enabled_providers(&self, providers: Provider) {
        unsafe {
            ffi::gweather_info_set_enabled_providers(self.to_glib_none().0, providers.into_glib());
        }
    }

    #[doc(alias = "gweather_info_set_location")]
    pub fn set_location(&self, location: Option<&Location>) {
        unsafe {
            ffi::gweather_info_set_location(self.to_glib_none().0, location.to_glib_none().0);
        }
    }

    #[doc(alias = "gweather_info_update")]
    pub fn update(&self) {
        unsafe {
            ffi::gweather_info_update(self.to_glib_none().0);
        }
    }

    #[doc(alias = "gweather_info_store_cache")]
    pub fn store_cache() {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gweather_info_store_cache();
        }
    }

    #[doc(alias = "updated")]
    pub fn connect_updated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn updated_trampoline<F: Fn(&Info) + 'static>(this: *mut ffi::GWeatherInfo, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"updated\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(updated_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "application-id")]
    pub fn connect_application_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_application_id_trampoline<F: Fn(&Info) + 'static>(this: *mut ffi::GWeatherInfo, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::application-id\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_application_id_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "contact-info")]
    pub fn connect_contact_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_contact_info_trampoline<F: Fn(&Info) + 'static>(this: *mut ffi::GWeatherInfo, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::contact-info\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_contact_info_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "enabled-providers")]
    pub fn connect_enabled_providers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_enabled_providers_trampoline<F: Fn(&Info) + 'static>(this: *mut ffi::GWeatherInfo, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::enabled-providers\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_enabled_providers_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "location")]
    pub fn connect_location_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_location_trampoline<F: Fn(&Info) + 'static>(this: *mut ffi::GWeatherInfo, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::location\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_location_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl Default for Info {
                     fn default() -> Self {
                         glib::object::Object::new::<Self>()
                     }
                 }

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`Info`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct InfoBuilder {
            builder: glib::object::ObjectBuilder<'static, Info>,
        }

        impl InfoBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("application-id", application_id.into()), }
                        }

                            pub fn contact_info(self, contact_info: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("contact-info", contact_info.into()), }
                        }

                            pub fn enabled_providers(self, enabled_providers: Provider) -> Self {
                            Self { builder: self.builder.property("enabled-providers", enabled_providers), }
                        }

                            pub fn location(self, location: &Location) -> Self {
                            Self { builder: self.builder.property("location", location.clone()), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`Info`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Info {
    self.builder.build() }
}
