From: Jim Evins Date: Tue, 23 May 2006 01:26:54 +0000 (+0000) Subject: 2006-05-22 Jim Evins X-Git-Tag: glabels-2_3_0~374 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1089d9b2f104ef8d172aa3304ff7e90c88b2d68c;p=glabels 2006-05-22 Jim Evins * src/print.c: (draw_barcode_object): Don't print "Invalid barcode data" if data field is empty. Patch provided by Darren Warner . Fixes Bug #1479839. * AUTHORS: Added acknowledgment for above patch. * src/bc-gnubarcode.c: (gl_barcode_gnubarcode_new): * src/bc-postnet.c: (postnet_code): Removed "Invalid barcode data" warnings from stderr. * src/view-barcode.c: (draw_barcode): Draw box around barcode extent if data empty or invalid. Center a message whether the data is empty or invalid in box. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@591 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/AUTHORS b/glabels2/AUTHORS index 21a47bb0..70e0c4da 100644 --- a/glabels2/AUTHORS +++ b/glabels2/AUTHORS @@ -47,6 +47,7 @@ Glabels includes contributions from: nestor di -- excellent splash screen that first appeared in 0.4.3: + Darren Warner Javier Donaire Segarra Alessandro Zummo José Dapena Paz diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index be402391..9344a8a1 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,17 @@ +2006-05-22 Jim Evins + + * src/print.c: (draw_barcode_object): + Don't print "Invalid barcode data" if data field is empty. Patch provided + by Darren Warner . Fixes Bug #1479839. + * AUTHORS: + Added acknowledgment for above patch. + * src/bc-gnubarcode.c: (gl_barcode_gnubarcode_new): + * src/bc-postnet.c: (postnet_code): + Removed "Invalid barcode data" warnings from stderr. + * src/view-barcode.c: (draw_barcode): + Draw box around barcode extent if data empty or invalid. Center a + message whether the data is empty or invalid in box. + 2006-05-22 Jim Evins * src/print.c: (draw_text_object): diff --git a/glabels2/src/bc-gnubarcode.c b/glabels2/src/bc-gnubarcode.c index 40a51fe9..c24b587a 100644 --- a/glabels2/src/bc-gnubarcode.c +++ b/glabels2/src/bc-gnubarcode.c @@ -193,7 +193,6 @@ gl_barcode_gnubarcode_new (const gchar *id, Barcode_Encode (bci, flags); if (!bci->partial || !bci->textinfo) { - g_message ("Barcode Data Invalid"); Barcode_Delete (bci); return NULL; } diff --git a/glabels2/src/bc-postnet.c b/glabels2/src/bc-postnet.c index 694069eb..9979cde8 100644 --- a/glabels2/src/bc-postnet.c +++ b/glabels2/src/bc-postnet.c @@ -176,9 +176,6 @@ postnet_code (const gchar *digits) len++; } } - if ((len != 5) && (len != 9) && (len != 11)) { - g_message ("Invalid POSTNET length %d, should be 5(ZIP), 9(ZIP+4), or 11(DPBC)", len); - } /* Create correction character */ d = (10 - (sum % 10)) % 10; diff --git a/glabels2/src/print.c b/glabels2/src/print.c index bdbe574b..5856a025 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -1282,6 +1282,16 @@ draw_barcode_object (PrintInfo *pi, gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); text = gl_text_node_expand (text_node, record); + + if (text == NULL || *text == '\0') { + + g_free(text); + gl_text_node_free(&text_node); + g_free(id); + + return; + } + gbc = gl_barcode_new (id, text_flag, checksum_flag, w, h, text); g_free (text); gl_text_node_free (&text_node); diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 35185f56..894f471f 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -537,25 +537,27 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, static void draw_barcode (glViewBarcode *view_barcode) { - glLabelObject *object; - GnomeCanvasItem *item; - glTextNode *text_node; - gchar *id; - gboolean text_flag; - gboolean checksum_flag; - glColorNode *color_node; - gdouble w, h; - glBarcodeLine *line; - glBarcodeChar *bchar; - glBarcode *gbc; - GList *li; - GList *item_list = NULL; + glLabelObject *object; + GnomeCanvasItem *item; + glTextNode *text_node; + gchar *id; + gboolean text_flag; + gboolean checksum_flag; + glColorNode *color_node; + gdouble w, h; + glBarcodeLine *line; + glBarcodeChar *bchar; + glBarcode *gbc; + GList *li; + GList *item_list = NULL; GnomeCanvasPoints *points; - gchar *digits, *cstring; - GnomeFont *font; - GnomeGlyphList *glyphlist; - gdouble y_offset; - guint format_digits; + gchar *digits, *cstring; + GnomeFont *font; + GnomeGlyphList *glyphlist; + gdouble y_offset; + guint format_digits; + ArtDRect bbox; + gdouble affine[6]; gl_debug (DEBUG_VIEW, "START"); @@ -595,17 +597,40 @@ draw_barcode (glViewBarcode *view_barcode) gbc = gl_barcode_new (id, text_flag, checksum_flag, w, h, digits); if (gbc == NULL) { - cstring = _("Invalid barcode data"); + item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode), + gnome_canvas_rect_get_type (), + "x1", 0.0, + "y1", 0.0, + "x2", w, + "y2", h, + "outline_color_rgba", color_node->color, + "width_pixels", 1, + NULL); + view_barcode->private->item_list = + g_list_prepend (view_barcode->private->item_list, item); + + if (digits == NULL || *digits == '\0') + { + cstring = _("Barcode data empty"); + } + else + { + cstring = _("Invalid barcode data"); + } + glyphlist = gnome_glyphlist_from_text_sized_dumb (font, color_node->color, 0.0, 0.0, (guchar *)cstring, strlen (cstring)); y_offset = 10.0 - fabs (gnome_font_get_descender (font)); + art_affine_identity (affine); + gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox); + item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode), gl_canvas_hacktext_get_type (), - "x", 0.0, - "y", y_offset, + "x", w/2 - bbox.x1/2, + "y", h/2 - bbox.y1/2 + y_offset, "glyphlist", glyphlist, NULL); gnome_glyphlist_unref (glyphlist);