// 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, Location};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "ShumateSymbolEvent")]
    pub struct SymbolEvent(Object<ffi::ShumateSymbolEvent, ffi::ShumateSymbolEventClass>) @implements Location;

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

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

    #[doc(alias = "shumate_symbol_event_get_feature_id")]
    #[doc(alias = "get_feature_id")]
    #[doc(alias = "feature-id")]
    pub fn feature_id(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::shumate_symbol_event_get_feature_id(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_symbol_event_get_layer")]
    #[doc(alias = "get_layer")]
    pub fn layer(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::shumate_symbol_event_get_layer(self.to_glib_none().0)) }
    }

    #[doc(alias = "shumate_symbol_event_get_source_layer")]
    #[doc(alias = "get_source_layer")]
    #[doc(alias = "source-layer")]
    pub fn source_layer(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::shumate_symbol_event_get_source_layer(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_symbol_event_get_tag")]
    #[doc(alias = "get_tag")]
    pub fn tag(&self, tag_name: &str) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::shumate_symbol_event_get_tag(
                self.to_glib_none().0,
                tag_name.to_glib_none().0,
            ))
        }
    }

    #[cfg(not(feature = "v1_1"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1"))))]
    #[doc(alias = "source-layer")]
    pub fn source_layer(&self) -> Option<glib::GString> {
        ObjectExt::property(self, "source-layer")
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    #[doc(alias = "feature-id")]
    pub fn connect_feature_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_feature_id_trampoline<F: Fn(&SymbolEvent) + 'static>(
            this: *mut ffi::ShumateSymbolEvent,
            _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::feature-id\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_feature_id_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_1")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
    #[doc(alias = "layer")]
    pub fn connect_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_layer_trampoline<F: Fn(&SymbolEvent) + 'static>(
            this: *mut ffi::ShumateSymbolEvent,
            _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::layer\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_layer_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "source-layer")]
    pub fn connect_source_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_source_layer_trampoline<F: Fn(&SymbolEvent) + 'static>(
            this: *mut ffi::ShumateSymbolEvent,
            _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::source-layer\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_source_layer_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`SymbolEvent`] 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 SymbolEventBuilder {
    builder: glib::object::ObjectBuilder<'static, SymbolEvent>,
}

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

    pub fn latitude(self, latitude: f64) -> Self {
        Self {
            builder: self.builder.property("latitude", latitude),
        }
    }

    pub fn longitude(self, longitude: f64) -> Self {
        Self {
            builder: self.builder.property("longitude", longitude),
        }
    }

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