Debian Codegraph @

vendored-meson/meson/test cases/frameworks/7 gnome/gir/dep1/dep3/dep3.c

raw
1 #include "dep3.h"
2
3 struct _MesonDep3
4 {
5 GObject parent_instance;
6
7 gchar *msg;
8 };
9
10 G_DEFINE_TYPE (MesonDep3, meson_dep3, G_TYPE_OBJECT)
11
12 enum {
13 PROP_0,
14 PROP_MSG,
15 LAST_PROP
16 };
17
18 static GParamSpec *gParamSpecs [LAST_PROP];
19
20 /**
21 * meson_dep3_new:
22 * @msg: The message to set.
23 *
24 * Allocates a new #MesonDep3.
25 *
26 * Returns: (transfer full): a #MesonDep3.
27 */
28 MesonDep3 *
29 meson_dep3_new (const gchar *msg)
30 {
31 g_return_val_if_fail (msg != NULL, NULL);
32
33 return g_object_new (MESON_TYPE_DEP3,
34 "message", msg,
35 NULL);
36 }
37
38 static void
39 meson_dep3_finalize (GObject *object)
40 {
41 MesonDep3 *self = (MesonDep3 *)object;
42
43 g_clear_pointer (&self->msg, g_free);
44
45 G_OBJECT_CLASS (meson_dep3_parent_class)->finalize (object);
46 }
47
48 static void
49 meson_dep3_get_property (GObject *object,
50 guint prop_id,
51 GValue *value,
52 GParamSpec *pspec)
53 {
54 MesonDep3 *self = MESON_DEP3 (object);
55
56 switch (prop_id)
57 {
58 case PROP_MSG:
59 g_value_set_string (value, self->msg);
60 break;
61 default:
62 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
63 }
64 }
65
66 static void
67 meson_dep3_set_property (GObject *object,
68 guint prop_id,
69 const GValue *value,
70 GParamSpec *pspec)
71 {
72 MesonDep3 *self = MESON_DEP3 (object);
73
74 switch (prop_id)
75 {
76 case PROP_MSG:
77 self->msg = g_value_dup_string (value);
78 break;
79 default:
80 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
81 }
82 }
83
84 static void
85 meson_dep3_class_init (MesonDep3Class *klass)
86 {
87 GObjectClass *object_class = G_OBJECT_CLASS (klass);
88
89 object_class->finalize = meson_dep3_finalize;
90 object_class->get_property = meson_dep3_get_property;
91 object_class->set_property = meson_dep3_set_property;
92
93 gParamSpecs [PROP_MSG] =
94 g_param_spec_string ("message",
95 "Message",
96 "The message to print.",
97 NULL,
98 (G_PARAM_READWRITE |
99 G_PARAM_CONSTRUCT_ONLY |
100 G_PARAM_STATIC_STRINGS));
101
102 g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
103 }
104
105 static void
106 meson_dep3_init (MesonDep3 *self)
107 {
108 }
109
110 /**
111 * meson_dep3_return_message:
112 * @self: a #MesonDep3.
113 *
114 * Returns the message.
115 *
116 * Returns: (transfer none): a const gchar*
117 */
118 const gchar*
119 meson_dep3_return_message (MesonDep3 *self)
120 {
121 g_return_val_if_fail (MESON_IS_DEP3 (self), NULL);
122
123 return (const gchar*) self->msg;
124 }