/+junk/GObject_tutorial

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/GObject_tutorial
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
#include "cat.h"


struct _TestCat {
  TestAnimal parent;
};

G_DEFINE_TYPE (TestCat, test_cat, TEST_TYPE_ANIMAL)

/******************************************************************************/
void
test_cat_real_make_sound (TestCat * self);

void
test_cat_real_move (TestCat * self, gint x, gint y);

/******************************************************************************/
TestCat *
test_cat_new () {
  return g_object_new (TEST_TYPE_CAT, NULL);
}

static void
test_cat_init (TestCat * self) {
  
}

static void
test_cat_class_init (TestCatClass * klass) {
  TestAnimalClass * animal_class = TEST_ANIMAL_CLASS (klass);
  animal_class->make_sound = test_cat_real_make_sound;
  animal_class->move = test_cat_real_move;
}

/******************************************************************************/
void
test_cat_real_make_sound (TestCat * self) {
  g_print ("The cat says \"meew\" and \"rurururu\"\n");
}

void
test_cat_real_move (TestCat * self, gint x, gint y) {
  g_print ("The cat silently moves to (%i, %i).\n", x, y);
}