]> git.sur5r.net Git - glabels/commitdiff
2006-05-22 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Tue, 23 May 2006 01:26:54 +0000 (01:26 +0000)
committerJim Evins <evins@snaught.com>
Tue, 23 May 2006 01:26:54 +0000 (01:26 +0000)
* src/print.c: (draw_barcode_object):
Don't print "Invalid barcode data" if data field is empty.  Patch provided
by Darren Warner <warnerd@users.sourceforge.net>.  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

glabels2/AUTHORS
glabels2/ChangeLog
glabels2/src/bc-gnubarcode.c
glabels2/src/bc-postnet.c
glabels2/src/print.c
glabels2/src/view-barcode.c

index 21a47bb063cfc1ee78643517a0c24d1cf7c32a12..70e0c4da8b9d83bfdea7c05c8596dff6aa68d583 100644 (file)
@@ -47,6 +47,7 @@ Glabels includes contributions from:
        nestor di <nestordi@usuarios.retecal.es>  --  excellent splash screen
                                                       that first appeared in
                                                       0.4.3:
+       Darren Warner <warnerd@users.sourceforge.net>
        Javier Donaire Segarra <jyuyu@users.sourceforge.net>
        Alessandro Zummo <azummo@towertech.it>
        José Dapena Paz <jdapena@igalia.com>
index be4023919dddc50e4117c896b9cec8c528fc7f98..9344a8a119a93d38d88a630665607ca1c5a134bd 100644 (file)
@@ -1,3 +1,17 @@
+2006-05-22  Jim Evins  <evins@snaught.com>
+
+       * src/print.c: (draw_barcode_object):
+               Don't print "Invalid barcode data" if data field is empty.  Patch provided
+               by Darren Warner <warnerd@users.sourceforge.net>.  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  <evins@snaught.com>
 
        * src/print.c: (draw_text_object):
index 40a51fe96d97bc8a4e60e32c458fb855653681b7..c24b587a384c1a4a0490341dd870da1fdf8cbb82 100644 (file)
@@ -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;
        }
index 694069eb390f9c5ccdf448901d60c2ec16856cdf..9979cde86dec9ed5de513324411b41f75dca6ac5 100644 (file)
@@ -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;
index bdbe574be5b8bf3b94e344d4bbcebb7ae8a8f095..5856a025eacbb0c243febf0fcdf12e179c73fb6c 100644 (file)
@@ -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);
index 35185f5631335ba5e870754cfc33bcfe5f8f1a01..894f471f207b241d380f686b341a420757f696a3 100644 (file)
@@ -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);