// 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)) }
    }

    #[cfg(feature = "v1_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
    #[doc(alias = "shumate_symbol_event_get_n_press")]
    #[doc(alias = "get_n_press")]
    #[doc(alias = "n-press")]
    pub fn n_press(&self) -> i32 {
        unsafe { ffi::shumate_symbol_event_get_n_press(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(feature = "v1_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
    #[doc(alias = "n-press")]
    pub fn set_n_press(&self, n_press: u32) {
        ObjectExt::set_property(self, "n-press", n_press)
    }

    #[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 _,
                c"notify::feature-id".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 _,
                c"notify::layer".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_layer_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
    #[doc(alias = "n-press")]
    pub fn connect_n_press_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_n_press_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 _,
                c"notify::n-press".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_n_press_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 _,
                c"notify::source-layer".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(),
        }
    }

    #[cfg(feature = "v1_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
    pub fn n_press(self, n_press: u32) -> Self {
        Self {
            builder: self.builder.property("n-press", n_press),
        }
    }

    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 {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}
