use crate::MapSource;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "ShumateMapSourceRegistry")]
pub struct MapSourceRegistry(Object<ffi::ShumateMapSourceRegistry, ffi::ShumateMapSourceRegistryClass>) @implements gio::ListModel;
match fn {
type_ => || ffi::shumate_map_source_registry_get_type(),
}
}
impl MapSourceRegistry {
#[doc(alias = "shumate_map_source_registry_new")]
pub fn new() -> MapSourceRegistry {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::shumate_map_source_registry_new()) }
}
#[doc(alias = "shumate_map_source_registry_new_with_defaults")]
#[doc(alias = "new_with_defaults")]
pub fn with_defaults() -> MapSourceRegistry {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::shumate_map_source_registry_new_with_defaults()) }
}
#[doc(alias = "shumate_map_source_registry_add")]
pub fn add(&self, map_source: &impl IsA<MapSource>) {
unsafe {
ffi::shumate_map_source_registry_add(
self.to_glib_none().0,
map_source.as_ref().to_glib_full(),
);
}
}
#[doc(alias = "shumate_map_source_registry_get_by_id")]
#[doc(alias = "get_by_id")]
pub fn by_id(&self, id: &str) -> Option<MapSource> {
unsafe {
from_glib_none(ffi::shumate_map_source_registry_get_by_id(
self.to_glib_none().0,
id.to_glib_none().0,
))
}
}
#[doc(alias = "shumate_map_source_registry_populate_defaults")]
pub fn populate_defaults(&self) {
unsafe {
ffi::shumate_map_source_registry_populate_defaults(self.to_glib_none().0);
}
}
#[doc(alias = "shumate_map_source_registry_remove")]
pub fn remove(&self, id: &str) {
unsafe {
ffi::shumate_map_source_registry_remove(self.to_glib_none().0, id.to_glib_none().0);
}
}
}
impl Default for MapSourceRegistry {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for MapSourceRegistry {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("MapSourceRegistry")
}
}