/+junk/GObject_tutorial

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/GObject_tutorial

« back to all changes in this revision

Viewing changes to pt1_animals_done/dog.c

  • Committer: Gustav Hartvigsson
  • Date: 2017-04-04 20:29:08 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20170404202908-37q4rzsskk2nzuaz
First lesson.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "dog.h"
 
2
 
 
3
 
 
4
struct _TestDog {
 
5
  TestAnimal parent;
 
6
};
 
7
 
 
8
G_DEFINE_TYPE (TestDog, test_dog, TEST_TYPE_ANIMAL)
 
9
 
 
10
/******************************************************************************/
 
11
void
 
12
test_dog_real_make_sound (TestDog * self);
 
13
 
 
14
void
 
15
test_dog_real_move (TestDog * self, gint x, gint y);
 
16
 
 
17
/******************************************************************************/
 
18
TestDog *
 
19
test_dog_new () {
 
20
  return g_object_new (TEST_TYPE_DOG, NULL);
 
21
}
 
22
 
 
23
static void
 
24
test_dog_init (TestDog * self) {
 
25
  
 
26
}
 
27
 
 
28
static void
 
29
test_dog_class_init (TestDogClass * klass) {
 
30
  TestAnimalClass * animal_class = TEST_ANIMAL_CLASS (klass);
 
31
  animal_class->make_sound = test_dog_real_make_sound;
 
32
  animal_class->move = test_dog_real_move;
 
33
}
 
34
 
 
35
/******************************************************************************/
 
36
void
 
37
test_dog_real_make_sound (TestDog * self) {
 
38
  g_print ("The dog says \"awoo!\" and \"Wa Wa Wa\"\n");
 
39
}
 
40
 
 
41
void
 
42
test_dog_real_move (TestDog * self, gint x, gint y) {
 
43
  g_print ("The dog runs around a bit and randomly ends up at (%i, %i).\n", x, y);
 
44
}