libshumate 0.8.0

Rust bindings for libshumate
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{MapSource, ffi};
use glib::{prelude::*, translate::*};

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.upcast().into_glib_ptr(),
            );
        }
    }

    #[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()
    }
}