3 /* This will work with an older version (0.92.1 specifically), if you want
4 * to see a version with automatic argument<->datamember linking, automatic
5 * initialization and destruction, look at my-person2.gob */
10 #include "my-person-private.h"
13 class My:Person from Gtk:Object {
15 public long dob; /* date of birth as a time_t */
16 public long dod; /* date of death as a time_t */
18 private int rounds_in_shotgun; /* number of rounds in our shotgun */
20 argument POINTER (type char *) name
22 /* note that strdup handles NULL correctly */
23 ARG = g_strdup(self->name);
26 /* note that strdup handles NULL correctly */
28 self->name = g_strdup(ARG);
31 argument LONG dob get { ARG = self->dob; } set { self->dob = ARG; };
32 argument LONG dod get { ARG = self->dod; } set { self->dod = ARG; };
36 self->name = g_strdup("Nobody");
40 /* initially we have no rounds in the shotgun */
41 self->_priv->rounds_in_shotgun = 0;
44 /* when the person gets born, sends out a signal, the caller
45 of the signal should provide the date of birth */
46 signal last NONE (LONG)
53 /* when the person dies, sends out a signal, the caller
54 of the signal should provide the date of death */
55 signal last NONE (LONG)
66 /* add a round to our shotgun */
67 self->_priv->rounds_in_shotgun++;
72 shoot_oneself_in_the_head(self)
74 if(self->_priv->rounds_in_shotgun==0) {
75 g_warning("No rounds in the shotgun!");
79 /* one round was fired */
80 self->_priv->rounds_in_shotgun--;
82 /* death is imminent if we shoot oneself in the head */
83 death(self, (long)time(NULL));
86 /* override the destroy signal where we destroy data we need to free */
89 destroy (Gtk:Object *self (check null type))
91 g_free(MY_PERSON(self)->name);
98 return (GtkObject *)GET_NEW;