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 private 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
*priv
=
107 G_TYPE_INSTANCE_GET_PRIVATE(title_block
, ADG_TYPE_TITLE_BLOCK
,
108 AdgTitleBlockPrivate
);
110 priv
->material
= NULL
;
111 priv
->treatment
= NULL
;
113 title_block
->priv
= priv
;
117 finalize(GObject
*object
)
119 AdgTitleBlock
*title_block
;
120 GObjectClass
*object_class
;
122 title_block
= (AdgTitleBlock
*) object
;
123 object_class
= (GObjectClass
*) adg_title_block_parent_class
;
125 g_free(title_block
->priv
->name
);
126 g_free(title_block
->priv
->material
);
127 g_free(title_block
->priv
->treatment
);
129 if (object_class
->finalize
!= NULL
)
130 object_class
->finalize(object
);
135 get_property(GObject
*object
,
136 guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
138 AdgTitleBlockPrivate
*priv
= ((AdgTitleBlock
*) object
)->priv
;
142 g_value_set_string(value
, priv
->name
);
145 g_value_set_string(value
, priv
->material
);
148 g_value_set_string(value
, priv
->treatment
);
151 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
157 set_property(GObject
*object
,
158 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
160 AdgTitleBlock
*title_block
= ADG_TITLE_BLOCK(object
);
164 g_free(title_block
->priv
->name
);
165 title_block
->priv
->name
= g_value_dup_string(value
);
168 g_free(title_block
->priv
->material
);
169 title_block
->priv
->material
= g_value_dup_string(value
);
172 g_free(title_block
->priv
->treatment
);
173 title_block
->priv
->treatment
= g_value_dup_string(value
);
176 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
183 * adg_title_block_get_name:
184 * @title_block: an #AdgTitleBlock entity
186 * Gets the descriptive name associated to this title block.
187 * The title block name usually represents what is commonly
188 * referred as "title of the drawing".
190 * Return value: a copy of the title block name: it must be freed
191 * with g_free() when no longer needed
194 adg_title_block_get_name(AdgTitleBlock
*title_block
)
196 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
198 return g_strdup(title_block
->priv
->name
);
202 * adg_title_block_set_name:
203 * @title_block: an #AdgTitleBlock entity
204 * @name: the new name
206 * Sets a new name on the title block.
209 adg_title_block_set_name(AdgTitleBlock
*title_block
, const gchar
*name
)
211 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
213 g_free(title_block
->priv
->name
);
214 title_block
->priv
->name
= g_strdup(name
);
215 g_object_notify((GObject
*) title_block
, "name");
220 * adg_title_block_get_material:
221 * @title_block: an #AdgTitleBlock entity
223 * Gets the material (a descriptive name) associated to this title
224 * block. This property is not always significative: on drawings
225 * representing more than one part (such as assemblies) the material
226 * item has no meaning.
228 * Return value: a copy of the material name: it must be freed
229 * with g_free() when no longer needed
232 adg_title_block_get_material(AdgTitleBlock
*title_block
)
234 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
236 return g_strdup(title_block
->priv
->material
);
240 * adg_title_block_set_material:
241 * @title_block: an #AdgTitleBlock entity
242 * @name: the new material
244 * Sets a new material on the title block.
247 adg_title_block_set_material(AdgTitleBlock
*title_block
,
248 const gchar
*material
)
250 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
252 g_free(title_block
->priv
->material
);
253 title_block
->priv
->material
= g_strdup(material
);
254 g_object_notify((GObject
*) title_block
, "material");
259 * adg_title_block_get_treatment:
260 * @title_block: an #AdgTitleBlock entity
262 * Gets the treatment (a descriptive name) associated to this title
263 * block. As for :material property, also the treatment
264 * should be set only when applicable.
266 * Return value: a copy of the treatment description: it must be freed
267 * with g_free() when no longer needed
270 adg_title_block_get_treatment(AdgTitleBlock
*title_block
)
272 g_return_val_if_fail(ADG_IS_TITLE_BLOCK(title_block
), NULL
);
274 return g_strdup(title_block
->priv
->treatment
);
278 * adg_title_block_set_treatment:
279 * @title_block: an #AdgTitleBlock entity
280 * @name: the new treatment
282 * Sets a new treatment on the title block.
285 adg_title_block_set_treatment(AdgTitleBlock
*title_block
,
286 const gchar
*treatment
)
288 g_return_if_fail(ADG_IS_TITLE_BLOCK(title_block
));
290 g_free(title_block
->priv
->treatment
);
291 title_block
->priv
->treatment
= g_strdup(treatment
);
292 g_object_notify((GObject
*) title_block
, "treatment");