2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * view_barcode.c: GLabels label barcode object widget
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <libgnomeprint/gnome-glyphlist.h>
27 #include "view-barcode.h"
28 #include "canvas-hacktext.h"
30 #include "view-highlight.h"
33 #include "wdgt-bc-data.h"
34 #include "wdgt-bc-props.h"
35 #include "wdgt-bc-style.h"
36 #include "wdgt-position.h"
40 #include "pixmaps/cursor_barcode.xbm"
41 #include "pixmaps/cursor_barcode_mask.xbm"
45 /*========================================================*/
46 /* Private macros and constants. */
47 /*========================================================*/
49 /*========================================================*/
51 /*========================================================*/
53 struct _glViewBarcodePrivate {
68 /*========================================================*/
69 /* Private globals. */
70 /*========================================================*/
72 static glViewObjectClass *parent_class = NULL;
75 /*========================================================*/
76 /* Private function prototypes. */
77 /*========================================================*/
79 static void gl_view_barcode_class_init (glViewBarcodeClass *klass);
80 static void gl_view_barcode_instance_init (glViewBarcode *view_barcode);
81 static void gl_view_barcode_finalize (GObject *object);
83 static void update_view_barcode_cb (glLabelObject *object,
84 glViewBarcode *view_barcode);
86 static GtkWidget *construct_properties_dialog (glViewBarcode *view_barcode);
88 static void response_cb (GtkDialog *dialog,
90 glViewBarcode *view_barcode);
92 static void bc_data_changed_cb (glWdgtBCData *bc_data,
93 glViewBarcode *view_barcode);
95 static void bc_props_changed_cb (glWdgtBCProps *bc_props,
96 glViewBarcode *view_barcode);
98 static void bc_style_changed_cb (glWdgtBCStyle *bc_style,
99 glViewBarcode *view_barcode);
101 static void position_changed_cb (glWdgtPosition *position,
102 glViewBarcode *view_barcode);
104 static void update_dialog_cb (glLabelObject *object,
105 glViewBarcode *view_barcode);
107 static void draw_barcode (glViewBarcode *view_barcode);
110 /*****************************************************************************/
111 /* Boilerplate object stuff. */
112 /*****************************************************************************/
114 gl_view_barcode_get_type (void)
116 static GType type = 0;
120 sizeof (glViewBarcodeClass),
123 (GClassInitFunc) gl_view_barcode_class_init,
126 sizeof (glViewBarcode),
128 (GInstanceInitFunc) gl_view_barcode_instance_init,
131 type = g_type_register_static (GL_TYPE_VIEW_OBJECT,
132 "glViewBarcode", &info, 0);
139 gl_view_barcode_class_init (glViewBarcodeClass *klass)
141 GObjectClass *object_class = (GObjectClass *) klass;
143 gl_debug (DEBUG_VIEW, "START");
145 parent_class = g_type_class_peek_parent (klass);
147 object_class->finalize = gl_view_barcode_finalize;
149 gl_debug (DEBUG_VIEW, "END");
153 gl_view_barcode_instance_init (glViewBarcode *view_barcode)
155 gl_debug (DEBUG_VIEW, "START");
157 view_barcode->private = g_new0 (glViewBarcodePrivate, 1);
159 gl_debug (DEBUG_VIEW, "END");
163 gl_view_barcode_finalize (GObject *object)
167 gl_debug (DEBUG_VIEW, "START");
169 g_return_if_fail (object && GL_IS_VIEW_BARCODE (object));
171 G_OBJECT_CLASS (parent_class)->finalize (object);
173 gl_debug (DEBUG_VIEW, "END");
176 /*****************************************************************************/
177 /* NEW barcode object view. */
178 /*****************************************************************************/
180 gl_view_barcode_new (glLabelBarcode *object,
183 glViewBarcode *view_barcode;
187 gl_debug (DEBUG_VIEW, "START");
188 g_return_if_fail (object && GL_IS_LABEL_BARCODE (object));
189 g_return_if_fail (view && GL_IS_VIEW (view));
191 view_barcode = g_object_new (gl_view_barcode_get_type(), NULL);
193 gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view);
194 gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode),
195 GL_LABEL_OBJECT(object),
196 GL_VIEW_HIGHLIGHT_SIMPLE);
198 /* Create analogous canvas items. */
199 draw_barcode (view_barcode);
201 g_signal_connect (G_OBJECT (object), "changed",
202 G_CALLBACK (update_view_barcode_cb), view_barcode);
204 /* Create a dialog for controlling/viewing object properties. */
205 dialog = construct_properties_dialog (view_barcode);
206 gl_view_object_set_dialog (GL_VIEW_OBJECT(view_barcode), dialog);
208 gl_debug (DEBUG_VIEW, "END");
210 return GL_VIEW_OBJECT (view_barcode);
213 /*---------------------------------------------------------------------------*/
214 /* PRIVATE. label object "changed" callback. */
215 /*---------------------------------------------------------------------------*/
217 update_view_barcode_cb (glLabelObject *object,
218 glViewBarcode *view_barcode)
221 GnomeCanvasItem *group;
223 gl_debug (DEBUG_VIEW, "START");
225 view = gl_view_object_get_view (GL_VIEW_OBJECT(view_barcode));
227 /* Adjust appearance of analogous canvas items. */
228 draw_barcode (view_barcode);
230 /* Adjust highlight */
231 gl_view_object_update_highlight (GL_VIEW_OBJECT(view_barcode));
233 gl_debug (DEBUG_VIEW, "END");
236 /*****************************************************************************/
237 /* Create a properties dialog for a barcode object. */
238 /*****************************************************************************/
240 construct_properties_dialog (glViewBarcode *view_barcode)
242 GtkWidget *dialog, *wsection;
243 BonoboWindow *win = glabels_get_active_window ();
244 glLabelObject *object;
245 gdouble x, y, w, h, label_width, label_height;
246 glTextNode *text_node;
247 glBarcodeStyle style;
252 GtkSizeGroup *label_size_group;
254 gl_debug (DEBUG_VIEW, "START");
256 /* retrieve object and query parameters */
257 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
258 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
259 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
260 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
261 &style, &text_flag, &color, &scale);
262 gl_label_get_size (GL_LABEL(object->parent),
263 &label_width, &label_height);
264 merge = gl_label_get_merge (GL_LABEL(object->parent));
266 /*-----------------------------------------------------------------*/
268 /*-----------------------------------------------------------------*/
269 dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"),
271 GTK_DIALOG_DESTROY_WITH_PARENT,
275 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
276 g_signal_connect (G_OBJECT (dialog), "response",
277 G_CALLBACK (response_cb), view_barcode);
279 label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
281 /*---------------------------*/
283 /*---------------------------*/
284 wsection = gl_hig_category_new (_("Data"));
285 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
288 view_barcode->private->bc_data =
289 gl_wdgt_bc_data_new (merge->field_defs);
290 gl_wdgt_bc_data_set_label_size_group (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
292 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
293 (merge->type != GL_MERGE_NONE),
295 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
296 view_barcode->private->bc_data);
297 g_signal_connect ( G_OBJECT(view_barcode->private->bc_data),
298 "changed", G_CALLBACK (bc_data_changed_cb),
302 /*---------------------------*/
303 /* Appearance section */
304 /*---------------------------*/
305 wsection = gl_hig_category_new (_("Properties"));
306 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
308 /* barcode props entry */
309 gl_debug (DEBUG_VIEW, "Creating props entry...");
310 view_barcode->private->bc_props = gl_wdgt_bc_props_new ();
311 gl_wdgt_bc_props_set_label_size_group (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
313 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
315 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
316 view_barcode->private->bc_props);
317 g_signal_connect ( G_OBJECT(view_barcode->private->bc_props),
318 "changed", G_CALLBACK (bc_props_changed_cb),
321 /* Barcode style widget */
322 view_barcode->private->bc_style = gl_wdgt_bc_style_new ();
323 gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
325 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
327 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
328 view_barcode->private->bc_style);
329 g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
330 "changed", G_CALLBACK (bc_style_changed_cb),
334 /*----------------------------*/
335 /* Position section */
336 /*----------------------------*/
337 wsection = gl_hig_category_new (_("Position"));
338 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
340 /* ------ Position Frame ------ */
341 view_barcode->private->position = gl_wdgt_position_new ();
342 gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_barcode->private->position),
344 gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position),
346 label_width, label_height);
347 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
348 view_barcode->private->position);
349 g_signal_connect (G_OBJECT (view_barcode->private->position),
351 G_CALLBACK(position_changed_cb), view_barcode);
354 /*----------------------------*/
355 /* Track object changes. */
356 /*----------------------------*/
357 g_signal_connect (G_OBJECT (object), "changed",
358 G_CALLBACK (update_dialog_cb), view_barcode);
360 gl_debug (DEBUG_VIEW, "END");
365 /*---------------------------------------------------------------------------*/
366 /* PRIVATE. "Response" callback. */
367 /*---------------------------------------------------------------------------*/
369 response_cb (GtkDialog *dialog,
371 glViewBarcode *view_barcode)
373 gl_debug (DEBUG_VIEW, "START");
375 g_return_if_fail(dialog != NULL);
376 g_return_if_fail(GTK_IS_DIALOG(dialog));
379 case GTK_RESPONSE_CLOSE:
380 gtk_widget_hide (GTK_WIDGET(dialog));
383 g_assert_not_reached();
386 gl_debug (DEBUG_VIEW, "END");
389 /*---------------------------------------------------------------------------*/
390 /* PRIVATE. barcode data "changed" callback. */
391 /*---------------------------------------------------------------------------*/
393 bc_data_changed_cb (glWdgtBCData *bc_data,
394 glViewBarcode *view_barcode)
396 glLabelObject *object;
397 glTextNode *text_node;
399 gl_debug (DEBUG_VIEW, "START");
401 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
403 text_node = gl_wdgt_bc_data_get_data (bc_data);
405 g_signal_handlers_block_by_func (G_OBJECT(object),
406 update_dialog_cb, view_barcode);
407 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
408 g_signal_handlers_unblock_by_func (G_OBJECT(object),
409 update_dialog_cb, view_barcode);
411 gl_text_node_free (&text_node);
413 gl_debug (DEBUG_VIEW, "END");
416 /*---------------------------------------------------------------------------*/
417 /* PRIVATE. barcode props "changed" callback. */
418 /*---------------------------------------------------------------------------*/
420 bc_props_changed_cb (glWdgtBCProps *text_props,
421 glViewBarcode *view_barcode)
423 glLabelObject *object;
424 glBarcodeStyle style;
430 gl_debug (DEBUG_VIEW, "START");
432 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
434 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
435 &style, &text_flag, &color, &scale);
436 gl_wdgt_bc_props_get_params (text_props, &scale, &color);
438 g_signal_handlers_block_by_func (G_OBJECT(object),
439 update_dialog_cb, view_barcode);
440 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
441 style, text_flag, color, scale);
442 g_signal_handlers_unblock_by_func (G_OBJECT(object),
443 update_dialog_cb, view_barcode);
445 gl_debug (DEBUG_VIEW, "END");
448 /*---------------------------------------------------------------------------*/
449 /* PRIVATE. barcode style "changed" callback. */
450 /*---------------------------------------------------------------------------*/
452 bc_style_changed_cb (glWdgtBCStyle *bc_style,
453 glViewBarcode *view_barcode)
455 glLabelObject *object;
456 glBarcodeStyle style;
462 gl_debug (DEBUG_VIEW, "START");
464 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
466 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
467 &style, &text_flag, &color, &scale);
468 gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag);
470 g_signal_handlers_block_by_func (G_OBJECT(object),
471 update_dialog_cb, view_barcode);
472 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
473 style, text_flag, color, scale);
474 g_signal_handlers_unblock_by_func (G_OBJECT(object),
475 update_dialog_cb, view_barcode);
477 gl_debug (DEBUG_VIEW, "END");
480 /*---------------------------------------------------------------------------*/
481 /* PRIVATE. position "changed" callback. */
482 /*---------------------------------------------------------------------------*/
484 position_changed_cb (glWdgtPosition *position,
485 glViewBarcode *view_barcode)
487 glLabelObject *object;
490 gl_debug (DEBUG_VIEW, "START");
492 gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y);
494 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
496 g_signal_handlers_block_by_func (G_OBJECT(object),
497 update_dialog_cb, view_barcode);
498 gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
499 g_signal_handlers_unblock_by_func (G_OBJECT(object),
500 update_dialog_cb, view_barcode);
502 gl_debug (DEBUG_VIEW, "END");
505 /*---------------------------------------------------------------------------*/
506 /* PRIVATE. label object "changed" callback. */
507 /*---------------------------------------------------------------------------*/
509 update_dialog_cb (glLabelObject *object,
510 glViewBarcode *view_barcode)
513 glTextNode *text_node;
514 glBarcodeStyle style;
520 gl_debug (DEBUG_VIEW, "START");
522 /* Query properties of object. */
523 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
524 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
525 &style, &text_flag, &color, &scale);
526 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
527 merge = gl_label_get_merge (GL_LABEL(object->parent));
529 /* Block widget handlers to prevent recursion */
530 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data),
531 bc_data_changed_cb, view_barcode);
532 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props),
533 bc_props_changed_cb, view_barcode);
534 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style),
535 bc_style_changed_cb, view_barcode);
536 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position),
537 position_changed_cb, view_barcode);
539 /* Update widgets in property dialog */
541 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
542 (merge->type != GL_MERGE_NONE),
544 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
546 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
548 gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
551 /* Unblock widget handlers */
552 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data),
553 bc_data_changed_cb, view_barcode);
554 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props),
555 bc_props_changed_cb, view_barcode);
556 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style),
557 bc_style_changed_cb, view_barcode);
558 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position),
559 position_changed_cb, view_barcode);
561 gl_text_node_free (&text_node);
563 gl_debug (DEBUG_VIEW, "END");
566 /*****************************************************************************/
567 /* Return apropos cursor for create object mode. */
568 /*****************************************************************************/
570 gl_view_barcode_get_create_cursor (void)
572 static GdkCursor *cursor = NULL;
573 GdkPixmap *pixmap_data, *pixmap_mask;
574 GdkColor fg = { 0, 0, 0, 0 };
575 GdkColor bg = { 0, 65535, 65535, 65535 };
577 gl_debug (DEBUG_VIEW, "START");
580 pixmap_data = gdk_bitmap_create_from_data (NULL,
582 cursor_barcode_width,
583 cursor_barcode_height);
584 pixmap_mask = gdk_bitmap_create_from_data (NULL,
585 cursor_barcode_mask_bits,
586 cursor_barcode_mask_width,
587 cursor_barcode_mask_height);
589 gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg,
590 &bg, cursor_barcode_x_hot,
591 cursor_barcode_y_hot);
594 gl_debug (DEBUG_VIEW, "END");
599 /*****************************************************************************/
600 /* Canvas event handler for creating barcode objects. */
601 /*****************************************************************************/
603 gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
607 static gdouble x0, y0;
608 static gboolean dragging = FALSE;
609 static glViewObject *view_barcode;
610 static GObject *object;
612 glTextNode *text_node;
614 gl_debug (DEBUG_VIEW, "");
616 switch (event->type) {
618 case GDK_BUTTON_PRESS:
619 gl_debug (DEBUG_VIEW, "BUTTON_PRESS");
620 switch (event->button.button) {
623 gdk_pointer_grab (GTK_WIDGET (view->canvas)->window,
625 GDK_POINTER_MOTION_MASK |
626 GDK_BUTTON_RELEASE_MASK |
627 GDK_BUTTON_PRESS_MASK,
628 NULL, NULL, event->button.time);
629 gnome_canvas_window_to_world (canvas,
631 event->button.y, &x, &y);
632 object = gl_label_barcode_new (view->label);
633 gl_label_object_set_position (GL_LABEL_OBJECT(object),
635 text_node = gl_text_node_new_from_text ("123456789");
636 gl_label_barcode_set_data (GL_LABEL_BARCODE(object),
638 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
639 GL_BARCODE_STYLE_POSTNET,
641 gl_color_set_opacity (gl_prefs->default_line_color, 0.5),
643 view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object),
653 case GDK_BUTTON_RELEASE:
654 gl_debug (DEBUG_VIEW, "BUTTON_RELEASE");
655 switch (event->button.button) {
658 gdk_pointer_ungrab (event->button.time);
659 gnome_canvas_window_to_world (canvas,
661 event->button.y, &x, &y);
662 gl_label_object_set_position (GL_LABEL_OBJECT(object),
664 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
665 GL_BARCODE_STYLE_POSTNET,
667 gl_prefs->default_line_color,
669 gl_view_unselect_all (view);
670 gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
671 gl_view_arrow_mode (view);
678 case GDK_MOTION_NOTIFY:
679 gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
680 if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
681 gnome_canvas_window_to_world (canvas,
683 event->motion.y, &x, &y);
684 gl_label_object_set_position (GL_LABEL_OBJECT(object),
697 /*--------------------------------------------------------------------------*/
698 /* PRIVATE. Draw barcode to item (group). */
699 /*--------------------------------------------------------------------------*/
701 draw_barcode (glViewBarcode *view_barcode)
703 glLabelObject *object;
704 GnomeCanvasItem *group, *item;
705 glTextNode *text_node;
706 glBarcodeStyle style;
711 glBarcodeChar *bchar;
714 GList *item_list = NULL;
715 GnomeCanvasPoints *points;
716 gchar *digits, *cstring;
718 GnomeGlyphList *glyphlist;
721 gl_debug (DEBUG_VIEW, "START");
723 /* Query label object and properties */
724 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
725 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
726 &style, &text_flag, &color, &scale);
727 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
728 if (text_node->field_flag) {
729 digits = gl_barcode_default_digits (style);
731 digits = gl_text_node_expand (text_node, NULL);
734 /* get parent item/group to render to. */
735 group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode));
737 /* remove previous items from group. */
738 for (li = view_barcode->private->item_list; li!=NULL; li = li->next) {
739 gl_debug (DEBUG_VIEW, "in loop");
740 gtk_object_destroy (GTK_OBJECT (li->data));
742 gl_debug (DEBUG_VIEW, "1");
743 g_list_free (view_barcode->private->item_list);
744 view_barcode->private->item_list = NULL;
745 gl_debug (DEBUG_VIEW, "2");
748 font = gnome_font_find_closest_from_weight_slant (GL_BARCODE_FONT_FAMILY,
749 GL_BARCODE_FONT_WEIGHT,
753 gbc = gl_barcode_new (style, text_flag, scale, digits);
756 cstring = _("Invalid barcode");
757 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
763 y_offset = 10.0 - gnome_font_get_descender (font);
764 item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
765 gl_canvas_hacktext_get_type (),
768 "glyphlist", glyphlist, NULL);
770 view_barcode->private->item_list =
771 g_list_prepend (view_barcode->private->item_list, item);
774 points = gnome_canvas_points_new (2);
775 for (li = gbc->lines; li != NULL; li = li->next) {
776 line = (glBarcodeLine *) li->data;
778 points->coords[0] = line->x;
779 points->coords[1] = line->y;
780 points->coords[2] = line->x;
781 points->coords[3] = line->y + line->length;
784 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
785 gnome_canvas_line_get_type
786 (), "points", points,
787 "width_units", line->width,
788 "fill_color_rgba", color,
790 view_barcode->private->item_list =
791 g_list_prepend (view_barcode->private->item_list, item);
793 gnome_canvas_points_free (points);
795 for (li = gbc->chars; li != NULL; li = li->next) {
796 bchar = (glBarcodeChar *) li->data;
798 font = gnome_font_find_closest_from_weight_slant (
799 GL_BARCODE_FONT_FAMILY,
800 GL_BARCODE_FONT_WEIGHT,
801 FALSE, bchar->fsize);
802 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
811 bchar->fsize - gnome_font_get_descender (font);
813 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
814 gnome_canvas_hacktext_get_type
815 (), "x", bchar->x, "y",
817 "glyphlist", glyphlist,
820 view_barcode->private->item_list =
821 g_list_prepend (view_barcode->private->item_list, item);
828 gl_barcode_free (&gbc);
831 gl_debug (DEBUG_VIEW, "END");