libappstream/auto/launchable.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
// 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, LaunchableKind};
use glib::{prelude::*, translate::*};
glib::wrapper! {
///
///
/// # Implements
///
/// [`LaunchableExt`][trait@crate::prelude::LaunchableExt]
#[doc(alias = "AsLaunchable")]
pub struct Launchable(Object<ffi::AsLaunchable, ffi::AsLaunchableClass>);
match fn {
type_ => || ffi::as_launchable_get_type(),
}
}
impl Launchable {
pub const NONE: Option<&'static Launchable> = None;
/// Creates a new [`Launchable`][crate::Launchable].
///
/// # Returns
///
/// a [`Launchable`][crate::Launchable]
#[doc(alias = "as_launchable_new")]
pub fn new() -> Launchable {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::as_launchable_new()) }
}
}
impl Default for Launchable {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Launchable>> Sealed for T {}
}
/// Trait containing all [`struct@Launchable`] methods.
///
/// # Implementors
///
/// [`Launchable`][struct@crate::Launchable]
pub trait LaunchableExt: IsA<Launchable> + sealed::Sealed + 'static {
/// Add a new launchable entry.
#[doc(alias = "as_launchable_add_entry")]
fn add_entry(&self, entry: &str) {
unsafe {
ffi::as_launchable_add_entry(self.as_ref().to_glib_none().0, entry.to_glib_none().0);
}
}
/// Get an array of launchable entries.
///
/// # Returns
///
/// An string list of launch entries.
#[doc(alias = "as_launchable_get_entries")]
#[doc(alias = "get_entries")]
fn entries(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::as_launchable_get_entries(
self.as_ref().to_glib_none().0,
))
}
}
/// The launch system for the entries this [`Launchable`][crate::Launchable]
/// object stores.
///
/// # Returns
///
/// an enum of type [`LaunchableKind`][crate::LaunchableKind]
#[doc(alias = "as_launchable_get_kind")]
#[doc(alias = "get_kind")]
fn kind(&self) -> LaunchableKind {
unsafe { from_glib(ffi::as_launchable_get_kind(self.as_ref().to_glib_none().0)) }
}
/// Set the launch system for the entries this [`Launchable`][crate::Launchable]
/// object stores.
/// ## `kind`
/// the new [`LaunchableKind`][crate::LaunchableKind]
#[doc(alias = "as_launchable_set_kind")]
fn set_kind(&self, kind: LaunchableKind) {
unsafe {
ffi::as_launchable_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
}
}
}
impl<O: IsA<Launchable>> LaunchableExt for O {}