2 * This file is a basic example of how a .gob file would be constructed,
3 * how to add data members, properties and methods
10 #include "my-person-private.h"
13 class My:Person from G:Object {
14 /* the name of the person */
15 private char *name = {g_strdup("Nobody")}
19 blurb = "Name of the person",
20 default_value = "Nobody",
21 /* Export get/set functions for this property */
23 /* link to the data memeber 'name' */
26 /* date of birth as a time_t */
29 (nick = "Date of birth",
30 blurb = "Date of birth of the person",
35 /* We could use 'link' as above, but the code below
36 * shows how to do this without linking */
38 self->_priv->dob = g_value_get_long (VAL);
41 g_value_set_long (VAL, self->_priv->dob);
44 /* date of death as a time_t */
47 (nick = "Date of death",
48 blurb = "Date of death of the person",
55 /* number of rounds in our shotgun */
56 private int rounds_in_shotgun = 0;
58 /* when the person gets born, sends out a signal, the caller
59 of the signal should provide the date of birth */
60 signal last NONE (LONG)
62 birth (self, long dob)
64 g_object_set (G_OBJECT (self),
69 /* when the person dies, sends out a signal, the caller
70 of the signal should provide the date of death */
71 signal last NONE (LONG)
73 death (self, long dod)
75 g_object_set (G_OBJECT (self),
84 /* add a round to our shotgun */
85 self->_priv->rounds_in_shotgun++;
90 shoot_oneself_in_the_head (self)
92 if (self->_priv->rounds_in_shotgun == 0) {
93 g_warning ("No rounds in the shotgun!");
97 /* one round was fired */
98 self->_priv->rounds_in_shotgun--;
100 /* death is imminent if we shoot oneself in the head */
101 self_death (self, (long)time (NULL));
107 return (GObject *)GET_NEW;