1 /* Fo
2  * fo-area_tree.c: Formatting object area_tree root
3  *
4  * Copyright (C) 2001 Sun Microsystems
5  * Copyright (C) 2007-2010 Menteith Consulting Ltd
6  *
7  * See COPYING for the status of this software.
8  */
9 
10 #include "fo-utils.h"
11 #include "fo-area.h"
12 #include "fo-area-private.h"
13 #include "fo-area-tree.h"
14 
15 
16 struct _FoAreaTree
17 {
18   FoArea parent_instance;
19 };
20 
21 struct _FoAreaTreeClass
22 {
23   FoAreaClass parent_class;
24 
25 };
26 
27 static void fo_area_tree_class_init  (FoAreaTreeClass *klass);
28 static void fo_area_tree_finalize    (GObject           *object);
29 static void fo_area_tree_debug_dump_properties (FoArea *area,
30 						gint depth);
31 
32 static gpointer parent_class;
33 
34 GType
fo_area_tree_get_type(void)35 fo_area_tree_get_type (void)
36 {
37   static GType object_type = 0;
38 
39   if (!object_type)
40     {
41       static const GTypeInfo object_info =
42       {
43         sizeof (FoAreaTreeClass),
44         (GBaseInitFunc) NULL,
45         (GBaseFinalizeFunc) NULL,
46         (GClassInitFunc) fo_area_tree_class_init,
47         NULL,           /* class_finalize */
48         NULL,           /* class_data */
49         sizeof (FoAreaTree),
50         0,              /* n_preallocs */
51         NULL,		/* instance_init */
52 	NULL		/* value_table */
53       };
54 
55       object_type = g_type_register_static (FO_TYPE_AREA,
56                                             "FoAreaTree",
57                                             &object_info, 0);
58     }
59 
60   return object_type;
61 }
62 
63 /**
64  * fo_area_tree_class_init:
65  * @klass: #FoAreaTreeClass object to initialise.
66  *
67  * Implements #GClassInitFunc for #FoAreaTreeClass.
68  **/
69 void
fo_area_tree_class_init(FoAreaTreeClass * klass)70 fo_area_tree_class_init (FoAreaTreeClass *klass)
71 {
72   GObjectClass *object_class = G_OBJECT_CLASS (klass);
73 
74   parent_class = g_type_class_peek_parent (klass);
75 
76   object_class->finalize = fo_area_tree_finalize;
77 
78   FO_AREA_CLASS (klass)->debug_dump_properties = fo_area_tree_debug_dump_properties;
79 }
80 
81 /**
82  * fo_area_tree_finalize:
83  * @object: #FoAreaTree object to finalize.
84  *
85  * Implements #GObjectFinalizeFunc for #FoAreaTree.
86  **/
87 void
fo_area_tree_finalize(GObject * object)88 fo_area_tree_finalize (GObject *object)
89 {
90   FoAreaTree *area_tree;
91 
92   area_tree = FO_AREA_TREE (object);
93 
94   fo_node_traverse (FO_NODE (area_tree),
95 		    G_POST_ORDER,
96 		    G_TRAVERSE_ALL,
97 		    -1,
98 		    fo_area_release,
99 		    NULL);
100 
101   G_OBJECT_CLASS (parent_class)->finalize (object);
102 }
103 
104 
105 /**
106  * fo_area_tree_new:
107  *
108  * Creates a new #FoAreaTree initialized to default value.
109  *
110  * Return value: the new #FoAreaTree
111  **/
112 FoArea*
fo_area_tree_new(void)113 fo_area_tree_new (void)
114 {
115   return FO_AREA (g_object_new (fo_area_tree_get_type (), NULL));
116 }
117 
118 void
fo_area_tree_debug_dump_properties(FoArea * area,gint depth)119 fo_area_tree_debug_dump_properties (FoArea *area, gint depth)
120 {
121   g_return_if_fail (area != NULL);
122   g_return_if_fail (FO_IS_AREA_TREE (area));
123 
124   FO_AREA_CLASS (parent_class)->debug_dump_properties (area, depth + 1);
125 }
126