File: mg-base.c

package info (click to toggle)
mergeant 0.52-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,872 kB
  • ctags: 6,584
  • sloc: ansic: 63,372; xml: 23,218; sh: 10,895; makefile: 612; sql: 237
file content (752 lines) | stat: -rw-r--r-- 17,993 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
/* mg-base.c
 *
 * Copyright (C) 2003 Vivien Malerba
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#include <string.h>
#include "mg-base.h"
#include "marshal.h"
#include "mg-conf.h"

/* 
 * Main static functions 
 */
static void mg_base_class_init (MgBaseClass * class);
static void mg_base_init (MgBase * srv);
static void mg_base_dispose (GObject   * object);
static void mg_base_finalize (GObject   * object);

static void mg_base_set_property    (GObject              *object,
				    guint                 param_id,
				    const GValue         *value,
				    GParamSpec           *pspec);
static void mg_base_get_property    (GObject              *object,
				    guint                 param_id,
				    GValue               *value,
				    GParamSpec           *pspec);

/* get a pointer to the parents to be able to call their destructor */
static GObjectClass  *parent_class = NULL;

/* signals */
enum
{
	CHANGED,
	ID_CHANGED,
	NAME_CHANGED,
	DESCR_CHANGED,
	OWNER_CHANGED,
	NULLIFIED,
	LAST_SIGNAL
};

static gint mg_base_signals[LAST_SIGNAL] = { 0, 0, 0, 0};

/* properties */
enum
{
	PROP_0,
	PROP_CONF,
	PROP_BLOCK_CHANGED
};


struct _MgBasePrivate
{
	MgConf            *conf;     /* property: NOT NULL to use MgBase object */
	guint              id;	     /* 0 or UNIQUE, comes from ConfManager->id_serial */

	gchar             *name;
	gchar             *descr;
	gchar             *owner;
	
	gboolean           nullified;/* TRUE if the object has been "nullified" */
	gboolean           changed_locked;
};

guint
mg_base_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (MgBaseClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mg_base_class_init,
			NULL,
			NULL,
			sizeof (MgBase),
			0,
			(GInstanceInitFunc) mg_base_init
		};
		
		type = g_type_register_static (G_TYPE_OBJECT, "MgBase", &info, 0);
	}
	return type;
}

