1 /* Fo
2  * fo-property-border-before-color.c: 'border-before-color' property
3  *
4  * Copyright (C) 2001 Sun Microsystems
5  * Copyright (C) 2007 Menteith Consulting Ltd
6  *
7  * See COPYING for the status of this software.
8  */
9 
10 #include <string.h>
11 #include "fo-utils.h"
12 #include "fo-context.h"
13 #include "datatype/fo-datatype.h"
14 #include "property/fo-property-private.h"
15 #include "property/fo-property-font-size.h"
16 #include "property/fo-property-border-before-color.h"
17 #include "property/fo-property-util.h"
18 
19 /* border-before-color */
20 /* Inherited: FALSE */
21 /* Shorthand: FALSE */
22 /* <color> | inherit */
23 /* Initial value: the value of the 'color' property */
24 
25 struct _FoPropertyBorderBeforeColor
26 {
27   FoProperty parent_instance;
28 };
29 
30 struct _FoPropertyBorderBeforeColorClass
31 {
32   FoPropertyClass parent_class;
33 };
34 
35 static void fo_property_border_before_color_init         (FoPropertyBorderBeforeColor      *property_border_before_color);
36 static void fo_property_border_before_color_class_init   (FoPropertyBorderBeforeColorClass *klass);
37 static void fo_property_border_before_color_finalize     (GObject       *object);
38 
39 static const gchar class_name[] = "border-before-color";
40 static gpointer parent_class;
41 
42 /**
43  * fo_property_border_before_color_get_type:
44  *
45  * Register the #FoPropertyBorderBeforeColor type if not already registered and
46  * return its #GType value.
47  *
48  * Return value: #GType of #FoPropertyBorderBeforeColor.
49  **/
50 GType
fo_property_border_before_color_get_type(void)51 fo_property_border_before_color_get_type (void)
52 {
53   static GType object_type = 0;
54 
55   if (!object_type)
56     {
57       static const GTypeInfo object_info =
58       {
59         sizeof (FoPropertyBorderBeforeColorClass),
60         NULL,           /* base_init */
61         NULL,           /* base_finalize */
62         (GClassInitFunc) fo_property_border_before_color_class_init,
63         NULL,           /* class_finalize */
64         NULL,           /* class_data */
65         sizeof (FoPropertyBorderBeforeColor),
66         0,              /* n_preallocs */
67         (GInstanceInitFunc) fo_property_border_before_color_init,
68 	NULL		/* value_table */
69       };
70 
71       object_type = g_type_register_static (FO_TYPE_PROPERTY,
72                                             class_name,
73                                             &object_info, 0);
74     }
75 
76   return object_type;
77 }
78 
79 /**
80  * fo_property_border_before_color_init:
81  * @border_before_color: #FoPropertyBorderBeforeColor object to initialise.
82  *
83  * Implements #GInstanceInitFunc for #FoPropertyBorderBeforeColor.
84  **/
85 void
fo_property_border_before_color_init(FoPropertyBorderBeforeColor * border_before_color)86 fo_property_border_before_color_init (FoPropertyBorderBeforeColor *border_before_color)
87 {
88   FO_PROPERTY (border_before_color)->value =
89     g_object_ref (fo_property_util_get_color_initial ());
90 }
91 
92 /**
93  * fo_property_border_before_color_class_init:
94  * @klass: #FoPropertyBorderBeforeColorClass object to initialise.
95  *
96  * Implements #GClassInitFunc for #FoPropertyBorderBeforeColorClass.
97  **/
98 void
fo_property_border_before_color_class_init(FoPropertyBorderBeforeColorClass * klass)99 fo_property_border_before_color_class_init (FoPropertyBorderBeforeColorClass *klass)
100 {
101   GObjectClass *object_class = G_OBJECT_CLASS (klass);
102   FoPropertyClass *property_class = FO_PROPERTY_CLASS (klass);
103 
104   parent_class = g_type_class_peek_parent (klass);
105 
106   object_class->finalize = fo_property_border_before_color_finalize;
107 
108   property_class->is_inherited = FALSE;
109   property_class->is_shorthand = FALSE;
110   property_class->resolve_enum =
111     fo_property_util_resolve_color_enum;
112   property_class->validate =
113     fo_property_util_validate_color;
114   property_class->get_initial =
115     fo_property_border_before_color_get_initial;
116 }
117 
118 /**
119  * fo_property_border_before_color_finalize:
120  * @object: #FoPropertyBorderBeforeColor object to finalize.
121  *
122  * Implements #GObjectFinalizeFunc for #FoPropertyBorderBeforeColor.
123  **/
124 void
fo_property_border_before_color_finalize(GObject * object)125 fo_property_border_before_color_finalize (GObject *object)
126 {
127   FoPropertyBorderBeforeColor *border_before_color;
128 
129   border_before_color = FO_PROPERTY_BORDER_BEFORE_COLOR (object);
130 
131   G_OBJECT_CLASS (parent_class)->finalize (object);
132 }
133 
134 
135 /**
136  * fo_property_border_before_color_new:
137  *
138  * Creates a new #FoPropertyBorderBeforeColor initialized to default value.
139  *
140  * Return value: the new #FoPropertyBorderBeforeColor.
141  **/
142 FoProperty*
fo_property_border_before_color_new(void)143 fo_property_border_before_color_new (void)
144 {
145   FoProperty* border_before_color;
146 
147   border_before_color =
148     FO_PROPERTY (g_object_new (fo_property_border_before_color_get_type (),
149                                NULL));
150 
151   return border_before_color;
152 }
153 
154 /**
155  * fo_property_border_before_color_get_initial:
156  *
157  * Get an instance of the property with the correct initial value.
158  *
159  * Return value: An instance of the property.
160  **/
161 FoProperty*
fo_property_border_before_color_get_initial(void)162 fo_property_border_before_color_get_initial (void)
163 {
164   static FoProperty *border_before_color = NULL;
165 
166   if (border_before_color == NULL)
167     {
168       border_before_color =
169 	fo_property_border_before_color_new ();
170     }
171 
172   return border_before_color;
173 }
174