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
|
#include "animal.h"
G_DEFINE_TYPE (TestAnimal, test_animal, G_TYPE_OBJECT)
//G_DEFINE_TYPE_WITH_PRIVATE (TestAnimal, test_animal, G_TYPE_OBJECT)
/*
struct _TestAnimalPrivate {
};
*/
/******************************************************************************/
void
test_animal_real_make_sound (TestAnimal * self);
void
test_animal_real_move (TestAnimal * self, gint x, gint y);
/******************************************************************************/
TestAnimal *
test_animal_new () {
return g_object_new (TEST_TYPE_ANIMAL, NULL);
}
static void
test_animal_init (TestAnimal * self) {
}
static void
test_animal_class_init (TestAnimalClass * klass) {
GObjectClass * obj_class = G_OBJECT_CLASS (klass);
klass->make_sound = test_animal_real_make_sound;
klass->move = test_animal_real_move;
}
void
test_animal_make_sound (TestAnimal * self) {
g_return_if_fail (TEST_IS_ANIMAL (self));
TestAnimalClass * klass = TEST_ANIMAL_GET_CLASS (self);
klass->make_sound (self);
}
void
test_animal_move (TestAnimal * self, gint x, gint y) {
g_return_if_fail (TEST_IS_ANIMAL (self));
TestAnimalClass * klass = TEST_ANIMAL_GET_CLASS (self);
klass->move (self, x, y);
}
/******************************************************************************/
void
test_animal_real_make_sound (TestAnimal * self) {
g_print ("This animal can't make a sound... :-( \n");
}
void
test_animal_real_move (TestAnimal * self, gint x, gint y) {
g_print ("This animal can't move to %i, %i... :-( \n", x, y);
}
|