static void
mg_base_class_init (MgBaseClass * class)
{
	GObjectClass   *object_class = G_OBJECT_CLASS (class);

	parent_class = g_type_class_peek_parent (class);

	mg_base_signals[CHANGED] =
		g_signal_new ("changed",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, changed),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	mg_base_signals[NAME_CHANGED] =
		g_signal_new ("name_changed",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, name_changed),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	mg_base_signals[ID_CHANGED] =
		g_signal_new ("id_changed",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, id_changed),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	mg_base_signals[DESCR_CHANGED] =
		g_signal_new ("descr_changed",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, descr_changed),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	mg_base_signals[OWNER_CHANGED] =
		g_signal_new ("owner_changed",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, owner_changed),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	mg_base_signals[NULLIFIED] =
		g_signal_new ("nullified",
			      G_TYPE_FROM_CLASS (object_class),
			      G_SIGNAL_RUN_FIRST,
			      G_STRUCT_OFFSET (MgBaseClass, nullified),
			      NULL, NULL,
			      marshal_VOID__VOID, G_TYPE_NONE,
			      0);
	class->changed = NULL;
	class->name_changed = mg_base_changed;
	class->id_changed = mg_base_changed;
	class->descr_changed = mg_base_changed;
	class->owner_changed = mg_base_changed;
	class->nullified = NULL;


	/* virtual functions */
	class->nullify = NULL;
	class->signal_changed = NULL;
#ifdef debug
	class->dump = NULL;
#endif

	object_class->dispose = mg_base_dispose;
	object_class->finalize = mg_base_finalize;

	/* Properties */
	object_class->set_property = mg_base_set_property;
	object_class->get_property = mg_base_get_property;
	g_object_class_install_property (object_class, PROP_CONF,
					 g_param_spec_pointer ("conf", NULL, NULL, (G_PARAM_READABLE | G_PARAM_WRITABLE)));
	g_object_class_install_property (object_class, PROP_BLOCK_CHANGED,
                                         g_param_spec_boolean ("changed_blocked", NULL, NULL, FALSE,
                                                               G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
mg_base_init (MgBase * base)
{
	base->priv = g_new0 (MgBasePrivate, 1);
	base->priv->conf = NULL;
	base->priv->nullified = FALSE;
	base->priv->id = 0;

	base->priv->name = NULL;
	base->priv->descr = NULL;
	base->priv->owner = NULL;

	base->priv->changed_locked = FALSE;
}

/**
 * mg_base_new
 *
 * Creates a new MgBase object. This object class is normally not instantiated
 * directly but through child classes objects' intantiation
 * 
 * Returns: the newly created object
 */
GObject   *
mg_base_new ()
{
	GObject   *obj;

	MgBase *base;
	obj = g_object_new (MG_BASE_TYPE, NULL);
	base = MG_BASE (obj);

	return obj;
}


static void
mg_base_dispose (GObject   * object)
{
	MgBase *base;

	g_return_if_fail (object != NULL);
	g_return_if_fail (IS_MG_BASE (object));

	base = MG_BASE (object);
	if (base->priv) {
		if (! base->priv->nullified)
			mg_base_nullify (base);

		if (base->priv->conf) {
			g_object_remove_weak_pointer (G_OBJECT (base->priv->conf),
						      (gpointer) & (base->priv->conf));
			base->priv->conf = NULL;
		}
	}

	/* parent class */
	parent_class->dispose (object);
}

static void
mg_base_finalize (GObject   * object)
{
	MgBase *base;

	g_return_if_fail (object != NULL);
	g_return_if_fail (IS_MG_BASE (object));

	base = MG_BASE (object);
	if (base->priv) {
		if (! base->priv->nullified) {
			g_warning ("MgBase::finalize(%p) not nullified!\n", base);
		}

		if (base->priv->name)
			g_free (base->priv->name);
		if (base->priv->descr)
			g_free (base->priv->descr);
		if (base->priv->owner)
			g_free (base->priv->owner);

		g_free (base->priv);
		base->priv = NULL;
	}

	/* parent class */
	parent_class->finalize (object);
}


static void 
mg_base_set_property (GObject              *object,
		      guint                 param_id,
		      const GValue         *value,
		      GParamSpec           *pspec)
{
	gpointer ptr;
	MgBase *base;

	base = MG_BASE (object);
	if (base->priv) {
		switch (param_id) {
		case PROP_CONF:
			ptr = g_value_get_pointer (value);
			mg_base_set_conf (base, MG_CONF (ptr));
			break;
		case PROP_BLOCK_CHANGED:
			if (g_value_get_boolean (value))
				mg_base_block_changed (base);
			else
				mg_base_unblock_changed (base);
		}
	}
}

static void
mg_base_get_property (GObject              *object,
		      guint                 param_id,
		      GValue               *value,
		      GParamSpec           *pspec)
{
	MgBase *base;

	base = MG_BASE (object);
	if (base->priv) {
		switch (param_id) {
		case PROP_CONF:
			g_value_set_pointer (value, base->priv->conf);
			break;
		case PROP_BLOCK_CHANGED:
			g_value_set_boolean (value, base->priv->changed_locked);
		}
	}
}

/**
 * mg_base_set_conf
 * @base: a #MgBase object
 * @conf: the #MgConf to which @base is attached
 * 
 * Sets the #MgConf to which @base is attached to. It has no other
 * action than to store it to easily be able to retreive it.
 */
void
mg_base_set_conf (MgBase *base, MgConf *conf)
{
	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);
	g_return_if_fail (conf && IS_MG_CONF (conf));

	if (base->priv->conf) {
		g_object_remove_weak_pointer (G_OBJECT (base->priv->conf),
					      (gpointer) & (base->priv->conf));
		base->priv->conf = NULL;
	}

	base->priv->conf = conf;
	g_object_add_weak_pointer (G_OBJECT (base->priv->conf),
				   (gpointer) & (base->priv->conf));
}

/**
 * mg_base_get_conf
 * @base: a #MgBase object
 *
 * Fetch the corresponding #MgConf object.
 *
 * Returns: the #MgConf object to which @base is attached to
 */ 
MgConf *
mg_base_get_conf (MgBase *base)
{
	g_return_val_if_fail (base && IS_MG_BASE (base), NULL);
	g_return_val_if_fail (base->priv, NULL);

	return base->priv->conf;
}


/**
 * mg_base_set_id
 * @base: a #MgBase object
 * @id: 
 * 
 * Sets the id of the object. The id is set to 0 by default (which means the object does
 * not use the id at all).
 * WARNING: the id is not checked which means no search is
 * made to see if the id is already used
 */
void
mg_base_set_id (MgBase *base, guint id)
{
	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	if (base->priv->id != id) {
		base->priv->id = id;
#ifdef debug_signal
		g_print (">> 'ID_CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
		g_signal_emit (G_OBJECT (base), mg_base_signals[ID_CHANGED], 0);
#ifdef debug_signal
		g_print ("<< 'ID_CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
	}
}

/**
 * mg_base_set_name
 * @base: a #MgBase object
 * @name: 
 *
 * Sets the name of the MgBase object. If the name is changed, then the 
 * "name_changed" signal is emitted.
 * 
 */
void
mg_base_set_name (MgBase *base, const gchar *name)
{
	gboolean changed = FALSE;

	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	if (name) {
		if (base->priv->name) {
			changed = strcmp (base->priv->name, name) ? TRUE : FALSE;
			g_free (base->priv->name);
		}
		else
			changed = TRUE;
		base->priv->name = g_strdup (name);
	}

	if (changed) {
#ifdef debug_signal
		g_print (">> 'NAME_CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
		g_signal_emit (G_OBJECT (base), mg_base_signals[NAME_CHANGED], 0);
#ifdef debug_signal
		g_print ("<< 'NAME_CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
	}
}


/**
 * mg_base_set_description
 * @base: a #MgBase object
 * @descr: 
 *
 * Sets the description of the MgBase object. If the description is changed, then the 
 * "descr_changed" signal is emitted.
 * 
 */
void
mg_base_set_description (MgBase *base, const gchar *descr)
{
	gboolean changed = FALSE;

	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	if (descr) {
		if (base->priv->descr) {
			changed = strcmp (base->priv->descr, descr) ? TRUE : FALSE;
			g_free (base->priv->descr);
		}
		else
			changed = TRUE;
		base->priv->descr = g_strdup (descr);
	}

	if (changed) {
#ifdef debug_signal
		g_print (">> 'DESCR_CHANGED' from mg_base_set_descr (%s)\n", base->priv->descr);
#endif
		g_signal_emit (G_OBJECT (base), mg_base_signals[DESCR_CHANGED], 0);
#ifdef debug_signal
		g_print ("<< 'DESCR_CHANGED' from mg_base_set_descr (%s)\n", base->priv->descr);
#endif
	}
}


/**
 * mg_base_set_owner
 * @base: a #MgBase object
 * @owner: 
 *
 * Sets the owner of the MgBase object. If the owner is changed, then the 
 * "owner_changed" signal is emitted.
 * 
 */
void
mg_base_set_owner (MgBase *base, const gchar *owner)
{
	gboolean changed = FALSE;

	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	if (owner) {
		if (base->priv->owner) {
			changed = strcmp (base->priv->owner, owner) ? TRUE : FALSE;
			g_free (base->priv->owner);
		}
		else
			changed = TRUE;
		base->priv->owner = g_strdup (owner);
	}

	if (changed) {
#ifdef debug_signal
		g_print (">> 'OWNER_CHANGED' from mg_base_set_descr (%s)\n", base->priv->descr);
#endif
		g_signal_emit (G_OBJECT (base), mg_base_signals[OWNER_CHANGED], 0);
#ifdef debug_signal
		g_print ("<< 'OWNER_CHANGED' from mg_base_set_descr (%s)\n", base->priv->descr);
#endif
	}
}

/**
 * mg_base_get_id
 * @base: a #MgBase object
 * 
 * Fetch the id of the MgBase object.
 * 
 * Returns: the id.
 */
guint
mg_base_get_id (MgBase *base)
{
	g_return_val_if_fail (base && IS_MG_BASE (base), 0);
	g_return_val_if_fail (base->priv, 0);
		
	return base->priv->id;
}


/**
 * mg_base_get_name
 * @base: a #MgBase object
 * 
 * Fetch the name of the MgBase object.
 * 
 * Returns: the object's name.
 */
const gchar *
mg_base_get_name (MgBase *base)
{
	g_return_val_if_fail (base && IS_MG_BASE (base), NULL);
	g_return_val_if_fail (base->priv, NULL);

	return base->priv->name;
}


/**
 * mg_base_get_description
 * @base: a #MgBase object
 * 
 * Fetch the description of the MgBase object.
 * 
 * Returns: the object's description.
 */
const gchar *
mg_base_get_description (MgBase *base)
{
	g_return_val_if_fail (base && IS_MG_BASE (base), NULL);
	g_return_val_if_fail (base->priv, NULL);

	return base->priv->descr;
}

/**
 * mg_base_get_owner
 * @base: a #MgBase object
 * 
 * Fetch the owner of the MgBase object.
 * 
 * Returns: the object's owner.
 */
const gchar *
mg_base_get_owner (MgBase *base)
{
	g_return_val_if_fail (base && IS_MG_BASE (base), NULL);
	g_return_val_if_fail (base->priv, NULL);

	return base->priv->owner;
}



/**
 * mg_base_nullify
 * @base: a #MgBase object
 *
 * Force the @base object to be destroyed, even if we don't have a reference on it
 * (we can't call g_object_unref() then) and even if the object is referenced
 * multiple times by other objects.
 *
 * The "nullified" signal is then emitted to tell the other reference holders that the object
 * must be destroyed and that they should give back their reference (using g_object_unref()).
 * However if a reference is still present, the object will not actually be destroyed and will
 * still be alive, but its state may not be deterministic.
 *
 * This is usefull because sometimes objects need to disappear even if they are referenced by other
 * objects. This usage is the same as with the gtk_widget_destroy() function on widgets.
 */
void
mg_base_nullify (MgBase *base)
{
	g_return_if_fail (base && IS_MG_BASE (base));

	if (base->priv) {
		if (!base->priv->nullified) {
			MgBaseClass *class;
			class = MG_BASE_CLASS (G_OBJECT_GET_CLASS (base));

			base->priv->nullified = TRUE;
#ifdef debug_signal
			g_print (">> 'NULLIFIED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
			g_signal_emit (G_OBJECT (base), mg_base_signals[NULLIFIED], 0);
#ifdef debug_signal
			g_print ("<< 'NULLIFIED' from %p\n", base);
#endif

			if (class->nullify)
				(*class->nullify) (base);
		}
		else 
			g_warning ("MgBase::nullify called on already nullified object %p, "
				   "of type %s\n", base, G_OBJECT_TYPE_NAME (base));
	}
}

/**
 * mg_base_nullify_check
 * @base: a #MgBase object
 *
 * Checks that the object has been nullified, and if not, then calls mg_base_nullify() on it.
 * This is usefull for objects inheriting the #MGBase object to be called first line in their
 * dispose() method.
 */
void
mg_base_nullify_check (MgBase *base)
{
	g_return_if_fail (base && IS_MG_BASE (base));

	if (base->priv && !base->priv->nullified)
		mg_base_nullify (base);
}

/**
 * mg_base_changed
 * @base: a #MgBase object
 *
 * Force emission of the "changed" signal, except if mg_base_block_changed() has
 * been called.
 */
void
mg_base_changed (MgBase *base)
{
	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	if (base->priv->changed_locked)
		return;

#ifdef debug_signal
	g_print (">> 'CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
	g_signal_emit (G_OBJECT (base), mg_base_signals[CHANGED], 0);
#ifdef debug_signal
	g_print ("<< 'CHANGED' from %s %p\n", G_OBJECT_TYPE_NAME (base), base);
#endif
}

/**
 * mg_base_block_changed
 * @base: a #MgBase object
 *
 * No "changed" signal will be emitted.
 */
void
mg_base_block_changed (MgBase *base)
{
	MgBaseClass *class;

	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	base->priv->changed_locked = TRUE;

	class = MG_BASE_CLASS (G_OBJECT_GET_CLASS (base));
	if (class->signal_changed)
		(*class->signal_changed) (base, TRUE);
}

/**
 * mg_base_unblock_changed
 * @base: a #MgBase object
 *
 * The "changed" signal will again be emitted.
 */
void
mg_base_unblock_changed (MgBase *base)
{
	MgBaseClass *class;

	g_return_if_fail (base && IS_MG_BASE (base));
	g_return_if_fail (base->priv);

	base->priv->changed_locked = FALSE;

	class = MG_BASE_CLASS (G_OBJECT_GET_CLASS (base));
	if (class->signal_changed)
		(*class->signal_changed) (base, FALSE);
}

#ifdef debug
/**
 * mg_base_dump
 * @base: a #MgBase object
 * @offset: the offset (in caracters) at which the dump will start
 *
 * Writes a textual description of the object to STDOUT. This function only
 * exists if libergeant is compiled with the "--enable-debug" option. This is
 * a virtual function.
 */
void
mg_base_dump (MgBase *base, guint offset)
{
	gchar *str;
	guint i;

	g_return_if_fail (base);
	g_return_if_fail (IS_MG_BASE (base));

	/* string for the offset */
	str = g_new0 (gchar, offset+1);
        for (i=0; i<offset; i++)
                str[i] = ' ';
        str[offset] = 0;
	
	/* dump */
	if (base->priv) {
		MgBaseClass *class;
		class = MG_BASE_CLASS (G_OBJECT_GET_CLASS (base));
		if (class->dump)
			(class->dump) (base, offset);
		else 
			g_print ("%s" D_COL_H1 "%s %p (name=%s, id=%d)\n" D_COL_NOR, 
				 str, G_OBJECT_TYPE_NAME (base), base, base->priv->name,
				 base->priv->id);
	}
	else
		g_print ("%s" D_COL_ERR "Using finalized object %p" D_COL_NOR, str, base);

	g_free (str);
}
#endif