1 /* Fo
2  * fo-property-border-right.c: 'border-right' property
3  *
4  * Copyright (C) 2001-2005 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-right.h"
17 #include "property/fo-property-util.h"
18 
19 /* border-right */
20 /* Inherited: FALSE */
21 /* Shorthand: TRUE */
22 /* [ <border-width> || <border-style> || <color> ] | inherit */
23 /* Initial value: see individual properties */
24 
25 struct _FoPropertyBorderRight
26 {
27   FoProperty parent_instance;
28 };
29 
30 struct _FoPropertyBorderRightClass
31 {
32   FoPropertyClass parent_class;
33 };
34 
35 static void fo_property_border_right_init         (FoPropertyBorderRight      *property_border_right);
36 static void fo_property_border_right_class_init   (FoPropertyBorderRightClass *klass);
37 static void fo_property_border_right_finalize     (GObject       *object);
38 
39 
40 static const gchar class_name[] = "border-right";
41 static gpointer parent_class;
42 
43 /**
44  * fo_property_border_right_get_type:
45  *
46  * Register the #FoPropertyBorderRight type if not already registered and
47  * return its #GType value.
48  *
49  * Return value: #GType of #FoPropertyBorderRight.
50  **/
51 GType
fo_property_border_right_get_type(void)52 fo_property_border_right_get_type (void)
53 {
54   static GType object_type = 0;
55 
56   if (!object_type)
57     {
58       static const GTypeInfo object_info =
59       {
60         sizeof (FoPropertyBorderRightClass),
61         NULL,           /* base_init */
62         NULL,           /* base_finalize */
63         (GClassInitFunc) fo_property_border_right_class_init,
64         NULL,           /* class_finalize */
65         NULL,           /* class_data */
66         sizeof (FoPropertyBorderRight),
67         0,              /* n_preallocs */
68         (GInstanceInitFunc) fo_property_border_right_init,
69 	NULL		/* value_table */
70       };
71 
72       object_type = g_type_register_static (FO_TYPE_PROPERTY,
73                                             class_name,
74                                             &object_info, 0);
75     }
76 
77   return object_type;
78 }
79 
80 /**
81  * fo_property_border_right_init:
82  * @border_right: #FoPropertyBorderRight object to initialise.
83  *
84  * Implements #GInstanceInitFunc for #FoPropertyBorderRight.
85  **/
86 void
fo_property_border_right_init(FoPropertyBorderRight * border_right)87 fo_property_border_right_init (FoPropertyBorderRight *border_right)
88 {
89   FO_PROPERTY (border_right)->value =
90     NULL;
91 }
92 
93 /**
94  * fo_property_border_right_class_init:
95  * @klass: #FoPropertyBorderRightClass object to initialise.
96  *
97  * Implements #GClassInitFunc for #FoPropertyBorderRightClass.
98  **/
99 void
fo_property_border_right_class_init(FoPropertyBorderRightClass * klass)100 fo_property_border_right_class_init (FoPropertyBorderRightClass *klass)
101 {
102   GObjectClass *object_class = G_OBJECT_CLASS (klass);
103   FoPropertyClass *property_class = FO_PROPERTY_CLASS (klass);
104 
105   parent_class = g_type_class_peek_parent (klass);
106 
107   object_class->finalize = fo_property_border_right_finalize;
108 
109   property_class->expr_eval = fo_expr_wsc_eval;
110   property_class->is_inherited = FALSE;
111   property_class->is_shorthand = TRUE;
112   property_class->resolve_enum =
113     fo_property_util_resolve_wsc_enum;
114   property_class->validate =
115     fo_property_util_validate_wsc;
116   property_class->get_initial =
117     fo_property_border_right_get_initial;
118 }
119 
120 /**
121  * fo_property_border_right_finalize:
122  * @object: #FoPropertyBorderRight object to finalize.
123  *
124  * Implements #GObjectFinalizeFunc for #FoPropertyBorderRight.
125  **/
126 void
fo_property_border_right_finalize(GObject * object)127 fo_property_border_right_finalize (GObject *object)
128 {
129   FoPropertyBorderRight *border_right;
130 
131   border_right = FO_PROPERTY_BORDER_RIGHT (object);
132 
133   G_OBJECT_CLASS (parent_class)->finalize (object);
134 }
135 
136 
137 /**
138  * fo_property_border_right_new:
139  *
140  * Creates a new #FoPropertyBorderRight initialized to default value.
141  *
142  * Return value: the new #FoPropertyBorderRight.
143  **/
144 FoProperty*
fo_property_border_right_new(void)145 fo_property_border_right_new (void)
146 {
147   FoProperty* border_right;
148 
149   border_right =
150     FO_PROPERTY (g_object_new (fo_property_border_right_get_type (),
151                                NULL));
152 
153   return border_right;
154 }
155 
156 /**
157  * fo_property_border_right_get_initial:
158  *
159  * Get an instance of the property with the correct initial value.
160  *
161  * Return value: An instance of the property.
162  **/
163 FoProperty*
fo_property_border_right_get_initial(void)164 fo_property_border_right_get_initial (void)
165 {
166   static FoProperty *border_right = NULL;
167 
168   if (border_right == NULL)
169     {
170       border_right =
171 	fo_property_border_right_new ();
172     }
173 
174   return border_right;
175 }
176