gio/auto/
simple_permission.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Permission};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// `GSimplePermission` is a trivial implementation of [`Permission`][crate::Permission]
10    /// that represents a permission that is either always or never allowed.  The
11    /// value is given at construction and doesn’t change.
12    ///
13    /// Calling [`PermissionExt::acquire()`][crate::prelude::PermissionExt::acquire()] or [`PermissionExt::release()`][crate::prelude::PermissionExt::release()]
14    /// on a `GSimplePermission` will result in errors.
15    ///
16    /// # Implements
17    ///
18    /// [`PermissionExt`][trait@crate::prelude::PermissionExt], [`trait@glib::ObjectExt`]
19    #[doc(alias = "GSimplePermission")]
20    pub struct SimplePermission(Object<ffi::GSimplePermission>) @extends Permission;
21
22    match fn {
23        type_ => || ffi::g_simple_permission_get_type(),
24    }
25}
26
27impl SimplePermission {
28    /// Creates a new #GPermission instance that represents an action that is
29    /// either always or never allowed.
30    /// ## `allowed`
31    /// [`true`] if the action is allowed
32    ///
33    /// # Returns
34    ///
35    /// the #GSimplePermission, as a #GPermission
36    #[doc(alias = "g_simple_permission_new")]
37    pub fn new(allowed: bool) -> SimplePermission {
38        unsafe {
39            Permission::from_glib_full(ffi::g_simple_permission_new(allowed.into_glib()))
40                .unsafe_cast()
41        }
42    }
43}