1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 * @title: AdgTitleBlock
24 * @short_description: A title block entity
26 * Title blocks are commonly used in technical drawings to include
27 * additional information not strictly related to physical dimensions,
28 * such as title, material of the represented part, special treatments,
31 * Actually this entity is only a place-holder: it will be implemented
32 * properly in a 0.6.x release, after having AdgToyTable in place.
38 * All fields are privates and should not be used directly.
39 * Use its public methods instead.
43 #include "adg-title-block.h"
44 #include "adg-title-block-private.h"
56 static void finalize (GObject
*object
);
57 static void get_property (GObject
*object
,
61 static void set_property (GObject
*object
,
67 G_DEFINE_TYPE(AdgTitleBlock
, adg_title_block
, ADG_TYPE_ENTITY
);
71 adg_title_block_class_init(AdgTitleBlockClass
*klass
)
73 GObjectClass
*gobject_class
;
76 gobject_class
= (GObjectClass
*) klass
;
78 g_type_class_add_private(klass
, sizeof(AdgTitleBlockPrivate
));
80 gobject_class
->set_property
= set_property
;
81 gobject_class
->get_property
= get_property
;
82 gobject_class
->finalize
= finalize
;
84 param
= g_param_spec_string("name",
86 P_("Descriptive name of this part"),
87 NULL
, G_PARAM_READWRITE
);
88 g_object_class_install_property(gobject_class
, PROP_NAME
, param
);
90 param
= g_param_spec_string("material",
92 P_("Material this part is done with"),
93 NULL
, G_PARAM_READWRITE
);
94 g_object_class_install_property(gobject_class
, PROP_MATERIAL
, param
);
96 param
= g_param_spec_string("treatment",
98 P_("Treatment this part must receive"),
99 NULL
, G_PARAM_READWRITE
);
100 g_object_class_install_property(gobject_class
, PROP_TREATMENT
, param
);
104 adg_title_block_init(AdgTitleBlock
*title_block
)
106 AdgTitleBlockPrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(title_block
,
107 ADG_TYPE_TITLE_BLOCK
,
108 AdgTitleBlockPrivate
);
110 data
->material
= NULL
;
111 data
->treatment
= NULL
;
113 title_block
->data
= data
;
117 finalize(GObject
*object
)
119 AdgTitleBlock
*title_block
;
120 AdgTitleBlockPrivate
*data
;
121 GObjectClass
*object_class
;
123 title_block
= (AdgTitleBlock
*) object
;
124 data
= title_block
->data
;
125 object_class
= (GObjectClass
*) adg_title_block_parent_class
;
128 g_free(data
->material
);
129 g_free(data
->treatment
);
131 if (object_class
->finalize
!= NULL
)
132 object_class
->finalize(object
);
137 get_property(GObject
*object
,
138 guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
140 AdgTitleBlockPrivate
*data
= ((AdgTitleBlock
*) object
)->data
;
144 g_value_set_string(value
, data
->name
);
147 g_value_set_string(value
, data
->material
);
150 g_value_set_string(value
, data
->treatment
);
153 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
159 set_property(GObject
*object
,
160 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
162 AdgTitleBlockPrivate
*data
= ((AdgTitleBlock
*) object
)->data
;
167 data
->name
= g_value_dup_string(value
);
170 g_free(data
->material
);
171 data
->material
= g_value_dup_string(value
);
174 g_free(data
->treatment
);
175 data
->treatment
= g_value_dup_string(value
);
178 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
185 * adg_title_block_get_name:
186 * @title_block: an #AdgTitleBlock entity
188 * Gets the descriptive name associated to this title block.
189 * The title block name usually represents what is commonly
190 * referred as "title of the drawing".
192 * Return value: a copy of the title block name: it must be freed
193 * with g_free() when no longer needed
196 adg_title_block_get_name(AdgTitleBlock
*title_block
)
198 AdgTitleBlockPrivate
*data
;
200 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
202 data
= title_block
->data
;
204 return g_strdup(data
->name
);
208 * adg_title_block_set_name:
209 * @title_block: an #AdgTitleBlock entity
210 * @name: the new name
212 * Sets a new name on the title block.
215 adg_title_block_set_name(AdgTitleBlock
*title_block
, const gchar
*name
)
217 AdgTitleBlockPrivate
*data
;
219 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
221 data
= title_block
->data
;
223 data
->name
= g_strdup(name
);
225 g_object_notify((GObject
*) title_block
, "name");
230 * adg_title_block_get_material:
231 * @title_block: an #AdgTitleBlock entity
233 * Gets the material (a descriptive name) associated to this title
234 * block. This property is not always significative: on drawings
235 * representing more than one part (such as assemblies) the material
236 * item has no meaning.
238 * Return value: a copy of the material name: it must be freed
239 * with g_free() when no longer needed
242 adg_title_block_get_material(AdgTitleBlock
*title_block
)
244 AdgTitleBlockPrivate
*data
;
246 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
248 data
= title_block
->data
;
250 return g_strdup(data
->material
);
254 * adg_title_block_set_material:
255 * @title_block: an #AdgTitleBlock entity
256 * @name: the new material
258 * Sets a new material on the title block.
261 adg_title_block_set_material(AdgTitleBlock
*title_block
,
262 const gchar
*material
)
264 AdgTitleBlockPrivate
*data
;
266 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
268 data
= title_block
->data
;
269 g_free(data
->material
);
270 data
->material
= g_strdup(material
);
271 g_object_notify((GObject
*) title_block
, "material");
276 * adg_title_block_get_treatment:
277 * @title_block: an #AdgTitleBlock entity
279 * Gets the treatment (a descriptive name) associated to this title
280 * block. As for :material property, also the treatment
281 * should be set only when applicable.
283 * Return value: a copy of the treatment description: it must be freed
284 * with g_free() when no longer needed
287 adg_title_block_get_treatment(AdgTitleBlock
*title_block
)
289 AdgTitleBlockPrivate
*data
;
291 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
293 data
= title_block
->data
;
295 return g_strdup(data
->treatment
);
299 * adg_title_block_set_treatment:
300 * @title_block: an #AdgTitleBlock entity
301 * @name: the new treatment
303 * Sets a new treatment on the title block.
306 adg_title_block_set_treatment(AdgTitleBlock
*title_block
,
307 const gchar
*treatment
)
309 AdgTitleBlockPrivate
*data
;
311 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
313 data
= title_block
->data
;
314 g_free(data
->treatment
);
315 data
->treatment
= g_strdup(treatment
);
316 g_object_notify((GObject
*) title_block
, "treatment");