/src/pango/subprojects/glib/gio/gsimplepermission.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright © 2010 Codethink Limited |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | * |
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. |
10 | | * |
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. |
15 | | * |
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/>. |
18 | | * |
19 | | * Author: Ryan Lortie <desrt@desrt.ca> |
20 | | */ |
21 | | |
22 | | #include "config.h" |
23 | | |
24 | | #include "gsimplepermission.h" |
25 | | #include "gpermission.h" |
26 | | |
27 | | |
28 | | /** |
29 | | * GSimplePermission: |
30 | | * |
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. |
34 | | * |
35 | | * Calling [method@Gio.Permission.acquire] or [method@Gio.Permission.release] |
36 | | * on a `GSimplePermission` will result in errors. |
37 | | **/ |
38 | | |
39 | | typedef GPermissionClass GSimplePermissionClass; |
40 | | |
41 | | struct _GSimplePermission |
42 | | { |
43 | | GPermission parent_instance; |
44 | | }; |
45 | | |
46 | | G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION) |
47 | | |
48 | | static void |
49 | | g_simple_permission_init (GSimplePermission *simple) |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | static void |
54 | | g_simple_permission_class_init (GSimplePermissionClass *class) |
55 | 0 | { |
56 | 0 | } |
57 | | |
58 | | /** |
59 | | * g_simple_permission_new: |
60 | | * @allowed: %TRUE if the action is allowed |
61 | | * |
62 | | * Creates a new #GPermission instance that represents an action that is |
63 | | * either always or never allowed. |
64 | | * |
65 | | * Returns: the #GSimplePermission, as a #GPermission |
66 | | * |
67 | | * Since: 2.26 |
68 | | **/ |
69 | | GPermission * |
70 | | g_simple_permission_new (gboolean allowed) |
71 | 0 | { |
72 | 0 | GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL); |
73 | |
|
74 | 0 | g_permission_impl_update (permission, allowed, FALSE, FALSE); |
75 | |
|
76 | 0 | return permission; |
77 | 0 | } |