2 * Copyright © 2010 Codethink Limited
4 * SPDX-License-Identifier: LGPL-2.1-or-later
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * Author: Ryan Lortie <desrt@desrt.ca>
24 #include "gsimplepermission.h"
25 #include "gpermission.h"
31 * `GSimplePermission` is a trivial implementation of [class@Gio.Permission]
32 * that represents a permission that is either always or never allowed. The
33 * value is given at construction and doesn’t change.
35 * Calling [method@Gio.Permission.acquire] or [method@Gio.Permission.release]
36 * on a `GSimplePermission` will result in errors.
39 typedef GPermissionClass GSimplePermissionClass;
41 struct _GSimplePermission
43 GPermission parent_instance;
46 G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION)
49 g_simple_permission_init (GSimplePermission *simple)
54 g_simple_permission_class_init (GSimplePermissionClass *class)
59 * g_simple_permission_new:
60 * @allowed: %TRUE if the action is allowed
62 * Creates a new #GPermission instance that represents an action that is
63 * either always or never allowed.
65 * Returns: the #GSimplePermission, as a #GPermission
70 g_simple_permission_new (gboolean allowed)
72 GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL);
74 g_permission_impl_update (permission, allowed, FALSE, FALSE);