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"
38 #include "pixmaps/cursor_barcode.xbm"
39 #include "pixmaps/cursor_barcode_mask.xbm"
43 /*========================================================*/
44 /* Private macros and constants. */
45 /*========================================================*/
47 /*========================================================*/
49 /*========================================================*/
51 struct _glViewBarcodePrivate {
66 /*========================================================*/
67 /* Private globals. */
68 /*========================================================*/
70 static glViewObjectClass *parent_class = NULL;
73 /*========================================================*/
74 /* Private function prototypes. */
75 /*========================================================*/
77 static void gl_view_barcode_class_init (glViewBarcodeClass *klass);
78 static void gl_view_barcode_instance_init (glViewBarcode *view_barcode);
79 static void gl_view_barcode_finalize (GObject *object);
81 static void update_view_barcode_cb (glLabelObject *object,
82 glViewBarcode *view_barcode);
84 static GtkWidget *construct_properties_dialog (glViewBarcode *view_barcode);
86 static void response_cb (GtkDialog *dialog,
88 glViewBarcode *view_barcode);
90 static void bc_data_changed_cb (glWdgtBCData *bc_data,
91 glViewBarcode *view_barcode);
93 static void bc_props_changed_cb (glWdgtBCProps *bc_props,
94 glViewBarcode *view_barcode);
96 static void bc_style_changed_cb (glWdgtBCStyle *bc_style,
97 glViewBarcode *view_barcode);
99 static void position_changed_cb (glWdgtPosition *position,
100 glViewBarcode *view_barcode);
102 static void update_dialog_cb (glLabelObject *object,
103 glViewBarcode *view_barcode);
105 static void draw_barcode (glViewBarcode *view_barcode);
108 /*****************************************************************************/
109 /* Boilerplate object stuff. */
110 /*****************************************************************************/
112 gl_view_barcode_get_type (void)
114 static GType type = 0;
118 sizeof (glViewBarcodeClass),
121 (GClassInitFunc) gl_view_barcode_class_init,
124 sizeof (glViewBarcode),
126 (GInstanceInitFunc) gl_view_barcode_instance_init,
129 type = g_type_register_static (GL_TYPE_VIEW_OBJECT,
130 "glViewBarcode", &info, 0);
137 gl_view_barcode_class_init (glViewBarcodeClass *klass)
139 GObjectClass *object_class = (GObjectClass *) klass;
141 gl_debug (DEBUG_VIEW, "START");
143 parent_class = g_type_class_peek_parent (klass);
145 object_class->finalize = gl_view_barcode_finalize;
147 gl_debug (DEBUG_VIEW, "END");
151 gl_view_barcode_instance_init (glViewBarcode *view_barcode)
153 gl_debug (DEBUG_VIEW, "START");
155 view_barcode->private = g_new0 (glViewBarcodePrivate, 1);
157 gl_debug (DEBUG_VIEW, "END");
161 gl_view_barcode_finalize (GObject *object)
165 gl_debug (DEBUG_VIEW, "START");
167 g_return_if_fail (object && GL_IS_VIEW_BARCODE (object));
169 G_OBJECT_CLASS (parent_class)->finalize (object);
171 gl_debug (DEBUG_VIEW, "END");
174 /*****************************************************************************/
175 /* NEW barcode object view. */
176 /*****************************************************************************/
178 gl_view_barcode_new (glLabelBarcode *object,
181 glViewBarcode *view_barcode;
185 gl_debug (DEBUG_VIEW, "START");
186 g_return_if_fail (object && GL_IS_LABEL_BARCODE (object));
187 g_return_if_fail (view && GL_IS_VIEW (view));
189 view_barcode = g_object_new (gl_view_barcode_get_type(), NULL);
191 gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view);
192 gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode),
193 GL_LABEL_OBJECT(object),
194 GL_VIEW_HIGHLIGHT_SIMPLE);
196 /* Create analogous canvas items. */
197 draw_barcode (view_barcode);
199 g_signal_connect (G_OBJECT (object), "changed",
200 G_CALLBACK (update_view_barcode_cb), view_barcode);
202 /* Create a dialog for controlling/viewing object properties. */
203 dialog = construct_properties_dialog (view_barcode);
204 gl_view_object_set_dialog (GL_VIEW_OBJECT(view_barcode), dialog);
206 gl_debug (DEBUG_VIEW, "END");
208 return GL_VIEW_OBJECT (view_barcode);
211 /*---------------------------------------------------------------------------*/
212 /* PRIVATE. label object "changed" callback. */
213 /*---------------------------------------------------------------------------*/
215 update_view_barcode_cb (glLabelObject *object,
216 glViewBarcode *view_barcode)
219 GnomeCanvasItem *group;
221 gl_debug (DEBUG_VIEW, "START");
223 view = gl_view_object_get_view (GL_VIEW_OBJECT(view_barcode));
225 /* Adjust appearance of analogous canvas items. */
226 draw_barcode (view_barcode);
228 /* Adjust highlight */
229 gl_view_object_update_highlight (GL_VIEW_OBJECT(view_barcode));
231 gl_debug (DEBUG_VIEW, "END");
234 /*****************************************************************************/
235 /* Create a properties dialog for a barcode object. */
236 /*****************************************************************************/
238 construct_properties_dialog (glViewBarcode *view_barcode)
240 GtkWidget *dialog, *notebook, *wvbox, *wbutton;
241 BonoboWindow *win = glabels_get_active_window ();
242 glLabelObject *object;
243 gdouble x, y, w, h, label_width, label_height;
244 glTextNode *text_node;
245 glBarcodeStyle style;
251 gl_debug (DEBUG_VIEW, "START");
253 /* retrieve object and query parameters */
254 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
255 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
256 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
257 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
258 &style, &text_flag, &color, &scale);
259 gl_label_get_size (GL_LABEL(object->parent),
260 &label_width, &label_height);
261 merge = gl_label_get_merge (GL_LABEL(object->parent));
263 /*-----------------------------------------------------------------*/
264 /* Build dialog with notebook. */
265 /*-----------------------------------------------------------------*/
266 gl_debug (DEBUG_VIEW, "Creating dialog...");
267 dialog = gtk_dialog_new_with_buttons ( _("Edit barcode object properties"),
269 GTK_DIALOG_DESTROY_WITH_PARENT,
273 g_signal_connect (G_OBJECT (dialog), "response",
274 G_CALLBACK (response_cb), view_barcode);
276 notebook = gtk_notebook_new ();
277 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
278 notebook, TRUE, TRUE, 0);
280 /*---------------------------*/
281 /* Data Notebook Tab */
282 /*---------------------------*/
283 gl_debug (DEBUG_VIEW, "Creating data tab...");
284 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
285 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
286 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
287 gtk_label_new (_("Data")));
290 gl_debug (DEBUG_VIEW, "Creating data entry...");
291 view_barcode->private->bc_data =
292 gl_wdgt_bc_data_new (_("Barcode data"), merge->field_defs);
293 gl_debug (DEBUG_VIEW, "1");
294 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
295 (merge->type != GL_MERGE_NONE),
297 gl_debug (DEBUG_VIEW, "2");
298 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_data,
300 gl_debug (DEBUG_VIEW, "3");
301 g_signal_connect ( G_OBJECT(view_barcode->private->bc_data),
302 "changed", G_CALLBACK (bc_data_changed_cb),
306 /*---------------------------*/
307 /* Appearance Notebook Tab */
308 /*---------------------------*/
309 gl_debug (DEBUG_VIEW, "Creating props tab...");
310 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
311 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
312 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
313 gtk_label_new (_("Appearance")));
315 /* barcode props entry */
316 gl_debug (DEBUG_VIEW, "Creating props entry...");
317 view_barcode->private->bc_props =
318 gl_wdgt_bc_props_new (_("Barcode Properties"));
319 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
321 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_props,
323 g_signal_connect ( G_OBJECT(view_barcode->private->bc_props),
324 "changed", G_CALLBACK (bc_props_changed_cb),
327 /* ------ Barcode Style Frame ------ */
328 view_barcode->private->bc_style = gl_wdgt_bc_style_new (_("Style"));
329 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
331 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_style,
333 g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
334 "changed", G_CALLBACK (bc_style_changed_cb),
338 /*----------------------------*/
339 /* Position/Size Notebook Tab */
340 /*----------------------------*/
341 gl_debug (DEBUG_VIEW, "Creating position tab...");
342 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
343 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
344 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
345 gtk_label_new (_("Position")));
347 /* ------ Position Frame ------ */
348 gl_debug (DEBUG_VIEW, "Creating position entry...");
349 view_barcode->private->position = gl_wdgt_position_new (_("Position"));
350 gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position),
352 label_width, label_height);
353 gtk_box_pack_start (GTK_BOX (wvbox),
354 view_barcode->private->position,
356 g_signal_connect (G_OBJECT (view_barcode->private->position),
358 G_CALLBACK(position_changed_cb), view_barcode);
361 /*----------------------------*/
362 /* Track object changes. */
363 /*----------------------------*/
364 g_signal_connect (G_OBJECT (object), "changed",
365 G_CALLBACK (update_dialog_cb), view_barcode);
367 gl_debug (DEBUG_VIEW, "END");
372 /*---------------------------------------------------------------------------*/
373 /* PRIVATE. "Response" callback. */
374 /*---------------------------------------------------------------------------*/
376 response_cb (GtkDialog *dialog,
378 glViewBarcode *view_barcode)
380 gl_debug (DEBUG_VIEW, "START");
382 g_return_if_fail(dialog != NULL);
383 g_return_if_fail(GTK_IS_DIALOG(dialog));
386 case GTK_RESPONSE_CLOSE:
387 gtk_widget_hide (GTK_WIDGET(dialog));
390 g_assert_not_reached();
393 gl_debug (DEBUG_VIEW, "END");
396 /*---------------------------------------------------------------------------*/
397 /* PRIVATE. barcode data "changed" callback. */
398 /*---------------------------------------------------------------------------*/
400 bc_data_changed_cb (glWdgtBCData *bc_data,
401 glViewBarcode *view_barcode)
403 glLabelObject *object;
404 glTextNode *text_node;
406 gl_debug (DEBUG_VIEW, "START");
408 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
410 text_node = gl_wdgt_bc_data_get_data (bc_data);
412 g_signal_handlers_block_by_func (G_OBJECT(object),
413 update_dialog_cb, view_barcode);
414 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
415 g_signal_handlers_unblock_by_func (G_OBJECT(object),
416 update_dialog_cb, view_barcode);
418 gl_text_node_free (&text_node);
420 gl_debug (DEBUG_VIEW, "END");
423 /*---------------------------------------------------------------------------*/
424 /* PRIVATE. barcode props "changed" callback. */
425 /*---------------------------------------------------------------------------*/
427 bc_props_changed_cb (glWdgtBCProps *text_props,
428 glViewBarcode *view_barcode)
430 glLabelObject *object;
431 glBarcodeStyle style;
437 gl_debug (DEBUG_VIEW, "START");
439 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
441 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
442 &style, &text_flag, &color, &scale);
443 gl_wdgt_bc_props_get_params (text_props, &scale, &color);
445 g_signal_handlers_block_by_func (G_OBJECT(object),
446 update_dialog_cb, view_barcode);
447 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
448 style, text_flag, color, scale);
449 g_signal_handlers_unblock_by_func (G_OBJECT(object),
450 update_dialog_cb, view_barcode);
452 gl_debug (DEBUG_VIEW, "END");
455 /*---------------------------------------------------------------------------*/
456 /* PRIVATE. barcode style "changed" callback. */
457 /*---------------------------------------------------------------------------*/
459 bc_style_changed_cb (glWdgtBCStyle *bc_style,
460 glViewBarcode *view_barcode)
462 glLabelObject *object;
463 glBarcodeStyle style;
469 gl_debug (DEBUG_VIEW, "START");
471 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
473 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
474 &style, &text_flag, &color, &scale);
475 gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag);
477 g_signal_handlers_block_by_func (G_OBJECT(object),
478 update_dialog_cb, view_barcode);
479 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
480 style, text_flag, color, scale);
481 g_signal_handlers_unblock_by_func (G_OBJECT(object),
482 update_dialog_cb, view_barcode);
484 gl_debug (DEBUG_VIEW, "END");
487 /*---------------------------------------------------------------------------*/
488 /* PRIVATE. position "changed" callback. */
489 /*---------------------------------------------------------------------------*/
491 position_changed_cb (glWdgtPosition *position,
492 glViewBarcode *view_barcode)
494 glLabelObject *object;
497 gl_debug (DEBUG_VIEW, "START");
499 gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y);
501 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
503 g_signal_handlers_block_by_func (G_OBJECT(object),
504 update_dialog_cb, view_barcode);
505 gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
506 g_signal_handlers_unblock_by_func (G_OBJECT(object),
507 update_dialog_cb, view_barcode);
509 gl_debug (DEBUG_VIEW, "END");
512 /*---------------------------------------------------------------------------*/
513 /* PRIVATE. label object "changed" callback. */
514 /*---------------------------------------------------------------------------*/
516 update_dialog_cb (glLabelObject *object,
517 glViewBarcode *view_barcode)
520 glTextNode *text_node;
521 glBarcodeStyle style;
527 gl_debug (DEBUG_VIEW, "START");
529 /* Query properties of object. */
530 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
531 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
532 &style, &text_flag, &color, &scale);
533 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
534 merge = gl_label_get_merge (GL_LABEL(object->parent));
536 /* Block widget handlers to prevent recursion */
537 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data),
538 bc_data_changed_cb, view_barcode);
539 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props),
540 bc_props_changed_cb, view_barcode);
541 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style),
542 bc_style_changed_cb, view_barcode);
543 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position),
544 position_changed_cb, view_barcode);
546 /* Update widgets in property dialog */
548 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
549 (merge->type != GL_MERGE_NONE),
551 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
553 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
555 gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
558 /* Unblock widget handlers */
559 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data),
560 bc_data_changed_cb, view_barcode);
561 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props),
562 bc_props_changed_cb, view_barcode);
563 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style),
564 bc_style_changed_cb, view_barcode);
565 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position),
566 position_changed_cb, view_barcode);
568 gl_text_node_free (&text_node);
570 gl_debug (DEBUG_VIEW, "END");
573 /*****************************************************************************/
574 /* Return apropos cursor for create object mode. */
575 /*****************************************************************************/
577 gl_view_barcode_get_create_cursor (void)
579 static GdkCursor *cursor = NULL;
580 GdkPixmap *pixmap_data, *pixmap_mask;
581 GdkColor fg = { 0, 0, 0, 0 };
582 GdkColor bg = { 0, 65535, 65535, 65535 };
584 gl_debug (DEBUG_VIEW, "START");
587 pixmap_data = gdk_bitmap_create_from_data (NULL,
589 cursor_barcode_width,
590 cursor_barcode_height);
591 pixmap_mask = gdk_bitmap_create_from_data (NULL,
592 cursor_barcode_mask_bits,
593 cursor_barcode_mask_width,
594 cursor_barcode_mask_height);
596 gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg,
597 &bg, cursor_barcode_x_hot,
598 cursor_barcode_y_hot);
601 gl_debug (DEBUG_VIEW, "END");
606 /*****************************************************************************/
607 /* Canvas event handler for creating barcode objects. */
608 /*****************************************************************************/
610 gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
614 static gdouble x0, y0;
615 static gboolean dragging = FALSE;
616 static glViewObject *view_barcode;
617 static GObject *object;
619 glTextNode *text_node;
621 gl_debug (DEBUG_VIEW, "");
623 switch (event->type) {
625 case GDK_BUTTON_PRESS:
626 gl_debug (DEBUG_VIEW, "BUTTON_PRESS");
627 switch (event->button.button) {
630 gdk_pointer_grab (GTK_WIDGET (view->canvas)->window,
632 GDK_POINTER_MOTION_MASK |
633 GDK_BUTTON_RELEASE_MASK |
634 GDK_BUTTON_PRESS_MASK,
635 NULL, NULL, event->button.time);
636 gnome_canvas_window_to_world (canvas,
638 event->button.y, &x, &y);
639 object = gl_label_barcode_new (view->label);
640 gl_label_object_set_position (GL_LABEL_OBJECT(object),
642 text_node = gl_text_node_new_from_text ("123456789");
643 gl_label_barcode_set_data (GL_LABEL_BARCODE(object),
645 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
646 GL_BARCODE_STYLE_POSTNET,
648 GNOME_CANVAS_COLOR_A (0,0,0,255),
650 view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object),
660 case GDK_BUTTON_RELEASE:
661 gl_debug (DEBUG_VIEW, "BUTTON_RELEASE");
662 switch (event->button.button) {
665 gdk_pointer_ungrab (event->button.time);
666 gnome_canvas_window_to_world (canvas,
668 event->button.y, &x, &y);
669 gl_label_object_set_position (GL_LABEL_OBJECT(object),
671 gl_view_unselect_all (view);
672 gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
673 gl_view_arrow_mode (view);
680 case GDK_MOTION_NOTIFY:
681 gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
682 if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
683 gnome_canvas_window_to_world (canvas,
685 event->button.y, &x, &y);
686 gl_label_object_set_position (GL_LABEL_OBJECT(object),
699 /*--------------------------------------------------------------------------*/
700 /* PRIVATE. Draw barcode to item (group). */
701 /*--------------------------------------------------------------------------*/
703 draw_barcode (glViewBarcode *view_barcode)
705 glLabelObject *object;
706 GnomeCanvasItem *group, *item;
707 glTextNode *text_node;
708 glBarcodeStyle style;
713 glBarcodeChar *bchar;
716 GList *item_list = NULL;
717 GnomeCanvasPoints *points;
718 gchar *digits, *cstring;
720 GnomeGlyphList *glyphlist;
723 gl_debug (DEBUG_VIEW, "START");
725 /* Query label object and properties */
726 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
727 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
728 &style, &text_flag, &color, &scale);
729 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
730 if (text_node->field_flag) {
731 digits = gl_barcode_default_digits (style);
733 digits = gl_text_node_expand (text_node, NULL);
736 /* get parent item/group to render to. */
737 group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode));
739 /* remove previous items from group. */
740 for (li = view_barcode->private->item_list; li!=NULL; li = li->next) {
741 gl_debug (DEBUG_VIEW, "in loop");
742 gtk_object_destroy (GTK_OBJECT (li->data));
744 gl_debug (DEBUG_VIEW, "1");
745 g_list_free (view_barcode->private->item_list);
746 view_barcode->private->item_list = NULL;
747 gl_debug (DEBUG_VIEW, "2");
750 font = gnome_font_find_closest_from_weight_slant (GL_BARCODE_FONT_FAMILY,
751 GL_BARCODE_FONT_WEIGHT,
755 gbc = gl_barcode_new (style, text_flag, scale, digits);
758 cstring = _("Invalid barcode");
759 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
765 y_offset = 10.0 - gnome_font_get_descender (font);
766 item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
767 gl_canvas_hacktext_get_type (),
770 "glyphlist", glyphlist, NULL);
772 view_barcode->private->item_list =
773 g_list_prepend (view_barcode->private->item_list, item);
776 points = gnome_canvas_points_new (2);
777 for (li = gbc->lines; li != NULL; li = li->next) {
778 line = (glBarcodeLine *) li->data;
780 points->coords[0] = line->x;
781 points->coords[1] = line->y;
782 points->coords[2] = line->x;
783 points->coords[3] = line->y + line->length;
786 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
787 gnome_canvas_line_get_type
788 (), "points", points,
789 "width_units", line->width,
790 "fill_color_rgba", color,
792 view_barcode->private->item_list =
793 g_list_prepend (view_barcode->private->item_list, item);
795 gnome_canvas_points_free (points);
797 for (li = gbc->chars; li != NULL; li = li->next) {
798 bchar = (glBarcodeChar *) li->data;
800 font = gnome_font_find_closest_from_weight_slant (
801 GL_BARCODE_FONT_FAMILY,
802 GL_BARCODE_FONT_WEIGHT,
803 FALSE, bchar->fsize);
804 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
813 bchar->fsize - gnome_font_get_descender (font);
815 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
816 gnome_canvas_hacktext_get_type
817 (), "x", bchar->x, "y",
819 "glyphlist", glyphlist,
822 view_barcode->private->item_list =
823 g_list_prepend (view_barcode->private->item_list, item);
830 gl_barcode_free (&gbc);
833 gl_debug (DEBUG_VIEW, "END");