/+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/animal.h

  • 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
#pragma once
 
2
 
 
3
#include <glib.h>
 
4
#include <glib-object.h>
 
5
 
 
6
G_BEGIN_DECLS
 
7
 
 
8
typedef struct _TestAnimal TestAnimal;
 
9
typedef struct _TestAnimalClass TestAnimalClass;
 
10
// typedef struct _TestAnimalPrivate TestAnimalPrivate;
 
11
 
 
12
 
 
13
#define TEST_TYPE_ANIMAL test_animal_get_type ()
 
14
//NEW STYLE
 
15
G_DECLARE_DERIVABLE_TYPE (TestAnimal, test_animal, TEST, ANIMAL, GObject)
 
16
 
 
17
/*
 
18
// OLD STYLE: This is how we used to do this. This has some advantages over
 
19
// the new style, in that the instance structure could be changed and have
 
20
// public variabels that way. This has been replaced with properties instead.
 
21
// We will come to that later.
 
22
#define TEST_TYPE_ANIMAL (test_animal_get_type ())
 
23
#define TEST_ANIMAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_ANIMAL, TestAnimal))
 
24
#define TEST_IS_ANIMAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_ANIMAL))
 
25
#define TEST_ANIMAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_ANIMAL, TestAnimalClass))
 
26
#define TEST_ANIMAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_ANIMAL))
 
27
#define TEST_ANIMAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_ANIMAL, TestAnimalClass))
 
28
 
 
29
struct _TestAnimal {
 
30
  GObject padding_instance;
 
31
  
 
32
  gpointer padding[8];
 
33
};
 
34
*/
 
35
 
 
36
struct _TestAnimalClass {
 
37
  GObjectClass parent_class;
 
38
  
 
39
  void (* make_sound)(TestAnimal *);
 
40
  
 
41
  void (* move)(TestAnimal *, gint, gint);
 
42
  
 
43
  gpointer padding[8];
 
44
};
 
45
 
 
46
 
 
47
TestAnimal *
 
48
test_animal_new ();
 
49
 
 
50
void
 
51
test_animal_make_sound (TestAnimal * self);
 
52
 
 
53
void
 
54
test_animal_move (TestAnimal * self, gint x, gint y);
 
55
 
 
56
 
 
57
G_END_DECLS