libappstream 0.4.0

Rust bindings for appstream
Documentation
// 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, TranslationKind};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "AsTranslation")]
    pub struct Translation(Object<ffi::AsTranslation, ffi::AsTranslationClass>);

    match fn {
        type_ => || ffi::as_translation_get_type(),
    }
}

impl Translation {
    pub const NONE: Option<&'static Translation> = None;

    #[doc(alias = "as_translation_new")]
    pub fn new() -> Translation {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::as_translation_new()) }
    }
}

impl Default for Translation {
    fn default() -> Self {
        Self::new()
    }
}

pub trait TranslationExt: IsA<Translation> + 'static {
    #[doc(alias = "as_translation_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::as_translation_get_id(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "as_translation_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> TranslationKind {
        unsafe { from_glib(ffi::as_translation_get_kind(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "as_translation_get_source_locale")]
    #[doc(alias = "get_source_locale")]
    fn source_locale(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::as_translation_get_source_locale(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "as_translation_set_id")]
    fn set_id(&self, id: &str) {
        unsafe {
            ffi::as_translation_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
        }
    }

    #[doc(alias = "as_translation_set_kind")]
    fn set_kind(&self, kind: TranslationKind) {
        unsafe {
            ffi::as_translation_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }

    #[doc(alias = "as_translation_set_source_locale")]
    fn set_source_locale(&self, locale: Option<&str>) {
        unsafe {
            ffi::as_translation_set_source_locale(
                self.as_ref().to_glib_none().0,
                locale.to_glib_none().0,
            );
        }
    }
}

impl<O: IsA<Translation>> TranslationExt for O {}