libappstream/auto/translation.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
// 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! {
///
///
/// # Implements
///
/// [`TranslationExt`][trait@crate::prelude::TranslationExt]
#[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;
/// Creates a new [`Translation`][crate::Translation].
///
/// # Returns
///
/// a [`Translation`][crate::Translation]
#[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()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Translation>> Sealed for T {}
}
/// Trait containing all [`struct@Translation`] methods.
///
/// # Implementors
///
/// [`Translation`][struct@crate::Translation]
pub trait TranslationExt: IsA<Translation> + sealed::Sealed + 'static {
/// The ID (e.g. Gettext translation domain) of this translation.
#[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)) }
}
/// The translation system type.
///
/// # Returns
///
/// an enum of type [`TranslationKind`][crate::TranslationKind]
#[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)) }
}
/// The locale of the source strings for this component. If this has not been
/// explicitly specified, `en_US` will be returned.
///
/// # Returns
///
/// The locale of the source strings for this component.
#[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,
))
}
}
/// Set the ID (e.g. Gettext domain) of this translation.
/// ## `id`
/// The ID of this translation.
#[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);
}
}
/// Set the translation system type.
/// ## `kind`
/// the new [`TranslationKind`][crate::TranslationKind]
#[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());
}
}
/// Set the locale of the source strings for this component. In gettext, this is
/// referred to as the `C` locale. It’s almost always `en_US`, but for some
/// components it may not be.
/// ## `locale`
/// The POSIX locale that the source strings are in, or [`None`] if unknown or default.
#[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 {}