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, *notebook, *wvbox, *wbutton;
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;
253 gl_debug (DEBUG_VIEW, "START");
255 /* retrieve object and query parameters */
256 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
257 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
258 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
259 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
260 &style, &text_flag, &color, &scale);
261 gl_label_get_size (GL_LABEL(object->parent),
262 &label_width, &label_height);
263 merge = gl_label_get_merge (GL_LABEL(object->parent));
265 /*-----------------------------------------------------------------*/
266 /* Build dialog with notebook. */
267 /*-----------------------------------------------------------------*/
268 gl_debug (DEBUG_VIEW, "Creating dialog...");
269 dialog = gtk_dialog_new_with_buttons ( _("Edit barcode object properties"),
271 GTK_DIALOG_DESTROY_WITH_PARENT,
275 g_signal_connect (G_OBJECT (dialog), "response",
276 G_CALLBACK (response_cb), view_barcode);
278 notebook = gtk_notebook_new ();
279 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
280 notebook, TRUE, TRUE, 0);
282 /*---------------------------*/
283 /* Data Notebook Tab */
284 /*---------------------------*/
285 gl_debug (DEBUG_VIEW, "Creating data tab...");
286 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
287 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
288 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
289 gtk_label_new (_("Data")));
292 gl_debug (DEBUG_VIEW, "Creating data entry...");
293 view_barcode->private->bc_data =
294 gl_wdgt_bc_data_new (_("Barcode data"), merge->field_defs);
295 gl_debug (DEBUG_VIEW, "1");
296 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
297 (merge->type != GL_MERGE_NONE),
299 gl_debug (DEBUG_VIEW, "2");
300 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_data,
302 gl_debug (DEBUG_VIEW, "3");
303 g_signal_connect ( G_OBJECT(view_barcode->private->bc_data),
304 "changed", G_CALLBACK (bc_data_changed_cb),
308 /*---------------------------*/
309 /* Appearance Notebook Tab */
310 /*---------------------------*/
311 gl_debug (DEBUG_VIEW, "Creating props tab...");
312 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
313 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
314 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
315 gtk_label_new (_("Appearance")));
317 /* barcode props entry */
318 gl_debug (DEBUG_VIEW, "Creating props entry...");
319 view_barcode->private->bc_props =
320 gl_wdgt_bc_props_new (_("Barcode Properties"));
321 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
323 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_props,
325 g_signal_connect ( G_OBJECT(view_barcode->private->bc_props),
326 "changed", G_CALLBACK (bc_props_changed_cb),
329 /* ------ Barcode Style Frame ------ */
330 view_barcode->private->bc_style = gl_wdgt_bc_style_new (_("Style"));
331 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
333 gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_style,
335 g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
336 "changed", G_CALLBACK (bc_style_changed_cb),
340 /*----------------------------*/
341 /* Position/Size Notebook Tab */
342 /*----------------------------*/
343 gl_debug (DEBUG_VIEW, "Creating position tab...");
344 wvbox = gtk_vbox_new (FALSE, GNOME_PAD);
345 gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10);
346 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox,
347 gtk_label_new (_("Position")));
349 /* ------ Position Frame ------ */
350 gl_debug (DEBUG_VIEW, "Creating position entry...");
351 view_barcode->private->position = gl_wdgt_position_new (_("Position"));
352 gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position),
354 label_width, label_height);
355 gtk_box_pack_start (GTK_BOX (wvbox),
356 view_barcode->private->position,
358 g_signal_connect (G_OBJECT (view_barcode->private->position),
360 G_CALLBACK(position_changed_cb), view_barcode);
363 /*----------------------------*/
364 /* Track object changes. */
365 /*----------------------------*/
366 g_signal_connect (G_OBJECT (object), "changed",
367 G_CALLBACK (update_dialog_cb), view_barcode);
369 gl_debug (DEBUG_VIEW, "END");
374 /*---------------------------------------------------------------------------*/
375 /* PRIVATE. "Response" callback. */
376 /*---------------------------------------------------------------------------*/
378 response_cb (GtkDialog *dialog,
380 glViewBarcode *view_barcode)
382 gl_debug (DEBUG_VIEW, "START");
384 g_return_if_fail(dialog != NULL);
385 g_return_if_fail(GTK_IS_DIALOG(dialog));
388 case GTK_RESPONSE_CLOSE:
389 gtk_widget_hide (GTK_WIDGET(dialog));
392 g_assert_not_reached();
395 gl_debug (DEBUG_VIEW, "END");
398 /*---------------------------------------------------------------------------*/
399 /* PRIVATE. barcode data "changed" callback. */
400 /*---------------------------------------------------------------------------*/
402 bc_data_changed_cb (glWdgtBCData *bc_data,
403 glViewBarcode *view_barcode)
405 glLabelObject *object;
406 glTextNode *text_node;
408 gl_debug (DEBUG_VIEW, "START");
410 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
412 text_node = gl_wdgt_bc_data_get_data (bc_data);
414 g_signal_handlers_block_by_func (G_OBJECT(object),
415 update_dialog_cb, view_barcode);
416 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
417 g_signal_handlers_unblock_by_func (G_OBJECT(object),
418 update_dialog_cb, view_barcode);
420 gl_text_node_free (&text_node);
422 gl_debug (DEBUG_VIEW, "END");
425 /*---------------------------------------------------------------------------*/
426 /* PRIVATE. barcode props "changed" callback. */
427 /*---------------------------------------------------------------------------*/
429 bc_props_changed_cb (glWdgtBCProps *text_props,
430 glViewBarcode *view_barcode)
432 glLabelObject *object;
433 glBarcodeStyle style;
439 gl_debug (DEBUG_VIEW, "START");
441 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
443 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
444 &style, &text_flag, &color, &scale);
445 gl_wdgt_bc_props_get_params (text_props, &scale, &color);
447 g_signal_handlers_block_by_func (G_OBJECT(object),
448 update_dialog_cb, view_barcode);
449 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
450 style, text_flag, color, scale);
451 g_signal_handlers_unblock_by_func (G_OBJECT(object),
452 update_dialog_cb, view_barcode);
454 gl_debug (DEBUG_VIEW, "END");
457 /*---------------------------------------------------------------------------*/
458 /* PRIVATE. barcode style "changed" callback. */
459 /*---------------------------------------------------------------------------*/
461 bc_style_changed_cb (glWdgtBCStyle *bc_style,
462 glViewBarcode *view_barcode)
464 glLabelObject *object;
465 glBarcodeStyle style;
471 gl_debug (DEBUG_VIEW, "START");
473 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
475 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
476 &style, &text_flag, &color, &scale);
477 gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag);
479 g_signal_handlers_block_by_func (G_OBJECT(object),
480 update_dialog_cb, view_barcode);
481 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
482 style, text_flag, color, scale);
483 g_signal_handlers_unblock_by_func (G_OBJECT(object),
484 update_dialog_cb, view_barcode);
486 gl_debug (DEBUG_VIEW, "END");
489 /*---------------------------------------------------------------------------*/
490 /* PRIVATE. position "changed" callback. */
491 /*---------------------------------------------------------------------------*/
493 position_changed_cb (glWdgtPosition *position,
494 glViewBarcode *view_barcode)
496 glLabelObject *object;
499 gl_debug (DEBUG_VIEW, "START");
501 gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y);
503 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
505 g_signal_handlers_block_by_func (G_OBJECT(object),
506 update_dialog_cb, view_barcode);
507 gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
508 g_signal_handlers_unblock_by_func (G_OBJECT(object),
509 update_dialog_cb, view_barcode);
511 gl_debug (DEBUG_VIEW, "END");
514 /*---------------------------------------------------------------------------*/
515 /* PRIVATE. label object "changed" callback. */
516 /*---------------------------------------------------------------------------*/
518 update_dialog_cb (glLabelObject *object,
519 glViewBarcode *view_barcode)
522 glTextNode *text_node;
523 glBarcodeStyle style;
529 gl_debug (DEBUG_VIEW, "START");
531 /* Query properties of object. */
532 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
533 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
534 &style, &text_flag, &color, &scale);
535 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
536 merge = gl_label_get_merge (GL_LABEL(object->parent));
538 /* Block widget handlers to prevent recursion */
539 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data),
540 bc_data_changed_cb, view_barcode);
541 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props),
542 bc_props_changed_cb, view_barcode);
543 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style),
544 bc_style_changed_cb, view_barcode);
545 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position),
546 position_changed_cb, view_barcode);
548 /* Update widgets in property dialog */
550 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
551 (merge->type != GL_MERGE_NONE),
553 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
555 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
557 gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
560 /* Unblock widget handlers */
561 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data),
562 bc_data_changed_cb, view_barcode);
563 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props),
564 bc_props_changed_cb, view_barcode);
565 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style),
566 bc_style_changed_cb, view_barcode);
567 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position),
568 position_changed_cb, view_barcode);
570 gl_text_node_free (&text_node);
572 gl_debug (DEBUG_VIEW, "END");
575 /*****************************************************************************/
576 /* Return apropos cursor for create object mode. */
577 /*****************************************************************************/
579 gl_view_barcode_get_create_cursor (void)
581 static GdkCursor *cursor = NULL;
582 GdkPixmap *pixmap_data, *pixmap_mask;
583 GdkColor fg = { 0, 0, 0, 0 };
584 GdkColor bg = { 0, 65535, 65535, 65535 };
586 gl_debug (DEBUG_VIEW, "START");
589 pixmap_data = gdk_bitmap_create_from_data (NULL,
591 cursor_barcode_width,
592 cursor_barcode_height);
593 pixmap_mask = gdk_bitmap_create_from_data (NULL,
594 cursor_barcode_mask_bits,
595 cursor_barcode_mask_width,
596 cursor_barcode_mask_height);
598 gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg,
599 &bg, cursor_barcode_x_hot,
600 cursor_barcode_y_hot);
603 gl_debug (DEBUG_VIEW, "END");
608 /*****************************************************************************/
609 /* Canvas event handler for creating barcode objects. */
610 /*****************************************************************************/
612 gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
616 static gdouble x0, y0;
617 static gboolean dragging = FALSE;
618 static glViewObject *view_barcode;
619 static GObject *object;
621 glTextNode *text_node;
623 gl_debug (DEBUG_VIEW, "");
625 switch (event->type) {
627 case GDK_BUTTON_PRESS:
628 gl_debug (DEBUG_VIEW, "BUTTON_PRESS");
629 switch (event->button.button) {
632 gdk_pointer_grab (GTK_WIDGET (view->canvas)->window,
634 GDK_POINTER_MOTION_MASK |
635 GDK_BUTTON_RELEASE_MASK |
636 GDK_BUTTON_PRESS_MASK,
637 NULL, NULL, event->button.time);
638 gnome_canvas_window_to_world (canvas,
640 event->button.y, &x, &y);
641 object = gl_label_barcode_new (view->label);
642 gl_label_object_set_position (GL_LABEL_OBJECT(object),
644 text_node = gl_text_node_new_from_text ("123456789");
645 gl_label_barcode_set_data (GL_LABEL_BARCODE(object),
647 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
648 GL_BARCODE_STYLE_POSTNET,
650 gl_color_set_opacity (gl_prefs->default_line_color, 0.5),
652 view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object),
662 case GDK_BUTTON_RELEASE:
663 gl_debug (DEBUG_VIEW, "BUTTON_RELEASE");
664 switch (event->button.button) {
667 gdk_pointer_ungrab (event->button.time);
668 gnome_canvas_window_to_world (canvas,
670 event->button.y, &x, &y);
671 gl_label_object_set_position (GL_LABEL_OBJECT(object),
673 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
674 GL_BARCODE_STYLE_POSTNET,
676 gl_prefs->default_line_color,
678 gl_view_unselect_all (view);
679 gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
680 gl_view_arrow_mode (view);
687 case GDK_MOTION_NOTIFY:
688 gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
689 if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
690 gnome_canvas_window_to_world (canvas,
692 event->motion.y, &x, &y);
693 gl_label_object_set_position (GL_LABEL_OBJECT(object),
706 /*--------------------------------------------------------------------------*/
707 /* PRIVATE. Draw barcode to item (group). */
708 /*--------------------------------------------------------------------------*/
710 draw_barcode (glViewBarcode *view_barcode)
712 glLabelObject *object;
713 GnomeCanvasItem *group, *item;
714 glTextNode *text_node;
715 glBarcodeStyle style;
720 glBarcodeChar *bchar;
723 GList *item_list = NULL;
724 GnomeCanvasPoints *points;
725 gchar *digits, *cstring;
727 GnomeGlyphList *glyphlist;
730 gl_debug (DEBUG_VIEW, "START");
732 /* Query label object and properties */
733 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
734 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
735 &style, &text_flag, &color, &scale);
736 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
737 if (text_node->field_flag) {
738 digits = gl_barcode_default_digits (style);
740 digits = gl_text_node_expand (text_node, NULL);
743 /* get parent item/group to render to. */
744 group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode));
746 /* remove previous items from group. */
747 for (li = view_barcode->private->item_list; li!=NULL; li = li->next) {
748 gl_debug (DEBUG_VIEW, "in loop");
749 gtk_object_destroy (GTK_OBJECT (li->data));
751 gl_debug (DEBUG_VIEW, "1");
752 g_list_free (view_barcode->private->item_list);
753 view_barcode->private->item_list = NULL;
754 gl_debug (DEBUG_VIEW, "2");
757 font = gnome_font_find_closest_from_weight_slant (GL_BARCODE_FONT_FAMILY,
758 GL_BARCODE_FONT_WEIGHT,
762 gbc = gl_barcode_new (style, text_flag, scale, digits);
765 cstring = _("Invalid barcode");
766 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
772 y_offset = 10.0 - gnome_font_get_descender (font);
773 item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
774 gl_canvas_hacktext_get_type (),
777 "glyphlist", glyphlist, NULL);
779 view_barcode->private->item_list =
780 g_list_prepend (view_barcode->private->item_list, item);
783 points = gnome_canvas_points_new (2);
784 for (li = gbc->lines; li != NULL; li = li->next) {
785 line = (glBarcodeLine *) li->data;
787 points->coords[0] = line->x;
788 points->coords[1] = line->y;
789 points->coords[2] = line->x;
790 points->coords[3] = line->y + line->length;
793 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
794 gnome_canvas_line_get_type
795 (), "points", points,
796 "width_units", line->width,
797 "fill_color_rgba", color,
799 view_barcode->private->item_list =
800 g_list_prepend (view_barcode->private->item_list, item);
802 gnome_canvas_points_free (points);
804 for (li = gbc->chars; li != NULL; li = li->next) {
805 bchar = (glBarcodeChar *) li->data;
807 font = gnome_font_find_closest_from_weight_slant (
808 GL_BARCODE_FONT_FAMILY,
809 GL_BARCODE_FONT_WEIGHT,
810 FALSE, bchar->fsize);
811 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
820 bchar->fsize - gnome_font_get_descender (font);
822 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
823 gnome_canvas_hacktext_get_type
824 (), "x", bchar->x, "y",
826 "glyphlist", glyphlist,
829 view_barcode->private->item_list =
830 g_list_prepend (view_barcode->private->item_list, item);
837 gl_barcode_free (&gbc);
840 gl_debug (DEBUG_VIEW, "END");