-
Notifications
You must be signed in to change notification settings - Fork 0
/
nc_object_name.c
173 lines (148 loc) · 4.02 KB
/
nc_object_name.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* SECTION:nc_object_name
* @title: NcObjectName
* @short_description: Object short description
* @include: nc_object_name.h
*
* Long description
*
*/
#include "nc_object_name.h"
struct _NcObjectName
{
/*< private >*/
GObject parent_instance;
};
typedef struct _NcObjectNamePrivate
{
gdouble private_double;
} NcObjectNamePrivate;
enum
{
PROP_0,
PROP_PROP1,
PROP_SIZE,
};
/* This object is a child of GObject */
G_DEFINE_TYPE_WITH_PRIVATE (NcObjectName, nc_object_name, G_TYPE_OBJECT);
static void
nc_object_name_init (NcObjectName *obj)
{
NcObjectNamePrivate * const self = nc_object_name_get_instance_private (obj);
self->private_double = 0.0;
}
static void
_nc_object_name_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
NcObjectName *obj = NC_OBJECT_NAME (object);
NcObjectNamePrivate * const self = nc_object_name_get_instance_private (obj);
g_return_if_fail (NC_IS_OBJECT_NAME (object));
switch (prop_id)
{
case PROP_PROP1:
self->private_double = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
_nc_object_name_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
NcObjectName *obj = NC_OBJECT_NAME (object);
NcObjectNamePrivate * const self = nc_object_name_get_instance_private (obj);
g_return_if_fail (NC_IS_OBJECT_NAME (object));
switch (prop_id)
{
case PROP_PROP1:
g_value_set_double (value, self->private_double);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
_nc_object_name_dispose (GObject *object)
{
/* Chain up : end */
G_OBJECT_CLASS (nc_object_name_parent_class)->dispose (object);
}
static void
_nc_object_name_finalize (GObject *object)
{
/* Chain up : end */
G_OBJECT_CLASS (nc_object_name_parent_class)->finalize (object);
}
static void
nc_object_name_class_init (NcObjectNameClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = &_nc_object_name_set_property;
object_class->get_property = &_nc_object_name_get_property;
object_class->dispose = &_nc_object_name_dispose;
object_class->finalize = &_nc_object_name_finalize;
g_object_class_install_property (object_class,
PROP_PROP1,
g_param_spec_double ("prop1",
NULL,
"This is prop is a double between (0.0, 1.0), default 0.5 ",
0.0, 1.0, 0.5,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
}
/* METHODS */
/**
* nc_object_name_new:
* @prop1: a value for prop1
*
* A simple constructor.
*
* Returns: (transfer full): a newly created #NcObjectName
*/
NcObjectName *
nc_object_name_new (gdouble prop1_val)
{
NcObjectName *nc_object_name = g_object_new (NC_TYPE_OBJECT_NAME,
"prop1", prop1_val,
NULL);
return nc_object_name;
}
/**
* nc_object_name_ref:
* @nc_object_name: a #NcObjectName
*
* Increase reference count by one.
*
* Returns: (transfer full): @nc_object_name.
*/
NcObjectName *
nc_object_name_ref (NcObjectName *nc_object_name)
{
return g_object_ref (nc_object_name);
}
/**
* nc_object_name_free:
* @nc_object_name: a #NcObjectName
*
* Decrease reference count by one.
*
*/
void
nc_object_name_free (NcObjectName *nc_object_name)
{
g_object_unref (nc_object_name);
}
/**
* nc_object_name_clear:
* @nc_object_name: a #NcObjectName
*
* Decrease reference count by one if *@nc_object_name != NULL
* and sets @nc_object_name to NULL.
*
*/
void
nc_object_name_clear (NcObjectName **nc_object_name)
{
g_clear_object (nc_object_name);
}