1 /*
2 * Copyright (C) 2021, Georges Basile Stavracas Neto
3 *
4 * This file is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 3.0 of the
7 * License.
8 *
9 * This file is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * SPDX-License-Identifier: LGPL-3.0-only
18 */
19
20 #include "config.h"
21 #include "parent-private.h"
22
23
24 /**
25 * XdpParent
26 *
27 * Parent window abstraction.
28 *
29 * The [struct@Parent] struct provides an abstract way to represent
30 * a window, without introducing a dependency on a toolkit
31 * library.
32 *
33 * An XdpParent implementation for GTK is included in the
34 * `portal-gtk3.h` and `portal-gtk4.h` header files, in the form of inline functions.
35 * To create a XdpParent for a GTK window, use
36 * `xdp_parent_new_gtk()`.
37 */
G_DEFINE_BOXED_TYPE(XdpParent,xdp_parent,xdp_parent_copy,xdp_parent_free)38 G_DEFINE_BOXED_TYPE (XdpParent, xdp_parent, xdp_parent_copy, xdp_parent_free)
39
40 /**
41 * xdp_parent_copy:
42 * @source: a [struct@Parent]
43 *
44 * Copies @source into a new [struct@Parent].
45 *
46 * Returns: (transfer full): an [struct@Parent] that is a copy of @source
47 */
48 XdpParent *
49 xdp_parent_copy (XdpParent *source)
50 {
51 XdpParent *parent;
52
53 parent = g_new0 (XdpParent, 1);
54
55 parent->parent_export = source->parent_export;
56 parent->parent_unexport = source->parent_unexport;
57 g_set_object (&parent->object, source->object);
58 parent->data = source->data;
59
60 return parent;
61 }
62
63 /**
64 * xdp_parent_free:
65 * @parent: an [struct@Parent]
66 *
67 * Frees @parent.
68 */
69 void
xdp_parent_free(XdpParent * parent)70 xdp_parent_free (XdpParent *parent)
71 {
72 g_clear_object (&parent->object);
73 g_free (parent);
74 }
75