1 /* Fo
2  * fo-property-border-start-width.c: 'border-start-width' 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-start-width.h"
17 #include "property/fo-property-util.h"
18 
19 /* border-start-width */
20 /* Inherited: FALSE */
21 /* Shorthand: FALSE */
22 /* <border-width> | <length-conditional> | inherit */
23 /* Initial value: medium */
24 
25 struct _FoPropertyBorderStartWidth
26 {
27   FoProperty parent_instance;
28 };
29 
30 struct _FoPropertyBorderStartWidthClass
31 {
32   FoPropertyClass parent_class;
33 };
34 
35 static void fo_property_border_start_width_init         (FoPropertyBorderStartWidth      *property_border_start_width);
36 static void fo_property_border_start_width_class_init   (FoPropertyBorderStartWidthClass *klass);
37 static void fo_property_border_start_width_finalize     (GObject       *object);
38 
39 static const gchar class_name[] = "border-start-width";
40 static gpointer parent_class;
41 
42 /**
43  * fo_property_border_start_width_get_type:
44  *
45  * Register the #FoPropertyBorderStartWidth type if not already registered and
46  * return its #GType value.
47  *
48  * Return value: #GType of #FoPropertyBorderStartWidth.
49  **/
50 GType
fo_property_border_start_width_get_type(void)51 fo_property_border_start_width_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 (FoPropertyBorderStartWidthClass),
60         NULL,           /* base_init */
61         NULL,           /* base_finalize */
62         (GClassInitFunc) fo_property_border_start_width_class_init,
63         NULL,           /* class_finalize */
64         NULL,           /* class_data */
65         sizeof (FoPropertyBorderStartWidth),
66         0,              /* n_preallocs */
67         (GInstanceInitFunc) fo_property_border_start_width_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_start_width_init:
81  * @border_start_width: #FoPropertyBorderStartWidth object to initialise.
82  *
83  * Implements #GInstanceInitFunc for #FoPropertyBorderStartWidth.
84  **/
85 void
fo_property_border_start_width_init(FoPropertyBorderStartWidth * border_start_width)86 fo_property_border_start_width_init (FoPropertyBorderStartWidth *border_start_width)
87 {
88   FO_PROPERTY (border_start_width)->value =
89     g_object_ref (fo_property_util_get_width_initial ());
90 }
91 
92 /**
93  * fo_property_border_start_width_class_init:
94  * @klass: #FoPropertyBorderStartWidthClass object to initialise.
95  *
96  * Implements #GClassInitFunc for #FoPropertyBorderStartWidthClass.
97  **/
98 void
fo_property_border_start_width_class_init(FoPropertyBorderStartWidthClass * klass)99 fo_property_border_start_width_class_init (FoPropertyBorderStartWidthClass *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_start_width_finalize;
107 
108   property_class->is_inherited = FALSE;
109   property_class->is_shorthand = FALSE;
110   property_class->resolve_enum =
111     fo_property_util_resolve_width_enum;
112   property_class->validate =
113     fo_property_util_validate_width;
114   property_class->get_initial =
115     fo_property_border_start_width_get_initial;
116 }
117 
118 /**
119  * fo_property_border_start_width_finalize:
120  * @object: #FoPropertyBorderStartWidth object to finalize.
121  *
122  * Implements #GObjectFinalizeFunc for #FoPropertyBorderStartWidth.
123  **/
124 void
fo_property_border_start_width_finalize(GObject * object)125 fo_property_border_start_width_finalize (GObject *object)
126 {
127   FoPropertyBorderStartWidth *border_start_width;
128 
129   border_start_width = FO_PROPERTY_BORDER_START_WIDTH (object);
130 
131   G_OBJECT_CLASS (parent_class)->finalize (object);
132 }
133 
134 
135 /**
136  * fo_property_border_start_width_new:
137  *
138  * Creates a new #FoPropertyBorderStartWidth initialized to default value.
139  *
140  * Return value: the new #FoPropertyBorderStartWidth.
141  **/
142 FoProperty*
fo_property_border_start_width_new(void)143 fo_property_border_start_width_new (void)
144 {
145   FoProperty* border_start_width;
146 
147   border_start_width =
148     FO_PROPERTY (g_object_new (fo_property_border_start_width_get_type (),
149                                NULL));
150 
151   return border_start_width;
152 }
153 
154 /**
155  * fo_property_border_start_width_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_start_width_get_initial(void)162 fo_property_border_start_width_get_initial (void)
163 {
164   static FoProperty *border_start_width = NULL;
165 
166   if (border_start_width == NULL)
167     {
168       border_start_width =
169 	fo_property_border_start_width_new ();
170     }
171 
172   return border_start_width;
173 }
174