goc_template_source 2 KB
Newer Older
1 2 3 4 5 6
#include "{{HEADER_FILE_NAME}}"
 
static void {{FUNCTION_PREFIX}}_class_init({{BASE_CLASS}}Class *klass);
static void {{FUNCTION_PREFIX}}_init({{BASE_CLASS}} *sp);
static void {{FUNCTION_PREFIX}}_finalize(GObject *object);

7
struct _{{BASE_CLASS}}Private {
8 9 10
	/* Place Private Members Here */
};

11 12 13 14
typedef struct _{{BASE_CLASS}}Signal {{BASE_CLASS}}Signal;
typedef enum _{{BASE_CLASS}}SignalType {{BASE_CLASS}}SignalType;

enum _{{BASE_CLASS}}SignalType {
15 16 17
	/* Place Signal Types Here */
	SIGNAL_TYPE_EXAMPLE,
	LAST_SIGNAL
18
};
19

20
struct _{{BASE_CLASS}}Signal {
21
	{{BASE_CLASS}} *object;
22
};
23 24

static guint {{FUNCTION_PREFIX}}_signals[LAST_SIGNAL] = { 0 };
25
static {{PARENT_CLASS}}Class *parent_class = NULL;
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

GType
{{FUNCTION_PREFIX}}_get_type()
{
	static GType type = 0;

	if(type == 0) {
		static const GTypeInfo our_info = {
			sizeof ({{BASE_CLASS}}Class),
			NULL,
			NULL,
			(GClassInitFunc){{FUNCTION_PREFIX}}_class_init,
			NULL,
			NULL,
			sizeof ({{BASE_CLASS}}),
			0,
			(GInstanceInitFunc){{FUNCTION_PREFIX}}_init,
		};

		type = g_type_register_static(G_TYPE_OBJECT, 
			"{{BASE_CLASS}}", &our_info, 0);
	}

	return type;
}

static void
{{FUNCTION_PREFIX}}_class_init({{BASE_CLASS}}Class *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS(klass);

	parent_class = g_type_class_peek_parent(klass);
	object_class->finalize = {{FUNCTION_PREFIX}}_finalize;
	
	/* Create signals here:
	   {{FUNCTION_PREFIX}}_signals[SIGNAL_TYPE_EXAMPLE] = g_signal_new(...)
 	*/
}

static void
{{FUNCTION_PREFIX}}_init({{BASE_CLASS}} *obj)
{
	obj->priv = g_new0({{BASE_CLASS}}Private, 1);
	/* Initialize private members, etc. */
}

static void
{{FUNCTION_PREFIX}}_finalize(GObject *object)
{
	{{BASE_CLASS}} *cobj;
	cobj = {{GTYPE_PREFIX}}_{{GTYPE_NAME}}(object);
	
	/* Free private members, etc. */
		
	g_free(cobj->priv);
	G_OBJECT_CLASS(parent_class)->finalize(object);
}

{{BASE_CLASS}} *
{{FUNCTION_PREFIX}}_new()
{
	{{BASE_CLASS}} *obj;
	
	obj = {{GTYPE_PREFIX}}_{{GTYPE_NAME}}(g_object_new({{GTYPE_PREFIX}}_TYPE_{{GTYPE_NAME}}, NULL));
	
	return obj;
}