Attachment 'gobject.xml'
Download 1 <?xml version='1.0' encoding='utf-8'?>
2 <snippets language="c">
3 <snippet>
4 <text><![CDATA[#ifndef __${1:NAME}_H__
5 #define __$1_H__
6
7 #include <${2:glib-object.h}>
8
9 G_BEGIN_DECLS
10
11 $<1:
12 global camel_str
13 components = $1.split('_')
14 type_str = '_'.join([components[0], 'TYPE'] + components[1:])
15 is_str = '_'.join([components[0], 'IS'] + components[1:])
16 camel_str = ''
17
18 for t in components:
19 camel_str += t.capitalize()
20
21 items = [ \
22 ['#define ' + type_str, '(' + $1.lower() + '_get_type ())'], \
23 ['#define ' + $1 + '(obj)', '(G_TYPE_CHECK_INSTANCE_CAST ((obj), ' + type_str + ', ' + camel_str + '))'], \
24 ['#define ' + $1 + '_CONST(obj)', '(G_TYPE_CHECK_INSTANCE_CAST ((obj), ' + type_str + ', ' + camel_str + ' const))'], \
25 ['#define ' + $1 + '_CLASS(klass)', '(G_TYPE_CHECK_CLASS_CAST ((klass), ' + type_str + ', ' + camel_str + 'Class))'], \
26 ['#define ' + is_str + '(obj)', '(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ' + type_str + '))'], \
27 ['#define ' + is_str + '_CLASS(klass)', '(G_TYPE_CHECK_CLASS_TYPE ((klass), ' + type_str + '))'], \
28 ['#define ' + $1 + '_GET_CLASS(obj)', '(G_TYPE_INSTANCE_GET_CLASS ((obj), ' + type_str + ', ' + camel_str + 'Class))']
29 ]
30
31 return align(items) >
32
33 $<1:
34 items = [ \
35 ['typedef struct _' + camel_str, camel_str + ';'], \
36 ['typedef struct _' + camel_str + 'Class', camel_str + 'Class;'], \
37 ['typedef struct _' + camel_str + 'Private', camel_str + 'Private;'] \
38 ]
39
40 return align(items) >
41
42 struct _$<1: return camel_str > {
43 ${7:GObject} parent;
44
45 $<1: return camel_str >Private *priv;
46 };
47
48 struct _$<1: return camel_str >Class {
49 $7Class parent_class;
50 };
51
52 GType $<1: return $1.lower() + '_get_type' > (void) G_GNUC_CONST;
53 $<1: return camel_str > *$<1:return $1.lower()>_new(void);
54
55 $0
56
57 G_END_DECLS
58
59 #endif /* __$1_H__ */]]></text>
60 <tag>gtemp</tag>
61 <description>GObject template</description>
62 </snippet>
63 </snippets>
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.