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 update_dialog_from_move_cb (glLabelObject *object,
110 glViewBarcode *view_barcode);
112 static void draw_barcode (glViewBarcode *view_barcode);
115 /*****************************************************************************/
116 /* Boilerplate object stuff. */
117 /*****************************************************************************/
119 gl_view_barcode_get_type (void)
121 static GType type = 0;
125 sizeof (glViewBarcodeClass),
128 (GClassInitFunc) gl_view_barcode_class_init,
131 sizeof (glViewBarcode),
133 (GInstanceInitFunc) gl_view_barcode_instance_init,
136 type = g_type_register_static (GL_TYPE_VIEW_OBJECT,
137 "glViewBarcode", &info, 0);
144 gl_view_barcode_class_init (glViewBarcodeClass *klass)
146 GObjectClass *object_class = (GObjectClass *) klass;
148 gl_debug (DEBUG_VIEW, "START");
150 parent_class = g_type_class_peek_parent (klass);
152 object_class->finalize = gl_view_barcode_finalize;
154 gl_debug (DEBUG_VIEW, "END");
158 gl_view_barcode_instance_init (glViewBarcode *view_barcode)
160 gl_debug (DEBUG_VIEW, "START");
162 view_barcode->private = g_new0 (glViewBarcodePrivate, 1);
164 gl_debug (DEBUG_VIEW, "END");
168 gl_view_barcode_finalize (GObject *object)
172 gl_debug (DEBUG_VIEW, "START");
174 g_return_if_fail (object && GL_IS_VIEW_BARCODE (object));
176 G_OBJECT_CLASS (parent_class)->finalize (object);
178 gl_debug (DEBUG_VIEW, "END");
181 /*****************************************************************************/
182 /* NEW barcode object view. */
183 /*****************************************************************************/
185 gl_view_barcode_new (glLabelBarcode *object,
188 glViewBarcode *view_barcode;
192 gl_debug (DEBUG_VIEW, "START");
193 g_return_if_fail (object && GL_IS_LABEL_BARCODE (object));
194 g_return_if_fail (view && GL_IS_VIEW (view));
196 view_barcode = g_object_new (gl_view_barcode_get_type(), NULL);
198 gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view);
199 gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode),
200 GL_LABEL_OBJECT(object),
201 GL_VIEW_HIGHLIGHT_SIMPLE);
203 /* Create analogous canvas items. */
204 draw_barcode (view_barcode);
206 g_signal_connect (G_OBJECT (object), "changed",
207 G_CALLBACK (update_view_barcode_cb), view_barcode);
209 /* Create a dialog for controlling/viewing object properties. */
210 dialog = construct_properties_dialog (view_barcode);
211 gl_view_object_set_dialog (GL_VIEW_OBJECT(view_barcode), dialog);
213 gl_debug (DEBUG_VIEW, "END");
215 return GL_VIEW_OBJECT (view_barcode);
218 /*---------------------------------------------------------------------------*/
219 /* PRIVATE. label object "changed" callback. */
220 /*---------------------------------------------------------------------------*/
222 update_view_barcode_cb (glLabelObject *object,
223 glViewBarcode *view_barcode)
226 GnomeCanvasItem *group;
228 gl_debug (DEBUG_VIEW, "START");
230 view = gl_view_object_get_view (GL_VIEW_OBJECT(view_barcode));
232 /* Adjust appearance of analogous canvas items. */
233 draw_barcode (view_barcode);
235 /* Adjust highlight */
236 gl_view_object_update_highlight (GL_VIEW_OBJECT(view_barcode));
238 gl_debug (DEBUG_VIEW, "END");
241 /*****************************************************************************/
242 /* Create a properties dialog for a barcode object. */
243 /*****************************************************************************/
245 construct_properties_dialog (glViewBarcode *view_barcode)
247 GtkWidget *dialog, *wsection;
248 BonoboWindow *win = glabels_get_active_window ();
249 glLabelObject *object;
250 gdouble x, y, w, h, label_width, label_height;
251 glTextNode *text_node;
252 glBarcodeStyle style;
257 GtkSizeGroup *label_size_group;
259 gl_debug (DEBUG_VIEW, "START");
261 /* retrieve object and query parameters */
262 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
263 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
264 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
265 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
266 &style, &text_flag, &color, &scale);
267 gl_label_get_size (GL_LABEL(object->parent),
268 &label_width, &label_height);
269 merge = gl_label_get_merge (GL_LABEL(object->parent));
271 /*-----------------------------------------------------------------*/
273 /*-----------------------------------------------------------------*/
274 dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"),
276 GTK_DIALOG_DESTROY_WITH_PARENT,
280 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
281 g_signal_connect (G_OBJECT (dialog), "response",
282 G_CALLBACK (response_cb), view_barcode);
284 label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
286 /*---------------------------*/
288 /*---------------------------*/
289 wsection = gl_hig_category_new (_("Data"));
290 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
293 view_barcode->private->bc_data =
294 gl_wdgt_bc_data_new (merge->field_defs);
295 gl_wdgt_bc_data_set_label_size_group (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
297 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
298 (merge->type != GL_MERGE_NONE),
300 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
301 view_barcode->private->bc_data);
302 g_signal_connect ( G_OBJECT(view_barcode->private->bc_data),
303 "changed", G_CALLBACK (bc_data_changed_cb),
307 /*---------------------------*/
308 /* Appearance section */
309 /*---------------------------*/
310 wsection = gl_hig_category_new (_("Properties"));
311 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
313 /* barcode props entry */
314 gl_debug (DEBUG_VIEW, "Creating props entry...");
315 view_barcode->private->bc_props = gl_wdgt_bc_props_new ();
316 gl_wdgt_bc_props_set_label_size_group (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
318 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
320 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
321 view_barcode->private->bc_props);
322 g_signal_connect ( G_OBJECT(view_barcode->private->bc_props),
323 "changed", G_CALLBACK (bc_props_changed_cb),
326 /* Barcode style widget */
327 view_barcode->private->bc_style = gl_wdgt_bc_style_new ();
328 gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
330 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
332 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
333 view_barcode->private->bc_style);
334 g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
335 "changed", G_CALLBACK (bc_style_changed_cb),
339 /*----------------------------*/
340 /* Position section */
341 /*----------------------------*/
342 wsection = gl_hig_category_new (_("Position"));
343 gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
345 /* ------ Position Frame ------ */
346 view_barcode->private->position = gl_wdgt_position_new ();
347 gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_barcode->private->position),
349 gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position),
351 label_width, label_height);
352 gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
353 view_barcode->private->position);
354 g_signal_connect (G_OBJECT (view_barcode->private->position),
356 G_CALLBACK(position_changed_cb), view_barcode);
359 /*----------------------------*/
360 /* Track object changes. */
361 /*----------------------------*/
362 g_signal_connect (G_OBJECT (object), "changed",
363 G_CALLBACK (update_dialog_cb), view_barcode);
364 g_signal_connect (G_OBJECT (object), "moved",
365 G_CALLBACK (update_dialog_from_move_cb),
368 gl_debug (DEBUG_VIEW, "END");
373 /*---------------------------------------------------------------------------*/
374 /* PRIVATE. "Response" callback. */
375 /*---------------------------------------------------------------------------*/
377 response_cb (GtkDialog *dialog,
379 glViewBarcode *view_barcode)
381 gl_debug (DEBUG_VIEW, "START");
383 g_return_if_fail(dialog != NULL);
384 g_return_if_fail(GTK_IS_DIALOG(dialog));
387 case GTK_RESPONSE_CLOSE:
388 gtk_widget_hide (GTK_WIDGET(dialog));
391 g_assert_not_reached();
394 gl_debug (DEBUG_VIEW, "END");
397 /*---------------------------------------------------------------------------*/
398 /* PRIVATE. barcode data "changed" callback. */
399 /*---------------------------------------------------------------------------*/
401 bc_data_changed_cb (glWdgtBCData *bc_data,
402 glViewBarcode *view_barcode)
404 glLabelObject *object;
405 glTextNode *text_node;
407 gl_debug (DEBUG_VIEW, "START");
409 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
411 text_node = gl_wdgt_bc_data_get_data (bc_data);
413 g_signal_handlers_block_by_func (G_OBJECT(object),
414 update_dialog_cb, view_barcode);
415 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
416 g_signal_handlers_unblock_by_func (G_OBJECT(object),
417 update_dialog_cb, view_barcode);
419 gl_text_node_free (&text_node);
421 gl_debug (DEBUG_VIEW, "END");
424 /*---------------------------------------------------------------------------*/
425 /* PRIVATE. barcode props "changed" callback. */
426 /*---------------------------------------------------------------------------*/
428 bc_props_changed_cb (glWdgtBCProps *text_props,
429 glViewBarcode *view_barcode)
431 glLabelObject *object;
432 glBarcodeStyle style;
438 gl_debug (DEBUG_VIEW, "START");
440 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
442 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
443 &style, &text_flag, &color, &scale);
444 gl_wdgt_bc_props_get_params (text_props, &scale, &color);
446 g_signal_handlers_block_by_func (G_OBJECT(object),
447 update_dialog_cb, view_barcode);
448 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
449 style, text_flag, color, scale);
450 g_signal_handlers_unblock_by_func (G_OBJECT(object),
451 update_dialog_cb, view_barcode);
453 gl_debug (DEBUG_VIEW, "END");
456 /*---------------------------------------------------------------------------*/
457 /* PRIVATE. barcode style "changed" callback. */
458 /*---------------------------------------------------------------------------*/
460 bc_style_changed_cb (glWdgtBCStyle *bc_style,
461 glViewBarcode *view_barcode)
463 glLabelObject *object;
464 glBarcodeStyle style;
470 gl_debug (DEBUG_VIEW, "START");
472 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
474 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
475 &style, &text_flag, &color, &scale);
476 gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag);
478 g_signal_handlers_block_by_func (G_OBJECT(object),
479 update_dialog_cb, view_barcode);
480 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
481 style, text_flag, color, scale);
482 g_signal_handlers_unblock_by_func (G_OBJECT(object),
483 update_dialog_cb, view_barcode);
485 gl_debug (DEBUG_VIEW, "END");
488 /*---------------------------------------------------------------------------*/
489 /* PRIVATE. position "changed" callback. */
490 /*---------------------------------------------------------------------------*/
492 position_changed_cb (glWdgtPosition *position,
493 glViewBarcode *view_barcode)
495 glLabelObject *object;
498 gl_debug (DEBUG_VIEW, "START");
500 gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y);
502 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
504 g_signal_handlers_block_by_func (G_OBJECT(object),
505 update_dialog_cb, view_barcode);
506 gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y);
507 g_signal_handlers_unblock_by_func (G_OBJECT(object),
508 update_dialog_cb, view_barcode);
510 gl_debug (DEBUG_VIEW, "END");
513 /*---------------------------------------------------------------------------*/
514 /* PRIVATE. label object "changed" callback. */
515 /*---------------------------------------------------------------------------*/
517 update_dialog_cb (glLabelObject *object,
518 glViewBarcode *view_barcode)
521 glTextNode *text_node;
522 glBarcodeStyle style;
528 gl_debug (DEBUG_VIEW, "START");
530 /* Query properties of object. */
531 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
532 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
533 &style, &text_flag, &color, &scale);
534 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
535 merge = gl_label_get_merge (GL_LABEL(object->parent));
537 /* Block widget handlers to prevent recursion */
538 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data),
539 bc_data_changed_cb, view_barcode);
540 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props),
541 bc_props_changed_cb, view_barcode);
542 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style),
543 bc_style_changed_cb, view_barcode);
544 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position),
545 position_changed_cb, view_barcode);
547 /* Update widgets in property dialog */
549 gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
550 (merge->type != GL_MERGE_NONE),
552 gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
554 gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
556 gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
559 /* Unblock widget handlers */
560 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data),
561 bc_data_changed_cb, view_barcode);
562 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props),
563 bc_props_changed_cb, view_barcode);
564 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style),
565 bc_style_changed_cb, view_barcode);
566 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position),
567 position_changed_cb, view_barcode);
569 gl_text_node_free (&text_node);
571 gl_debug (DEBUG_VIEW, "END");
574 /*---------------------------------------------------------------------------*/
575 /* PRIVATE. label object "moved" callback. */
576 /*---------------------------------------------------------------------------*/
578 update_dialog_from_move_cb (glLabelObject *object,
581 glViewBarcode *view_barcode)
585 gl_debug (DEBUG_VIEW, "START");
587 /* Query properties of object. */
588 gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
590 /* Block widget handlers to prevent recursion */
591 g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position),
592 position_changed_cb, view_barcode);
594 /* Update widgets in property dialog */
595 gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
598 /* Unblock widget handlers */
599 g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position),
600 position_changed_cb, view_barcode);
602 gl_debug (DEBUG_VIEW, "END");
605 /*****************************************************************************/
606 /* Return apropos cursor for create object mode. */
607 /*****************************************************************************/
609 gl_view_barcode_get_create_cursor (void)
611 static GdkCursor *cursor = NULL;
612 GdkPixmap *pixmap_data, *pixmap_mask;
613 GdkColor fg = { 0, 0, 0, 0 };
614 GdkColor bg = { 0, 65535, 65535, 65535 };
616 gl_debug (DEBUG_VIEW, "START");
619 pixmap_data = gdk_bitmap_create_from_data (NULL,
621 cursor_barcode_width,
622 cursor_barcode_height);
623 pixmap_mask = gdk_bitmap_create_from_data (NULL,
624 cursor_barcode_mask_bits,
625 cursor_barcode_mask_width,
626 cursor_barcode_mask_height);
628 gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg,
629 &bg, cursor_barcode_x_hot,
630 cursor_barcode_y_hot);
633 gl_debug (DEBUG_VIEW, "END");
638 /*****************************************************************************/
639 /* Canvas event handler for creating barcode objects. */
640 /*****************************************************************************/
642 gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
646 static gdouble x0, y0;
647 static gboolean dragging = FALSE;
648 static glViewObject *view_barcode;
649 static GObject *object;
651 glTextNode *text_node;
653 gl_debug (DEBUG_VIEW, "");
655 switch (event->type) {
657 case GDK_BUTTON_PRESS:
658 gl_debug (DEBUG_VIEW, "BUTTON_PRESS");
659 switch (event->button.button) {
662 gdk_pointer_grab (GTK_WIDGET (view->canvas)->window,
664 GDK_POINTER_MOTION_MASK |
665 GDK_BUTTON_RELEASE_MASK |
666 GDK_BUTTON_PRESS_MASK,
667 NULL, NULL, event->button.time);
668 gnome_canvas_window_to_world (canvas,
670 event->button.y, &x, &y);
671 object = gl_label_barcode_new (view->label);
672 gl_label_object_set_position (GL_LABEL_OBJECT(object),
674 text_node = gl_text_node_new_from_text ("123456789");
675 gl_label_barcode_set_data (GL_LABEL_BARCODE(object),
677 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
678 GL_BARCODE_STYLE_POSTNET,
680 gl_color_set_opacity (gl_prefs->default_line_color, 0.5),
682 view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object),
692 case GDK_BUTTON_RELEASE:
693 gl_debug (DEBUG_VIEW, "BUTTON_RELEASE");
694 switch (event->button.button) {
697 gdk_pointer_ungrab (event->button.time);
698 gnome_canvas_window_to_world (canvas,
700 event->button.y, &x, &y);
701 gl_label_object_set_position (GL_LABEL_OBJECT(object),
703 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
704 GL_BARCODE_STYLE_POSTNET,
706 gl_prefs->default_line_color,
708 gl_view_unselect_all (view);
709 gl_view_object_select (GL_VIEW_OBJECT(view_barcode));
710 gl_view_arrow_mode (view);
717 case GDK_MOTION_NOTIFY:
718 gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
719 if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
720 gnome_canvas_window_to_world (canvas,
722 event->motion.y, &x, &y);
723 gl_label_object_set_position (GL_LABEL_OBJECT(object),
736 /*--------------------------------------------------------------------------*/
737 /* PRIVATE. Draw barcode to item (group). */
738 /*--------------------------------------------------------------------------*/
740 draw_barcode (glViewBarcode *view_barcode)
742 glLabelObject *object;
743 GnomeCanvasItem *group, *item;
744 glTextNode *text_node;
745 glBarcodeStyle style;
750 glBarcodeChar *bchar;
753 GList *item_list = NULL;
754 GnomeCanvasPoints *points;
755 gchar *digits, *cstring;
757 GnomeGlyphList *glyphlist;
760 gl_debug (DEBUG_VIEW, "START");
762 /* Query label object and properties */
763 object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
764 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
765 &style, &text_flag, &color, &scale);
766 text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
767 if (text_node->field_flag) {
768 digits = gl_barcode_default_digits (style);
770 digits = gl_text_node_expand (text_node, NULL);
773 /* get parent item/group to render to. */
774 group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode));
776 /* remove previous items from group. */
777 for (li = view_barcode->private->item_list; li!=NULL; li = li->next) {
778 gl_debug (DEBUG_VIEW, "in loop");
779 gtk_object_destroy (GTK_OBJECT (li->data));
781 gl_debug (DEBUG_VIEW, "1");
782 g_list_free (view_barcode->private->item_list);
783 view_barcode->private->item_list = NULL;
784 gl_debug (DEBUG_VIEW, "2");
787 font = gnome_font_find_closest_from_weight_slant (GL_BARCODE_FONT_FAMILY,
788 GL_BARCODE_FONT_WEIGHT,
792 gbc = gl_barcode_new (style, text_flag, scale, digits);
795 cstring = _("Invalid barcode");
796 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
802 y_offset = 10.0 - gnome_font_get_descender (font);
803 item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
804 gl_canvas_hacktext_get_type (),
807 "glyphlist", glyphlist, NULL);
809 view_barcode->private->item_list =
810 g_list_prepend (view_barcode->private->item_list, item);
813 points = gnome_canvas_points_new (2);
814 for (li = gbc->lines; li != NULL; li = li->next) {
815 line = (glBarcodeLine *) li->data;
817 points->coords[0] = line->x;
818 points->coords[1] = line->y;
819 points->coords[2] = line->x;
820 points->coords[3] = line->y + line->length;
823 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
824 gnome_canvas_line_get_type
825 (), "points", points,
826 "width_units", line->width,
827 "fill_color_rgba", color,
829 view_barcode->private->item_list =
830 g_list_prepend (view_barcode->private->item_list, item);
832 gnome_canvas_points_free (points);
834 for (li = gbc->chars; li != NULL; li = li->next) {
835 bchar = (glBarcodeChar *) li->data;
837 font = gnome_font_find_closest_from_weight_slant (
838 GL_BARCODE_FONT_FAMILY,
839 GL_BARCODE_FONT_WEIGHT,
840 FALSE, bchar->fsize);
841 glyphlist = gnome_glyphlist_from_text_sized_dumb (font,
850 bchar->fsize - gnome_font_get_descender (font);
852 gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
853 gnome_canvas_hacktext_get_type
854 (), "x", bchar->x, "y",
856 "glyphlist", glyphlist,
859 view_barcode->private->item_list =
860 g_list_prepend (view_barcode->private->item_list, item);
867 gl_barcode_free (&gbc);
870 gl_debug (DEBUG_VIEW, "END");