libappstream/auto/suggested.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
// 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, SuggestedKind};
use glib::{prelude::*, translate::*};
glib::wrapper! {
///
///
/// # Implements
///
/// [`SuggestedExt`][trait@crate::prelude::SuggestedExt]
#[doc(alias = "AsSuggested")]
pub struct Suggested(Object<ffi::AsSuggested, ffi::AsSuggestedClass>);
match fn {
type_ => || ffi::as_suggested_get_type(),
}
}
impl Suggested {
pub const NONE: Option<&'static Suggested> = None;
/// Creates a new [`Suggested`][crate::Suggested].
///
/// # Returns
///
/// a new [`Suggested`][crate::Suggested]
#[doc(alias = "as_suggested_new")]
pub fn new() -> Suggested {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::as_suggested_new()) }
}
}
impl Default for Suggested {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Suggested>> Sealed for T {}
}
/// Trait containing all [`struct@Suggested`] methods.
///
/// # Implementors
///
/// [`Suggested`][struct@crate::Suggested]
pub trait SuggestedExt: IsA<Suggested> + sealed::Sealed + 'static {
/// Add a component id to this suggested object.
/// ## `cid`
/// The component id to add
#[doc(alias = "as_suggested_add_id")]
fn add_id(&self, cid: &str) {
unsafe {
ffi::as_suggested_add_id(self.as_ref().to_glib_none().0, cid.to_glib_none().0);
}
}
/// Get a list of components id that generated the suggestion
///
/// # Returns
///
/// an array of components id
#[doc(alias = "as_suggested_get_ids")]
#[doc(alias = "get_ids")]
fn ids(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_suggested_get_ids(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the suggested kind.
///
/// # Returns
///
/// the [`SuggestedKind`][crate::SuggestedKind]
#[doc(alias = "as_suggested_get_kind")]
#[doc(alias = "get_kind")]
fn kind(&self) -> SuggestedKind {
unsafe { from_glib(ffi::as_suggested_get_kind(self.as_ref().to_glib_none().0)) }
}
/// Check if the essential properties of this suggestion are
/// populated with useful data.
///
/// # Returns
///
/// [`true`] if we have useful data.
#[doc(alias = "as_suggested_is_valid")]
fn is_valid(&self) -> bool {
unsafe { from_glib(ffi::as_suggested_is_valid(self.as_ref().to_glib_none().0)) }
}
/// Sets the suggested kind.
/// ## `kind`
/// the [`SuggestedKind`][crate::SuggestedKind], e.g. [`SuggestedKind::Heuristic`][crate::SuggestedKind::Heuristic].
#[doc(alias = "as_suggested_set_kind")]
fn set_kind(&self, kind: SuggestedKind) {
unsafe {
ffi::as_suggested_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
}
}
}
impl<O: IsA<Suggested>> SuggestedExt for O {}