作図ソフト dia の改良版
修訂 | 2f684e9d80a094de3e02926dc4381953fb652467 (tree) |
---|---|
時間 | 2009-08-19 20:27:24 |
作者 | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
Fix inconsistent line ends
@@ -1,273 +1,273 @@ | ||
1 | -/* Dia -- an diagram creation/manipulation program | |
2 | - * Copyright (C) 1998, 1999 Alexander Larsson | |
3 | - * | |
4 | - * Custom Lines -- line shapes defined in XML rather than C. | |
5 | - * Based on the original Custom Objects plugin. | |
6 | - * Copyright (C) 1999 James Henstridge. | |
7 | - * | |
8 | - * Adapted for Custom Lines plugin by Marcel Toele. | |
9 | - * Modifications (C) 2007 Kern Automatiseringsdiensten BV. | |
10 | - * | |
11 | - * Rewrite to use only public API (C) 2008 Hans Breuer | |
12 | - * | |
13 | - * This program is free software; you can redistribute it and/or modify | |
14 | - * it under the terms of the GNU General Public License as published by | |
15 | - * the Free Software Foundation; either version 2 of the License, or | |
16 | - * (at your option) any later version. | |
17 | - * | |
18 | - * This program is distributed in the hope that it will be useful, | |
19 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | - * GNU General Public License for more details. | |
22 | - * | |
23 | - * You should have received a copy of the GNU General Public License | |
24 | - * along with this program; if not, write to the Free Software | |
25 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
26 | - */ | |
27 | - | |
28 | -#include <assert.h> | |
29 | -#include <gmodule.h> | |
30 | -#include <math.h> | |
31 | -#include <stdlib.h> | |
32 | -#include <string.h> | |
33 | -#include <sys/stat.h> | |
34 | - | |
35 | -#include "object.h" | |
36 | - | |
37 | -#include "line_info.h" | |
38 | -#include "custom_linetypes.h" | |
39 | - | |
40 | -#include "properties.h" | |
41 | -#include "propinternals.h" | |
42 | - | |
43 | -#include "pixmaps/default.xpm" | |
44 | - | |
45 | -static void customline_apply_properties( DiaObject* line, LineInfo* info ); | |
46 | -static DiaObject* customline_create(Point *startpoint, | |
47 | - void *user_data, | |
48 | - Handle **handle1, | |
49 | - Handle **handle2); | |
50 | -static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename); | |
51 | -static DiaObject *custom_polyline_load (ObjectNode obj_node, int version, const char *filename); | |
52 | -static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, const char *filename); | |
53 | - | |
54 | -static void customline_save (DiaObject *object, ObjectNode obj_node, const char *filename); | |
55 | - | |
56 | -static ObjectTypeOps | |
57 | -custom_zigzagline_type_ops = { | |
58 | - (CreateFunc)customline_create, /* create */ | |
59 | - (LoadFunc) custom_zigzagline_load, /* load */ | |
60 | - (SaveFunc) customline_save, /* save */ | |
61 | - (GetDefaultsFunc) NULL /* get_defaults*/, | |
62 | - (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
63 | -}; | |
64 | - | |
65 | -static ObjectTypeOps | |
66 | -custom_polyline_type_ops = { | |
67 | - (CreateFunc)customline_create, /* create */ | |
68 | - (LoadFunc) custom_polyline_load, /* load */ | |
69 | - (SaveFunc) customline_save, /* save */ | |
70 | - (GetDefaultsFunc) NULL /* get_defaults*/, | |
71 | - (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
72 | -}; | |
73 | - | |
74 | -static ObjectTypeOps | |
75 | -custom_bezierline_type_ops = { | |
76 | - (CreateFunc)customline_create, /* create */ | |
77 | - (LoadFunc) custom_bezierline_load, /* load */ | |
78 | - (SaveFunc) customline_save, /* save */ | |
79 | - (GetDefaultsFunc) NULL /* get_defaults*/, | |
80 | - (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
81 | -}; | |
82 | - | |
83 | -/* our delegates types, intialized on demand */ | |
84 | -static DiaObjectType *polyline_ot = NULL; | |
85 | -static DiaObjectType *bezier_ot = NULL; | |
86 | -static DiaObjectType *zigzag_ot = NULL; | |
87 | - | |
88 | - | |
89 | -static gboolean | |
90 | -ensure_standard_types (void) | |
91 | -{ | |
92 | - if (!zigzag_ot) | |
93 | - zigzag_ot = object_get_type ("Standard - ZigZagLine"); | |
94 | - if (!polyline_ot) | |
95 | - polyline_ot = object_get_type ("Standard - PolyLine"); | |
96 | - if (!bezier_ot) | |
97 | - bezier_ot = object_get_type ("Standard - BezierLine"); | |
98 | - | |
99 | - return (polyline_ot && bezier_ot && zigzag_ot); | |
100 | -} | |
101 | - | |
102 | -static DiaObject * | |
103 | -custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename) | |
104 | -{ | |
105 | - ensure_standard_types (); | |
106 | - | |
107 | - if (!zigzag_ot) { | |
108 | - g_warning ("Can't delegate to 'Standard - ZigZagLine'"); | |
109 | - return NULL; | |
110 | - } | |
111 | - return zigzag_ot->ops->load (obj_node, version, filename); | |
112 | -} | |
113 | -static DiaObject * | |
114 | -custom_polyline_load (ObjectNode obj_node, int version, const char *filename) | |
115 | -{ | |
116 | - ensure_standard_types (); | |
117 | - | |
118 | - if (!polyline_ot) { | |
119 | - g_warning ("Can't delegate to 'Standard - PolyLine'"); | |
120 | - return NULL; | |
121 | - } | |
122 | - return polyline_ot->ops->load (obj_node, version, filename); | |
123 | -} | |
124 | -static DiaObject * | |
125 | -custom_bezierline_load (ObjectNode obj_node, int version, const char *filename) | |
126 | -{ | |
127 | - ensure_standard_types (); | |
128 | - | |
129 | - if (!bezier_ot) { | |
130 | - g_warning ("Can't delegate to 'Standard - BezierLine'"); | |
131 | - return NULL; | |
132 | - } | |
133 | - return bezier_ot->ops->load (obj_node, version, filename); | |
134 | -} | |
135 | - | |
136 | -static void | |
137 | -customline_save (DiaObject *object, ObjectNode obj_node, const char *filename) | |
138 | -{ | |
139 | - g_assert (object->type && object->type->ops && object->type->ops->save); | |
140 | - | |
141 | - if (!ensure_standard_types()) { | |
142 | - g_warning ("Can't create standard types"); | |
143 | - return; | |
144 | - } | |
145 | - | |
146 | - if (object->type->ops == &custom_zigzagline_type_ops) | |
147 | - zigzag_ot->ops->save (object, obj_node, filename); | |
148 | - else if (object->type->ops == &custom_polyline_type_ops) | |
149 | - polyline_ot->ops->save (object, obj_node, filename); | |
150 | - else if (object->type->ops == &custom_bezierline_type_ops) | |
151 | - bezier_ot->ops->save (object, obj_node, filename); | |
152 | - else | |
153 | - g_warning ("customline_save() no delegate"); | |
154 | -} | |
155 | - | |
156 | -/* the order here must match the one in customline_apply_properties */ | |
157 | -static PropDescription | |
158 | -_customline_prop_descs[] = { | |
159 | - { "line_colour", PROP_TYPE_COLOUR }, | |
160 | - { "line_style", PROP_TYPE_LINESTYLE }, | |
161 | - { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH }, | |
162 | - { "corner_radius", PROP_TYPE_REAL }, | |
163 | - { "start_arrow", PROP_TYPE_ARROW }, | |
164 | - { "end_arrow", PROP_TYPE_ARROW }, | |
165 | - PROP_DESC_END | |
166 | -}; | |
167 | - | |
168 | -void | |
169 | -customline_apply_properties( DiaObject* line, LineInfo* info ) | |
170 | -{ | |
171 | - GPtrArray *props; | |
172 | - LinestyleProperty *lsprop; | |
173 | - ColorProperty *cprop; | |
174 | - RealProperty *rprop; | |
175 | - ArrowProperty *aprop; | |
176 | - | |
177 | - props = prop_list_from_descs( _customline_prop_descs, pdtpp_true ); | |
178 | - g_assert( props->len == 6 ); | |
179 | - | |
180 | - /* order/index/type must match _customline_prop_descs */ | |
181 | - cprop = g_ptr_array_index( props, 0 ); | |
182 | - cprop->color_data = info->line_color; | |
183 | - | |
184 | - lsprop = g_ptr_array_index( props, 1 ); | |
185 | - lsprop->style = info->line_style; | |
186 | - lsprop->dash = info->dashlength; | |
187 | - | |
188 | - rprop = g_ptr_array_index( props, 2 ); | |
189 | - rprop->real_data = info->line_width; | |
190 | - | |
191 | - rprop = g_ptr_array_index( props, 3 ); | |
192 | - rprop->real_data = info->corner_radius; | |
193 | - | |
194 | - aprop = g_ptr_array_index( props, 4 ); | |
195 | - aprop->arrow_data = info->start_arrow; | |
196 | - | |
197 | - aprop = g_ptr_array_index( props, 5 ); | |
198 | - aprop->arrow_data = info->end_arrow; | |
199 | - | |
200 | - line->ops->set_props( line, props ); | |
201 | - | |
202 | - prop_list_free(props); | |
203 | -} | |
204 | - | |
205 | -DiaObject * | |
206 | -customline_create(Point *startpoint, | |
207 | - void *user_data, | |
208 | - Handle **handle1, | |
209 | - Handle **handle2) | |
210 | -{ | |
211 | - DiaObject* res = NULL; | |
212 | - LineInfo* line_info = (LineInfo*)user_data; | |
213 | - | |
214 | - if (!ensure_standard_types()) { | |
215 | - g_warning ("Can't create standar types."); | |
216 | - return NULL; | |
217 | - } | |
218 | - | |
219 | - if (line_info->type == CUSTOM_LINETYPE_ZIGZAGLINE) | |
220 | - res = zigzag_ot->ops->create( startpoint, user_data, handle1, handle2 ); | |
221 | - else if (line_info->type == CUSTOM_LINETYPE_POLYLINE) | |
222 | - res = polyline_ot->ops->create( startpoint, NULL, handle1, handle2 ); | |
223 | - else if (line_info->type == CUSTOM_LINETYPE_BEZIERLINE) | |
224 | - res = bezier_ot->ops->create( startpoint, NULL, handle1, handle2 ); | |
225 | - else | |
226 | - g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object.")); | |
227 | - | |
228 | - if (res) { | |
229 | - customline_apply_properties (res, line_info); | |
230 | - res->type = line_info->object_type; | |
231 | - } | |
232 | - | |
233 | - return( res ); | |
234 | -} | |
235 | - | |
236 | -void | |
237 | -custom_linetype_new(LineInfo *info, DiaObjectType **otype) | |
238 | -{ | |
239 | - DiaObjectType *obj = g_new0(DiaObjectType, 1); | |
240 | - | |
241 | - obj->version = 1; | |
242 | - obj->pixmap = default_xpm; | |
243 | - | |
244 | - if (info->type == CUSTOM_LINETYPE_ZIGZAGLINE) | |
245 | - obj->ops = &custom_zigzagline_type_ops; | |
246 | - else if (info->type == CUSTOM_LINETYPE_POLYLINE) | |
247 | - obj->ops = &custom_polyline_type_ops; | |
248 | - else if (info->type == CUSTOM_LINETYPE_BEZIERLINE) | |
249 | - obj->ops = &custom_bezierline_type_ops; | |
250 | - else | |
251 | - g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object %s."), | |
252 | - obj->name); | |
253 | - | |
254 | - obj->name = info->name; | |
255 | - obj->default_user_data = info; | |
256 | - | |
257 | - if (info->icon_filename) { | |
258 | - struct stat buf; | |
259 | - if (0==stat(info->icon_filename,&buf)) { | |
260 | - obj->pixmap = NULL; | |
261 | - obj->pixmap_file = info->icon_filename; | |
262 | - } else { | |
263 | - g_warning(_("Cannot open icon file %s for object type '%s'."), | |
264 | - info->icon_filename, obj->name); | |
265 | - } | |
266 | - } | |
267 | - | |
268 | - info->object_type = obj; /* <-- Reciproce type linking */ | |
269 | - | |
270 | - obj->default_user_data = (void*)info; | |
271 | - | |
272 | - *otype = obj; | |
273 | -} | |
1 | +/* Dia -- an diagram creation/manipulation program | |
2 | + * Copyright (C) 1998, 1999 Alexander Larsson | |
3 | + * | |
4 | + * Custom Lines -- line shapes defined in XML rather than C. | |
5 | + * Based on the original Custom Objects plugin. | |
6 | + * Copyright (C) 1999 James Henstridge. | |
7 | + * | |
8 | + * Adapted for Custom Lines plugin by Marcel Toele. | |
9 | + * Modifications (C) 2007 Kern Automatiseringsdiensten BV. | |
10 | + * | |
11 | + * Rewrite to use only public API (C) 2008 Hans Breuer | |
12 | + * | |
13 | + * This program is free software; you can redistribute it and/or modify | |
14 | + * it under the terms of the GNU General Public License as published by | |
15 | + * the Free Software Foundation; either version 2 of the License, or | |
16 | + * (at your option) any later version. | |
17 | + * | |
18 | + * This program is distributed in the hope that it will be useful, | |
19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | + * GNU General Public License for more details. | |
22 | + * | |
23 | + * You should have received a copy of the GNU General Public License | |
24 | + * along with this program; if not, write to the Free Software | |
25 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
26 | + */ | |
27 | + | |
28 | +#include <assert.h> | |
29 | +#include <gmodule.h> | |
30 | +#include <math.h> | |
31 | +#include <stdlib.h> | |
32 | +#include <string.h> | |
33 | +#include <sys/stat.h> | |
34 | + | |
35 | +#include "object.h" | |
36 | + | |
37 | +#include "line_info.h" | |
38 | +#include "custom_linetypes.h" | |
39 | + | |
40 | +#include "properties.h" | |
41 | +#include "propinternals.h" | |
42 | + | |
43 | +#include "pixmaps/default.xpm" | |
44 | + | |
45 | +static void customline_apply_properties( DiaObject* line, LineInfo* info ); | |
46 | +static DiaObject* customline_create(Point *startpoint, | |
47 | + void *user_data, | |
48 | + Handle **handle1, | |
49 | + Handle **handle2); | |
50 | +static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename); | |
51 | +static DiaObject *custom_polyline_load (ObjectNode obj_node, int version, const char *filename); | |
52 | +static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, const char *filename); | |
53 | + | |
54 | +static void customline_save (DiaObject *object, ObjectNode obj_node, const char *filename); | |
55 | + | |
56 | +static ObjectTypeOps | |
57 | +custom_zigzagline_type_ops = { | |
58 | + (CreateFunc)customline_create, /* create */ | |
59 | + (LoadFunc) custom_zigzagline_load, /* load */ | |
60 | + (SaveFunc) customline_save, /* save */ | |
61 | + (GetDefaultsFunc) NULL /* get_defaults*/, | |
62 | + (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
63 | +}; | |
64 | + | |
65 | +static ObjectTypeOps | |
66 | +custom_polyline_type_ops = { | |
67 | + (CreateFunc)customline_create, /* create */ | |
68 | + (LoadFunc) custom_polyline_load, /* load */ | |
69 | + (SaveFunc) customline_save, /* save */ | |
70 | + (GetDefaultsFunc) NULL /* get_defaults*/, | |
71 | + (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
72 | +}; | |
73 | + | |
74 | +static ObjectTypeOps | |
75 | +custom_bezierline_type_ops = { | |
76 | + (CreateFunc)customline_create, /* create */ | |
77 | + (LoadFunc) custom_bezierline_load, /* load */ | |
78 | + (SaveFunc) customline_save, /* save */ | |
79 | + (GetDefaultsFunc) NULL /* get_defaults*/, | |
80 | + (ApplyDefaultsFunc) NULL /* apply_defaults*/ | |
81 | +}; | |
82 | + | |
83 | +/* our delegates types, intialized on demand */ | |
84 | +static DiaObjectType *polyline_ot = NULL; | |
85 | +static DiaObjectType *bezier_ot = NULL; | |
86 | +static DiaObjectType *zigzag_ot = NULL; | |
87 | + | |
88 | + | |
89 | +static gboolean | |
90 | +ensure_standard_types (void) | |
91 | +{ | |
92 | + if (!zigzag_ot) | |
93 | + zigzag_ot = object_get_type ("Standard - ZigZagLine"); | |
94 | + if (!polyline_ot) | |
95 | + polyline_ot = object_get_type ("Standard - PolyLine"); | |
96 | + if (!bezier_ot) | |
97 | + bezier_ot = object_get_type ("Standard - BezierLine"); | |
98 | + | |
99 | + return (polyline_ot && bezier_ot && zigzag_ot); | |
100 | +} | |
101 | + | |
102 | +static DiaObject * | |
103 | +custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename) | |
104 | +{ | |
105 | + ensure_standard_types (); | |
106 | + | |
107 | + if (!zigzag_ot) { | |
108 | + g_warning ("Can't delegate to 'Standard - ZigZagLine'"); | |
109 | + return NULL; | |
110 | + } | |
111 | + return zigzag_ot->ops->load (obj_node, version, filename); | |
112 | +} | |
113 | +static DiaObject * | |
114 | +custom_polyline_load (ObjectNode obj_node, int version, const char *filename) | |
115 | +{ | |
116 | + ensure_standard_types (); | |
117 | + | |
118 | + if (!polyline_ot) { | |
119 | + g_warning ("Can't delegate to 'Standard - PolyLine'"); | |
120 | + return NULL; | |
121 | + } | |
122 | + return polyline_ot->ops->load (obj_node, version, filename); | |
123 | +} | |
124 | +static DiaObject * | |
125 | +custom_bezierline_load (ObjectNode obj_node, int version, const char *filename) | |
126 | +{ | |
127 | + ensure_standard_types (); | |
128 | + | |
129 | + if (!bezier_ot) { | |
130 | + g_warning ("Can't delegate to 'Standard - BezierLine'"); | |
131 | + return NULL; | |
132 | + } | |
133 | + return bezier_ot->ops->load (obj_node, version, filename); | |
134 | +} | |
135 | + | |
136 | +static void | |
137 | +customline_save (DiaObject *object, ObjectNode obj_node, const char *filename) | |
138 | +{ | |
139 | + g_assert (object->type && object->type->ops && object->type->ops->save); | |
140 | + | |
141 | + if (!ensure_standard_types()) { | |
142 | + g_warning ("Can't create standard types"); | |
143 | + return; | |
144 | + } | |
145 | + | |
146 | + if (object->type->ops == &custom_zigzagline_type_ops) | |
147 | + zigzag_ot->ops->save (object, obj_node, filename); | |
148 | + else if (object->type->ops == &custom_polyline_type_ops) | |
149 | + polyline_ot->ops->save (object, obj_node, filename); | |
150 | + else if (object->type->ops == &custom_bezierline_type_ops) | |
151 | + bezier_ot->ops->save (object, obj_node, filename); | |
152 | + else | |
153 | + g_warning ("customline_save() no delegate"); | |
154 | +} | |
155 | + | |
156 | +/* the order here must match the one in customline_apply_properties */ | |
157 | +static PropDescription | |
158 | +_customline_prop_descs[] = { | |
159 | + { "line_colour", PROP_TYPE_COLOUR }, | |
160 | + { "line_style", PROP_TYPE_LINESTYLE }, | |
161 | + { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH }, | |
162 | + { "corner_radius", PROP_TYPE_REAL }, | |
163 | + { "start_arrow", PROP_TYPE_ARROW }, | |
164 | + { "end_arrow", PROP_TYPE_ARROW }, | |
165 | + PROP_DESC_END | |
166 | +}; | |
167 | + | |
168 | +void | |
169 | +customline_apply_properties( DiaObject* line, LineInfo* info ) | |
170 | +{ | |
171 | + GPtrArray *props; | |
172 | + LinestyleProperty *lsprop; | |
173 | + ColorProperty *cprop; | |
174 | + RealProperty *rprop; | |
175 | + ArrowProperty *aprop; | |
176 | + | |
177 | + props = prop_list_from_descs( _customline_prop_descs, pdtpp_true ); | |
178 | + g_assert( props->len == 6 ); | |
179 | + | |
180 | + /* order/index/type must match _customline_prop_descs */ | |
181 | + cprop = g_ptr_array_index( props, 0 ); | |
182 | + cprop->color_data = info->line_color; | |
183 | + | |
184 | + lsprop = g_ptr_array_index( props, 1 ); | |
185 | + lsprop->style = info->line_style; | |
186 | + lsprop->dash = info->dashlength; | |
187 | + | |
188 | + rprop = g_ptr_array_index( props, 2 ); | |
189 | + rprop->real_data = info->line_width; | |
190 | + | |
191 | + rprop = g_ptr_array_index( props, 3 ); | |
192 | + rprop->real_data = info->corner_radius; | |
193 | + | |
194 | + aprop = g_ptr_array_index( props, 4 ); | |
195 | + aprop->arrow_data = info->start_arrow; | |
196 | + | |
197 | + aprop = g_ptr_array_index( props, 5 ); | |
198 | + aprop->arrow_data = info->end_arrow; | |
199 | + | |
200 | + line->ops->set_props( line, props ); | |
201 | + | |
202 | + prop_list_free(props); | |
203 | +} | |
204 | + | |
205 | +DiaObject * | |
206 | +customline_create(Point *startpoint, | |
207 | + void *user_data, | |
208 | + Handle **handle1, | |
209 | + Handle **handle2) | |
210 | +{ | |
211 | + DiaObject* res = NULL; | |
212 | + LineInfo* line_info = (LineInfo*)user_data; | |
213 | + | |
214 | + if (!ensure_standard_types()) { | |
215 | + g_warning ("Can't create standar types."); | |
216 | + return NULL; | |
217 | + } | |
218 | + | |
219 | + if (line_info->type == CUSTOM_LINETYPE_ZIGZAGLINE) | |
220 | + res = zigzag_ot->ops->create( startpoint, user_data, handle1, handle2 ); | |
221 | + else if (line_info->type == CUSTOM_LINETYPE_POLYLINE) | |
222 | + res = polyline_ot->ops->create( startpoint, NULL, handle1, handle2 ); | |
223 | + else if (line_info->type == CUSTOM_LINETYPE_BEZIERLINE) | |
224 | + res = bezier_ot->ops->create( startpoint, NULL, handle1, handle2 ); | |
225 | + else | |
226 | + g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object.")); | |
227 | + | |
228 | + if (res) { | |
229 | + customline_apply_properties (res, line_info); | |
230 | + res->type = line_info->object_type; | |
231 | + } | |
232 | + | |
233 | + return( res ); | |
234 | +} | |
235 | + | |
236 | +void | |
237 | +custom_linetype_new(LineInfo *info, DiaObjectType **otype) | |
238 | +{ | |
239 | + DiaObjectType *obj = g_new0(DiaObjectType, 1); | |
240 | + | |
241 | + obj->version = 1; | |
242 | + obj->pixmap = default_xpm; | |
243 | + | |
244 | + if (info->type == CUSTOM_LINETYPE_ZIGZAGLINE) | |
245 | + obj->ops = &custom_zigzagline_type_ops; | |
246 | + else if (info->type == CUSTOM_LINETYPE_POLYLINE) | |
247 | + obj->ops = &custom_polyline_type_ops; | |
248 | + else if (info->type == CUSTOM_LINETYPE_BEZIERLINE) | |
249 | + obj->ops = &custom_bezierline_type_ops; | |
250 | + else | |
251 | + g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object %s."), | |
252 | + obj->name); | |
253 | + | |
254 | + obj->name = info->name; | |
255 | + obj->default_user_data = info; | |
256 | + | |
257 | + if (info->icon_filename) { | |
258 | + struct stat buf; | |
259 | + if (0==stat(info->icon_filename,&buf)) { | |
260 | + obj->pixmap = NULL; | |
261 | + obj->pixmap_file = info->icon_filename; | |
262 | + } else { | |
263 | + g_warning(_("Cannot open icon file %s for object type '%s'."), | |
264 | + info->icon_filename, obj->name); | |
265 | + } | |
266 | + } | |
267 | + | |
268 | + info->object_type = obj; /* <-- Reciproce type linking */ | |
269 | + | |
270 | + obj->default_user_data = (void*)info; | |
271 | + | |
272 | + *otype = obj; | |
273 | +} |