use crate::Location;
use glib::object::Cast;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;
glib::wrapper! {
#[doc(alias = "ShumateCoordinate")]
pub struct Coordinate(Object<ffi::ShumateCoordinate, ffi::ShumateCoordinateClass>) @implements Location;
match fn {
type_ => || ffi::shumate_coordinate_get_type(),
}
}
impl Coordinate {
pub const NONE: Option<&'static Coordinate> = None;
#[doc(alias = "shumate_coordinate_new")]
pub fn new() -> Coordinate {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::shumate_coordinate_new()) }
}
#[doc(alias = "shumate_coordinate_new_full")]
pub fn new_full(latitude: f64, longitude: f64) -> Coordinate {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::shumate_coordinate_new_full(latitude, longitude)) }
}
pub fn builder() -> CoordinateBuilder {
CoordinateBuilder::default()
}
}
impl Default for Coordinate {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Default)]
#[must_use = "The builder must be built to be used"]
pub struct CoordinateBuilder {
latitude: Option<f64>,
longitude: Option<f64>,
}
impl CoordinateBuilder {
pub fn new() -> Self {
Self::default()
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Coordinate {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref latitude) = self.latitude {
properties.push(("latitude", latitude));
}
if let Some(ref longitude) = self.longitude {
properties.push(("longitude", longitude));
}
glib::Object::new::<Coordinate>(&properties)
}
pub fn latitude(mut self, latitude: f64) -> Self {
self.latitude = Some(latitude);
self
}
pub fn longitude(mut self, longitude: f64) -> Self {
self.longitude = Some(longitude);
self
}
}
impl fmt::Display for Coordinate {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Coordinate")
}
}