4
#include "${1:$filename|stripsuffix}.h"
9
} ${2:$1|camelize}Private;
11
G_DEFINE_TYPE_WITH_PRIVATE ($2, ${3:$1|functify}, ${4:G_TYPE_OBJECT})
18
static GParamSpec *gParamSpecs [LAST_PROP];
23
return g_object_new (${$1|namespace|functify|upper}_TYPE_${$1|class|functify|upper}, NULL);
27
$3_finalize (GObject *object)
29
$2 *self = ($2 *)object;
30
$2Private *priv = $3_get_instance_private (self);
32
G_OBJECT_CLASS ($3_parent_class)->finalize (object);
36
$3_get_property (GObject *object,
37
${$3|space} guint prop_id,
38
${$3|space} GValue *value,
39
${$3|space} GParamSpec *pspec)
41
$2 *self = ${$3|upper} (object);
46
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
51
$3_set_property (GObject *object,
52
${$3|space} guint prop_id,
53
${$3|space} const GValue *value,
54
${$3|space} GParamSpec *pspec)
56
$2 *self = ${$3|upper} (object);
61
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
66
$3_class_init ($2Class *klass)
68
GObjectClass *object_class = G_OBJECT_CLASS (klass);
70
object_class->finalize = $3_finalize;
71
object_class->get_property = $3_get_property;
72
object_class->set_property = $3_set_property;
80
- desc Create GObject header
81
#ifndef ${$1|functify|upper}_H
82
#define ${$1|functify|upper}_H
84
#include ${3:<glib-object.h>}
88
#define ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper} (${$1|functify}_get_type())
90
G_DECLARE_DERIVABLE_TYPE (${1:$filename|stripsuffix|camelize}, ${$1|functify}, ${$1|functify|namespace|upper}, ${$1|class|functify|upper}, ${2:GObject})
97
$1 *${$1|functify}_new (void);
101
#endif /* ${$1|functify|upper}_H */
104
#ifndef ${1:$filename|stripsuffix|functify|upper}_H
116
snippet gobj_interface
118
- desc Create GObject Interface
119
#include "${1:$filename|stripsuffix}.h"
121
G_DEFINE_INTERFACE (${2:$1|camelize}, ${3:$1|functify}, ${4:G_TYPE_OBJECT})
124
$3_default_init ($2Interface *iface)
128
- desc Create GObject Interface header
129
#ifndef ${$1|functify|upper}_H
130
#define ${$1|functify|upper}_H
132
#include <glib-object.h>
136
#define ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper} (${$1|functify}_get_type ())
137
#define ${$1|functify|namespace|upper}_${$1|class|functify|upper}(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}, $1))
138
#define ${$1|functify|namespace|upper}_IS_${$1|class|functify|upper}(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}))
139
#define ${$1|functify|namespace|upper}_${$1|class|functify|upper}_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ${$1|functify|namespace|upper}_TYPE_${$1|class|functify|upper}, $1Interface))
141
typedef struct _$1 $1;
142
typedef struct _$1Interface $1Interface;
144
struct _${1:$filename|stripsuffix|functify|camelize}Interface
146
GTypeInterface parent;
149
GType ${$1|functify}_get_type (void);
153
#endif /* ${$1|functify|upper}_H */
157
g_object_ref (${1});$0
161
g_object_unref (${1});$0
165
g_clear_object (&${1});$0
168
- desc Add GObject property
169
gParamSpecs [PROP_${1:NAME}] =
170
g_param_spec_${2:object} ("${3:$1|lower}",
171
${$2|space} _("${4:$3|camelize}"),
172
${$2|space} _("${5:$3|camelize}"),
174
${$2|space} (G_PARAM_${7:READWRITE} |
175
${$2|space} G_PARAM_STATIC_STRINGS));
176
g_object_class_install_property (object_class, PROP_$1,
177
gParamSpecs [PROP_$1]);
180
- desc Add GObject signal
181
gSignals [${$1|functify|upper}] =
182
g_signal_new ("${1:name}",
183
G_TYPE_FROM_CLASS (klass),
184
${2:G_SIGNAL_RUN_LAST},
188
${6:g_cclosure_marshal_generic},
194
${$2|functify}_${1:do_something}_async (${2:$filename|stripsuffix|camelize} *self,
195
${$2|space} ${$1|space} GCancellable *cancellable,
196
${$2|space} ${$1|space} GAsyncReadyCallback callback,
197
${$2|space} ${$1|space} gpointer user_data)
199
g_autoptr(GTask) task = NULL;
201
g_return_if_fail (${$filename|stripsuffix|functify|namespace|upper}_IS_${$filename|stripsuffix|class|functify|upper} (self));
202
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
204
task = g_task_new (self, cancellable, callback, user_data);
211
${$2|functify}_${1:do_something}_finish (${2:$filename|stripsuffix|camelize} *self,
212
${$2|space} ${$1|space} GAsyncResult *result,
213
${$2|space} ${$1|space} GError **error)
215
GTask *task = (GTask *)result;
217
g_return_val_if_fail (${$filename|stripsuffix|functify|namespace|upper}_IS_${$filename|stripsuffix|class|functify|upper} (self), ${3:FALSE});
219
return g_task_propagate_${4:boolean} (task, error);