use crate::{Location, ffi};
use glib::{prelude::*, translate::*};
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::new()
}
}
impl Default for Coordinate {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct CoordinateBuilder {
builder: glib::object::ObjectBuilder<'static, Coordinate>,
}
impl CoordinateBuilder {
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),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Coordinate {
assert_initialized_main_thread!();
self.builder.build()
}
}