Debian Codegraph @

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

raw
1 #include "meson-sample.h"
2
3 struct _MesonSample
4 {
5 GObject parent_instance;
6
7 gchar *msg;
8 };
9
10 G_DEFINE_TYPE (MesonSample, meson_sample, 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_sample_new:
22 *
23 * Allocates a new #MesonSample.
24 *
25 * Returns: (transfer full): a #MesonSample.
26 */
27 MesonSample *
28 meson_sample_new (void)
29 {
30 return g_object_new (MESON_TYPE_SAMPLE, NULL);
31 }
32
33 static void
34 meson_sample_finalize (GObject *object)
35 {
36 MesonSample *self = (MesonSample *)object;
37
38 g_clear_pointer (&self->msg, g_free);
39
40 G_OBJECT_CLASS (meson_sample_parent_class)->finalize (object);
41 }
42
43 static void
44 meson_sample_get_property (GObject *object,
45 guint prop_id,
46 GValue *value,
47 GParamSpec *pspec)
48 {
49 MesonSample *self = MESON_SAMPLE (object);
50
51 switch (prop_id)
52 {
53 case PROP_MSG:
54 g_value_set_string (value, self->msg);
55 break;
56 default:
57 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
58 }
59 }
60
61 static void
62 meson_sample_set_property (GObject *object,
63 guint prop_id,
64 const GValue *value,
65 GParamSpec *pspec)
66 {
67 MesonSample *self = MESON_SAMPLE (object);
68
69 switch (prop_id)
70 {
71 case PROP_MSG:
72 self->msg = g_value_dup_string (value);
73 break;
74 default:
75 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
76 }
77 }
78
79 static void
80 meson_sample_class_init (MesonSampleClass *klass)
81 {
82 GObjectClass *object_class = G_OBJECT_CLASS (klass);
83
84 object_class->finalize = meson_sample_finalize;
85 object_class->get_property = meson_sample_get_property;
86 object_class->set_property = meson_sample_set_property;
87
88 gParamSpecs [PROP_MSG] =
89 g_param_spec_string ("message",
90 "Message",
91 "The message to print.",
92 NULL,
93 (G_PARAM_READWRITE |
94 G_PARAM_CONSTRUCT_ONLY |
95 G_PARAM_STATIC_STRINGS));
96
97 g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
98 }
99
100 static void
101 meson_sample_init (MesonSample *self)
102 {
103 }
104
105 /**
106 * meson_sample_print_message:
107 * @self: a #MesonSample.
108 *
109 * Prints the message.
110 *
111 * Returns: Nothing.
112 */
113 void
114 meson_sample_print_message (MesonSample *self, MesonDep1 *dep1, MesonDep2 *dep2)
115 {
116 MesonDep2 *samedep;
117 g_return_if_fail (MESON_IS_SAMPLE (self));
118
119 samedep = meson_dep1_just_return_it (dep1, dep2);
120 g_print ("Message: %s\n", meson_dep2_return_message (samedep));
121 }