]> git.sur5r.net Git - glabels/commitdiff
Encapsulate barcode style in single struct.
authorJim Evins <evins@snaught.com>
Wed, 1 Sep 2010 01:22:39 +0000 (21:22 -0400)
committerJim Evins <evins@snaught.com>
Wed, 1 Sep 2010 01:22:39 +0000 (21:22 -0400)
    Encapsulate barcode style into a single struct and related clean-up.

14 files changed:
src/label-barcode.c
src/label-barcode.h
src/merge-evolution.c
src/merge-text.c
src/merge-vcard.c
src/merge.c
src/merge.h
src/object-editor-bc-page.c
src/object-editor-private.h
src/object-editor.c
src/text-node.c
src/text-node.h
src/xml-label-04.c
src/xml-label.c

index c458552a7cdc9f2e2a65de5a012c7fcd0ee28173..8b1810d188f43b43c041330557c9cbbf25a8ebf7 100644 (file)
 /*========================================================*/
 
 struct _glLabelBarcodePrivate {
-        glTextNode     *text_node;
-        gchar          *backend_id;
-        gchar          *id;
-        glColorNode    *color_node;
-        gboolean        text_flag;
-        gboolean        checksum_flag;
-        guint           format_digits;
+
+        glTextNode          *text_node;
+        glLabelBarcodeStyle *style;
+        glColorNode         *color_node;
+
 };
 
 
@@ -129,7 +127,7 @@ gl_label_barcode_finalize (GObject *object)
         g_return_if_fail (object && GL_IS_LABEL_BARCODE (object));
 
         gl_text_node_free (&lbc->priv->text_node);
-        g_free (lbc->priv->id);
+        gl_label_barcode_style_free (lbc->priv->style);
         gl_color_node_free (&(lbc->priv->color_node));
         g_free (lbc->priv);
 
@@ -145,6 +143,7 @@ gl_label_barcode_new (glLabel *label,
                       gboolean checkpoint)
 {
         glLabelBarcode      *lbc;
+        glLabelBarcodeStyle *style;
         glColorNode         *line_color_node;
 
         lbc = g_object_new (gl_label_barcode_get_type(), NULL);
@@ -157,19 +156,16 @@ gl_label_barcode_new (glLabel *label,
                 }
 
                 /* Default barcode style and properties. */
-                lbc->priv->backend_id = g_strdup (gl_barcode_backends_backend_name_to_id (NULL));
-                lbc->priv->id         = g_strdup (gl_barcode_backends_style_name_to_id (lbc->priv->backend_id,
-                                                                                        NULL));
-                lbc->priv->text_flag     = gl_barcode_backends_style_can_text (lbc->priv->backend_id,
-                                                                               lbc->priv->id);
-                lbc->priv->checksum_flag = gl_barcode_backends_style_can_csum (lbc->priv->backend_id,
-                                                                               lbc->priv->id);
-                lbc->priv->format_digits = gl_barcode_backends_style_get_prefered_n (lbc->priv->backend_id,
-                                                                                     lbc->priv->id);
+                style = gl_label_barcode_style_new ();
+                gl_label_barcode_style_set_backend_id (style, gl_barcode_backends_backend_name_to_id (NULL));
+                gl_label_barcode_style_set_style_id (style, gl_barcode_backends_style_name_to_id (style->backend_id, NULL));
+                style->text_flag     = gl_barcode_backends_style_can_text (style->backend_id, style->id);
+                style->checksum_flag = gl_barcode_backends_style_can_csum (style->backend_id, style->id);
+                style->format_digits = gl_barcode_backends_style_get_prefered_n (style->backend_id, style->id);
+                lbc->priv->style = style;
 
                 line_color_node = gl_color_node_new_default ();
                 line_color_node->color = gl_label_get_default_line_color(label);
-
                 lbc->priv->color_node = line_color_node;
 
                 gl_label_add_object (label, GL_LABEL_OBJECT (lbc));
@@ -190,12 +186,8 @@ copy (glLabelObject *dst_object,
         glLabelBarcode      *lbc     = (glLabelBarcode *)src_object;
         glLabelBarcode      *new_lbc = (glLabelBarcode *)dst_object;
         glTextNode          *text_node;
-        gchar               *backend_id;
-        gchar               *id;
-        gboolean             text_flag;
-        gboolean             checksum_flag;
+        glLabelBarcodeStyle *style;
         glColorNode         *color_node;
-        guint                format_digits;
 
         gl_debug (DEBUG_LABEL, "START");
 
@@ -203,17 +195,15 @@ copy (glLabelObject *dst_object,
         g_return_if_fail (new_lbc && GL_IS_LABEL_BARCODE (new_lbc));
 
         text_node = gl_label_barcode_get_data (lbc);
-        gl_label_barcode_get_props (lbc, &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
+        style = gl_label_barcode_get_style (lbc);
         color_node = get_line_color (src_object);
 
         gl_label_barcode_set_data (new_lbc, text_node, FALSE);
-        gl_label_barcode_set_props (new_lbc, backend_id, id, text_flag, checksum_flag, format_digits, FALSE);
+        gl_label_barcode_set_style (new_lbc, style, FALSE);
         set_line_color (dst_object, color_node, FALSE);
 
         gl_color_node_free (&color_node);
         gl_text_node_free (&text_node);
-        g_free (backend_id);
-        g_free (id);
 
         gl_debug (DEBUG_LABEL, "END");
 }
@@ -223,9 +213,9 @@ copy (glLabelObject *dst_object,
 /* Set object params.                                                        */
 /*****************************************************************************/
 void
-gl_label_barcode_set_data (glLabelBarcode *lbc,
-                           glTextNode     *text_node,
-                           gboolean        checkpoint)
+gl_label_barcode_set_data (glLabelBarcode   *lbc,
+                           const glTextNode *text_node,
+                           gboolean          checkpoint)
 {
         glLabel *label;
 
@@ -252,13 +242,9 @@ gl_label_barcode_set_data (glLabelBarcode *lbc,
 
 
 void
-gl_label_barcode_set_props (glLabelBarcode *lbc,
-                            gchar          *backend_id,
-                            gchar          *id,
-                            gboolean        text_flag,
-                            gboolean        checksum_flag,
-                            guint           format_digits,
-                            gboolean        checkpoint)
+gl_label_barcode_set_style (glLabelBarcode            *lbc,
+                            const glLabelBarcodeStyle *style,
+                            gboolean                   checkpoint)
 {
         glLabel *label;
 
@@ -266,13 +252,7 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
 
         g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
-        if ( ((lbc->priv->backend_id == NULL) && (backend_id != NULL))
-             || ((lbc->priv->id == NULL) && (id != NULL))
-             || ((lbc->priv->backend_id != NULL) && (backend_id != NULL) && (g_ascii_strcasecmp (lbc->priv->backend_id, backend_id) != 0))
-             || ((lbc->priv->id != NULL) && (id != NULL) && (g_ascii_strcasecmp (lbc->priv->id, id) != 0))
-             || (lbc->priv->text_flag != text_flag)
-             || (lbc->priv->checksum_flag != checksum_flag)
-             || (lbc->priv->format_digits != format_digits))
+        if ( !gl_label_barcode_style_is_equal (style, lbc->priv->style) )
         {
                 if ( checkpoint )
                 {
@@ -280,11 +260,8 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
                         gl_label_checkpoint (label, _("Barcode property"));
                 }
 
-                lbc->priv->backend_id       = g_strdup (backend_id);
-                lbc->priv->id               = g_strdup (id);
-                lbc->priv->text_flag        = text_flag;
-                lbc->priv->checksum_flag    = checksum_flag;
-                lbc->priv->format_digits    = format_digits;
+                gl_label_barcode_style_free (lbc->priv->style);
+                lbc->priv->style = gl_label_barcode_style_dup (style);
 
                 gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc));
         }
@@ -305,21 +282,12 @@ gl_label_barcode_get_data (glLabelBarcode *lbc)
 }
 
 
-void
-gl_label_barcode_get_props (glLabelBarcode *lbc,
-                            gchar          **backend_id,
-                            gchar          **id,
-                            gboolean       *text_flag,
-                            gboolean       *checksum_flag,
-                            guint          *format_digits)
+glLabelBarcodeStyle *
+gl_label_barcode_get_style (glLabelBarcode *lbc)
 {
-        g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
+        g_return_val_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc), NULL);
 
-        *backend_id       = g_strdup (lbc->priv->backend_id);
-        *id               = g_strdup (lbc->priv->id);
-        *text_flag        = lbc->priv->text_flag;
-        *checksum_flag    = lbc->priv->checksum_flag;
-        *format_digits    = lbc->priv->format_digits;
+        return gl_label_barcode_style_dup (lbc->priv->style);
 }
 
 
@@ -343,17 +311,17 @@ get_size (glLabelObject *object,
         gl_label_object_get_raw_size (object, &w_parent, &h_parent);
 
         if (lbc->priv->text_node->field_flag) {
-                data = gl_barcode_backends_style_default_digits (lbc->priv->backend_id,
-                                                                 lbc->priv->id,
-                                                                 lbc->priv->format_digits);
+                data = gl_barcode_backends_style_default_digits (lbc->priv->style->backend_id,
+                                                                 lbc->priv->style->id,
+                                                                 lbc->priv->style->format_digits);
         } else {
                 data = gl_text_node_expand (lbc->priv->text_node, NULL);
         }
 
-        gbc = gl_barcode_backends_new_barcode (lbc->priv->backend_id,
-                                               lbc->priv->id,
-                                               lbc->priv->text_flag,
-                                               lbc->priv->checksum_flag,
+        gbc = gl_barcode_backends_new_barcode (lbc->priv->style->backend_id,
+                                               lbc->priv->style->id,
+                                               lbc->priv->style->text_flag,
+                                               lbc->priv->style->checksum_flag,
                                                w_parent,
                                                h_parent,
                                                data);
@@ -361,13 +329,13 @@ get_size (glLabelObject *object,
 
         if ( gbc == NULL ) {
                 /* Try again with default digits. */
-                data = gl_barcode_backends_style_default_digits (lbc->priv->backend_id,
-                                                                 lbc->priv->id,
-                                                                 lbc->priv->format_digits);
-                gbc = gl_barcode_backends_new_barcode (lbc->priv->backend_id,
-                                                       lbc->priv->id,
-                                                       lbc->priv->text_flag,
-                                                       lbc->priv->checksum_flag,
+                data = gl_barcode_backends_style_default_digits (lbc->priv->style->backend_id,
+                                                                 lbc->priv->style->id,
+                                                                 lbc->priv->style->format_digits);
+                gbc = gl_barcode_backends_new_barcode (lbc->priv->style->backend_id,
+                                                       lbc->priv->style->id,
+                                                       lbc->priv->style->text_flag,
+                                                       lbc->priv->style->checksum_flag,
                                                        w_parent,
                                                        h_parent,
                                                        data);
@@ -459,13 +427,9 @@ draw_object (glLabelObject *object,
         PangoFontDescription *desc;
         gchar                *text, *cstring;
         glTextNode           *text_node;
-        gchar                *backend_id;
-        gchar                *id;
-        gboolean              text_flag;
-        gboolean              checksum_flag;
+        glLabelBarcodeStyle  *style;
         guint                 color;
         glColorNode          *color_node;
-        guint                 format_digits;
         gdouble               w, h;
         gint                  iw, ih;
         gdouble               layout_width;
@@ -476,8 +440,7 @@ draw_object (glLabelObject *object,
         gl_label_object_get_matrix (object, &matrix);
 
         text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE (object));
-        gl_label_barcode_get_props (GL_LABEL_BARCODE (object),
-                                    &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
+        style = gl_label_barcode_get_style (GL_LABEL_BARCODE (object));
 
         color_node = gl_label_object_get_line_color (object);
         color = gl_color_node_expand (color_node, record);
@@ -485,17 +448,16 @@ draw_object (glLabelObject *object,
         {
                 color = GL_COLOR_MERGE_DEFAULT;
         }
-        gl_color_node_free (&color_node);
 
         gl_label_object_get_size (object, &w, &h);
 
         text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
         text = gl_text_node_expand (text_node, record);
         if (text_node->field_flag && screen_flag) {
-                text = gl_barcode_backends_style_default_digits (backend_id, id, format_digits);
+                text = gl_barcode_backends_style_default_digits (style->backend_id, style->id, style->format_digits);
         }
 
-        gbc = gl_barcode_backends_new_barcode (backend_id, id, text_flag, checksum_flag, w, h, text);
+        gbc = gl_barcode_backends_new_barcode (style->backend_id, style->id, style->text_flag, style->checksum_flag, w, h, text);
 
         cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (color));
 
@@ -635,8 +597,8 @@ draw_object (glLabelObject *object,
 
         g_free (text);
         gl_text_node_free (&text_node);
-        g_free (backend_id);
-        g_free (id);
+        gl_label_barcode_style_free (style);
+        gl_color_node_free (&color_node);
 
         gl_debug (DEBUG_LABEL, "END");
 }
@@ -667,6 +629,129 @@ object_at (glLabelObject *object,
 }
 
 
+/*****************************************************************************/
+/* Barcode style utilities.                                                  */
+/*****************************************************************************/
+glLabelBarcodeStyle *
+gl_label_barcode_style_new (void)
+{
+        return g_new0 (glLabelBarcodeStyle, 1);
+}
+
+
+glLabelBarcodeStyle *
+gl_label_barcode_style_dup (const glLabelBarcodeStyle *style)
+{
+        glLabelBarcodeStyle *style2;
+
+        style2 = gl_label_barcode_style_new ();
+
+        /* Shallow copy first. */
+        *style2 = *style;
+
+        /* Now go deep. */
+        style2->backend_id = g_strdup (style->backend_id);
+        style2->id         = g_strdup (style->id);
+
+        return style2;
+}
+
+
+void
+gl_label_barcode_style_free (glLabelBarcodeStyle *style)
+{
+        if ( style )
+        {
+                g_free (style->backend_id);
+                g_free (style->id);
+
+                g_free (style);
+        }
+}
+
+
+gboolean
+gl_label_barcode_style_is_equal (const glLabelBarcodeStyle *style1,
+                                 const glLabelBarcodeStyle *style2)
+{
+
+        /* First take care of the case of either or both being NULL. */
+        if ( style1 == NULL )
+        {
+                return ( style2 == NULL );
+        }
+        else
+        {
+                if ( style2 == NULL )
+                {
+                        return FALSE;
+                }
+        }
+
+        /* Compare field by field, bail on first difference. */
+        if ( style1->text_flag != style2->text_flag )
+        {
+                return FALSE;
+        }
+        if ( style1->checksum_flag != style2->checksum_flag )
+        {
+                return FALSE;
+        }
+        if ( style1->format_digits != style2->format_digits )
+        {
+                return FALSE;
+        }
+        if ( style1->backend_id && style2->backend_id )
+        {
+                if ( strcmp (style1->backend_id, style2->backend_id) != 0 )
+                {
+                        return FALSE;
+                }
+        }
+        else
+        {
+                if ( style1->backend_id != style2->backend_id )
+                {
+                        return FALSE;
+                }
+        }
+        if ( style1->id && style2->id )
+        {
+                if ( strcmp (style1->id, style2->id) != 0 )
+                {
+                        return FALSE;
+                }
+        }
+        else
+        {
+                if ( style1->id != style2->id )
+                {
+                        return FALSE;
+                }
+        }
+
+        /* Passed all tests. */
+        return TRUE;
+}
+
+
+void
+gl_label_barcode_style_set_backend_id (glLabelBarcodeStyle *style,
+                                       const gchar         *backend_id)
+{
+        style->backend_id = g_strdup (backend_id);
+}
+
+
+void
+gl_label_barcode_style_set_style_id (glLabelBarcodeStyle *style,
+                                     const gchar         *id)
+{
+        style->id = g_strdup (id);
+}
+
+
+
 
 
 /*
index bba52f9cc89a8a244ac6392283720010f118f27a..ce90b9d76a3f0ce2ff5f3d97e594ff85de60a1e1 100644 (file)
@@ -49,31 +49,50 @@ struct _glLabelBarcodeClass {
 };
 
 
-GType           gl_label_barcode_get_type  (void) G_GNUC_CONST;
-
-GObject        *gl_label_barcode_new       (glLabel        *label,
-                                            gboolean        checkpoint);
-
-void            gl_label_barcode_set_data  (glLabelBarcode *lbc,
-                                           glTextNode     *text_node,
-                                            gboolean        checkpoint);
-
-void            gl_label_barcode_set_props (glLabelBarcode *lbc,
-                                            gchar          *backend_id,
-                                           gchar          *id,
-                                           gboolean        text_flag,
-                                           gboolean        checksum_flag,
-                                           guint           format_digits,
-                                            gboolean        checkpoint);
-
-glTextNode     *gl_label_barcode_get_data  (glLabelBarcode *lbc);
-
-void            gl_label_barcode_get_props (glLabelBarcode *lbc,
-                                           gchar         **backend_id,
-                                           gchar         **id,
-                                           gboolean       *text_flag,
-                                           gboolean       *checksum_flag,
-                                           guint          *format_digits);
+
+typedef struct _glLabelBarcodeStyle     glLabelBarcodeStyle;
+
+struct _glLabelBarcodeStyle {
+        gchar          *backend_id;
+        gchar          *id;
+        gboolean        text_flag;
+        gboolean        checksum_flag;
+        guint           format_digits;
+};
+
+
+
+GType                 gl_label_barcode_get_type             (void) G_GNUC_CONST;
+
+GObject              *gl_label_barcode_new                  (glLabel                   *label,
+                                                             gboolean                   checkpoint);
+
+void                  gl_label_barcode_set_data             (glLabelBarcode            *lbc,
+                                                             const glTextNode          *text_node,
+                                                             gboolean                   checkpoint);
+
+void                  gl_label_barcode_set_style            (glLabelBarcode            *lbc,
+                                                             const glLabelBarcodeStyle *style,
+                                                             gboolean                   checkpoint);
+
+glTextNode           *gl_label_barcode_get_data             (glLabelBarcode            *lbc);
+
+glLabelBarcodeStyle  *gl_label_barcode_get_style            (glLabelBarcode            *lbc);
+
+
+glLabelBarcodeStyle  *gl_label_barcode_style_new            (void);
+glLabelBarcodeStyle  *gl_label_barcode_style_dup            (const glLabelBarcodeStyle *style);
+void                  gl_label_barcode_style_free           (glLabelBarcodeStyle       *style);
+
+gboolean              gl_label_barcode_style_is_equal       (const glLabelBarcodeStyle *style1,
+                                                             const glLabelBarcodeStyle *style2);
+
+void                  gl_label_barcode_style_set_backend_id (glLabelBarcodeStyle       *style,
+                                                             const gchar               *backend_id);
+
+void                  gl_label_barcode_style_set_style_id   (glLabelBarcodeStyle       *style,
+                                                             const gchar               *id);
+
 
 G_END_DECLS
 
index a5ecd47d42fcf076c8ee26526027d0c033dc9368..3542261d8a921949a88d5eb9b218b48767cac3f5 100644 (file)
@@ -82,13 +82,13 @@ static void           gl_merge_evolution_get_property    (GObject          *obje
                                                           GValue           *value,
                                                           GParamSpec       *pspec);
 
-static GList         *gl_merge_evolution_get_key_list    (glMerge          *merge);
-static gchar         *gl_merge_evolution_get_primary_key (glMerge          *merge);
+static GList         *gl_merge_evolution_get_key_list    (const glMerge    *merge);
+static gchar         *gl_merge_evolution_get_primary_key (const glMerge    *merge);
 static void           gl_merge_evolution_open            (glMerge          *merge);
 static void           gl_merge_evolution_close           (glMerge          *merge);
 static glMergeRecord *gl_merge_evolution_get_record      (glMerge          *merge);
 static void           gl_merge_evolution_copy            (glMerge          *dst_merge,
-                                                          glMerge          *src_merge);
+                                                          const glMerge    *src_merge);
 
 /* utility function prototypes go here */
 static void           free_field_list                    (GList *fields);
@@ -227,7 +227,7 @@ gl_merge_evolution_get_property (GObject     *object,
 /* Get key list.                                                            */
 /*--------------------------------------------------------------------------*/
 static GList *
-gl_merge_evolution_get_key_list (glMerge *merge)
+gl_merge_evolution_get_key_list (const glMerge *merge)
 {
         glMergeEvolution   *merge_evolution;
         GList              *key_list = NULL;
@@ -259,7 +259,7 @@ gl_merge_evolution_get_key_list (glMerge *merge)
 /* Get "primary" key.                                                       */
 /*--------------------------------------------------------------------------*/
 static gchar *
-gl_merge_evolution_get_primary_key (glMerge *merge)
+gl_merge_evolution_get_primary_key (const glMerge *merge)
 {
         return g_strdup (e_contact_pretty_name(E_CONTACT_FILE_AS));
 }
@@ -500,8 +500,8 @@ gl_merge_evolution_get_record (glMerge *merge)
 /* Copy merge_evolution specific fields.                                     */
 /*---------------------------------------------------------------------------*/
 static void
-gl_merge_evolution_copy (glMerge *dst_merge,
-                    glMerge *src_merge)
+gl_merge_evolution_copy (glMerge       *dst_merge,
+                         const glMerge *src_merge)
 {
         GList *src_iter, *dst_iter;
 
index c42cd3f72023f655ddd7910ee0eedd5c7effeaae..c4c0a6c67b96ee83f5462a764d39b644e639d1bb 100644 (file)
@@ -80,13 +80,13 @@ static gchar         *key_from_index                (glMergeText      *merge_tex
                                                      gint              i_field);
 static void           clear_keys                    (glMergeText      *merge_text);
 
-static GList         *gl_merge_text_get_key_list    (glMerge          *merge);
-static gchar         *gl_merge_text_get_primary_key (glMerge          *merge);
+static GList         *gl_merge_text_get_key_list    (const glMerge    *merge);
+static gchar         *gl_merge_text_get_primary_key (const glMerge    *merge);
 static void           gl_merge_text_open            (glMerge          *merge);
 static void           gl_merge_text_close           (glMerge          *merge);
 static glMergeRecord *gl_merge_text_get_record      (glMerge          *merge);
 static void           gl_merge_text_copy            (glMerge          *dst_merge,
-                                                    glMerge          *src_merge);
+                                                    const glMerge    *src_merge);
 
 static GList         *parse_line                    (FILE             *fp,
                                                     gchar             delim);
@@ -280,7 +280,7 @@ clear_keys (glMergeText      *merge_text)
 /* Get key list.                                                            */
 /*--------------------------------------------------------------------------*/
 static GList *
-gl_merge_text_get_key_list (glMerge *merge)
+gl_merge_text_get_key_list (const glMerge *merge)
 {
        glMergeText   *merge_text;
        gint           i_field, n_fields;
@@ -315,7 +315,7 @@ gl_merge_text_get_key_list (glMerge *merge)
 /* Get "primary" key.                                                       */
 /*--------------------------------------------------------------------------*/
 static gchar *
-gl_merge_text_get_primary_key (glMerge *merge)
+gl_merge_text_get_primary_key (const glMerge *merge)
 {
        /* For now, let's always assume the first column is the primary key. */
         return key_from_index (GL_MERGE_TEXT (merge), 0);
@@ -442,8 +442,8 @@ gl_merge_text_get_record (glMerge *merge)
 /* Copy merge_text specific fields.                                          */
 /*---------------------------------------------------------------------------*/
 static void
-gl_merge_text_copy (glMerge *dst_merge,
-                   glMerge *src_merge)
+gl_merge_text_copy (glMerge       *dst_merge,
+                   const glMerge *src_merge)
 {
        glMergeText *dst_merge_text;
        glMergeText *src_merge_text;
index 27ee9b042c28732428e406e4d0dd2f0e0ee4e6af..253bb89711c2645249d8edab6afd54ae692d1922 100644 (file)
@@ -73,13 +73,13 @@ static void           gl_merge_vcard_get_property    (GObject          *object,
                                                       GValue           *value,
                                                       GParamSpec       *pspec);
 
-static GList         *gl_merge_vcard_get_key_list    (glMerge          *merge);
-static gchar         *gl_merge_vcard_get_primary_key (glMerge          *merge);
+static GList         *gl_merge_vcard_get_key_list    (const glMerge    *merge);
+static gchar         *gl_merge_vcard_get_primary_key (const glMerge    *merge);
 static void           gl_merge_vcard_open            (glMerge          *merge);
 static void           gl_merge_vcard_close           (glMerge          *merge);
 static glMergeRecord *gl_merge_vcard_get_record      (glMerge          *merge);
 static void           gl_merge_vcard_copy            (glMerge          *dst_merge,
-                                                      glMerge          *src_merge);
+                                                      const glMerge    *src_merge);
 static char *         parse_next_vcard               (FILE             *fp);
 
 
@@ -190,7 +190,7 @@ gl_merge_vcard_get_property (GObject     *object,
 /* Get key list.                                                            */
 /*--------------------------------------------------------------------------*/
 static GList *
-gl_merge_vcard_get_key_list (glMerge *merge)
+gl_merge_vcard_get_key_list (const glMerge *merge)
 {
         glMergeVCard   *merge_vcard;
         GList          *key_list = NULL;
@@ -215,7 +215,7 @@ gl_merge_vcard_get_key_list (glMerge *merge)
 /* Get "primary" key.                                                       */
 /*--------------------------------------------------------------------------*/
 static gchar *
-gl_merge_vcard_get_primary_key (glMerge *merge)
+gl_merge_vcard_get_primary_key (const glMerge *merge)
 {
         return g_strdup (e_contact_pretty_name(E_CONTACT_FILE_AS));
 }
@@ -321,8 +321,8 @@ gl_merge_vcard_get_record (glMerge *merge)
 /* Copy merge_vcard specific fields.                                         */
 /*---------------------------------------------------------------------------*/
 static void
-gl_merge_vcard_copy (glMerge *dst_merge,
-                     glMerge *src_merge)
+gl_merge_vcard_copy (glMerge       *dst_merge,
+                     const glMerge *src_merge)
 {
         glMergeVCard *dst_merge_vcard;
         glMergeVCard *src_merge_vcard;
index 210aac93b4c1220930a8d320abbf274ba594467a..18379a05167c3f629e6d2de9d2aa16b232fbe007 100644 (file)
@@ -69,21 +69,21 @@ static GList *backends = NULL;
 /* Private function prototypes.                           */
 /*========================================================*/
 
-static void           gl_merge_finalize      (GObject        *object);
+static void           gl_merge_finalize      (GObject              *object);
 
-static void           merge_open             (glMerge        *merge);
+static void           merge_open             (glMerge              *merge);
 
-static void           merge_close            (glMerge        *merge);
+static void           merge_close            (glMerge              *merge);
 
-static glMergeRecord *merge_get_record       (glMerge        *merge);
+static glMergeRecord *merge_get_record       (glMerge              *merge);
 
-static void           merge_free_record      (glMergeRecord **record);
+static void           merge_free_record      (glMergeRecord       **record);
 
-static glMergeRecord *merge_dup_record       (glMergeRecord  *record);
+static glMergeRecord *merge_dup_record       (const glMergeRecord  *record);
 
-static void           merge_free_record_list (GList         **record_list);
+static void           merge_free_record_list (GList               **record_list);
 
-static GList         *merge_dup_record_list  (GList          *record_list);
+static GList         *merge_dup_record_list  (GList                *record_list);
 
 
 
@@ -276,7 +276,7 @@ gl_merge_finalize (GObject *object)
 /* New merge object.                                                         */
 /*****************************************************************************/
 glMerge *
-gl_merge_new (gchar *name)
+gl_merge_new (const gchar *name)
 {
        glMerge *merge = NULL;
        GList   *p;
@@ -314,7 +314,7 @@ gl_merge_new (gchar *name)
 /* Duplicate merge.                                                         */
 /*****************************************************************************/
 glMerge *
-gl_merge_dup (glMerge *src_merge)
+gl_merge_dup (const glMerge *src_merge)
 {
        glMerge    *dst_merge;
 
@@ -351,7 +351,7 @@ gl_merge_dup (glMerge *src_merge)
 /* Get name of merge.                                                        */
 /*****************************************************************************/
 gchar *
-gl_merge_get_name (glMerge *merge)
+gl_merge_get_name (const glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "");
 
@@ -368,7 +368,7 @@ gl_merge_get_name (glMerge *merge)
 /* Get description of merge.                                                 */
 /*****************************************************************************/
 gchar *
-gl_merge_get_description (glMerge *merge)
+gl_merge_get_description (const glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "");
 
@@ -385,7 +385,7 @@ gl_merge_get_description (glMerge *merge)
 /* Get source type of merge.                                                 */
 /*****************************************************************************/
 glMergeSrcType
-gl_merge_get_src_type (glMerge *merge)
+gl_merge_get_src_type (const glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "");
 
@@ -402,8 +402,8 @@ gl_merge_get_src_type (glMerge *merge)
 /* Set src of merge.                                                         */
 /*****************************************************************************/
 void
-gl_merge_set_src (glMerge *merge,
-                 gchar   *src)
+gl_merge_set_src (glMerge       *merge,
+                 const gchar   *src)
 {
        GList         *record_list = NULL;
        glMergeRecord *record;
@@ -458,7 +458,7 @@ gl_merge_set_src (glMerge *merge,
 /* Get src of merge.                                                         */
 /*****************************************************************************/
 gchar *
-gl_merge_get_src (glMerge *merge)
+gl_merge_get_src (const glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "");
 
@@ -475,7 +475,7 @@ gl_merge_get_src (glMerge *merge)
 /* Get Key List.                                                             */
 /*****************************************************************************/
 GList *
-gl_merge_get_key_list (glMerge *merge)
+gl_merge_get_key_list (const glMerge *merge)
 {
        GList *key_list = NULL;
 
@@ -523,7 +523,7 @@ gl_merge_free_key_list (GList **key_list)
 /* Get Key List.                                                             */
 /*****************************************************************************/
 gchar *
-gl_merge_get_primary_key (glMerge *merge)
+gl_merge_get_primary_key (const glMerge *merge)
 {
        gchar *key = NULL;
 
@@ -643,7 +643,7 @@ merge_free_record (glMergeRecord **record)
 /* Duplicate a merge record (list of fields)                                 */
 /*---------------------------------------------------------------------------*/
 static glMergeRecord *
-merge_dup_record (glMergeRecord *record)
+merge_dup_record (const glMergeRecord *record)
 {
        glMergeRecord *dest_record;
        GList         *p;
@@ -676,8 +676,8 @@ merge_dup_record (glMergeRecord *record)
 /* Find key in given record and evaluate.                                    */
 /*****************************************************************************/
 gchar *
-gl_merge_eval_key (glMergeRecord *record,
-                  gchar         *key)
+gl_merge_eval_key (const glMergeRecord *record,
+                  const gchar         *key)
                   
 {
        GList        *p;
@@ -706,7 +706,7 @@ gl_merge_eval_key (glMergeRecord *record,
 /* Read all records from merge source.                                       */
 /*****************************************************************************/
 const GList *
-gl_merge_get_record_list (glMerge *merge)
+gl_merge_get_record_list (const glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "");
              
@@ -769,7 +769,7 @@ merge_dup_record_list (GList *record_list)
 /* Count selected records.                                                   */
 /*****************************************************************************/
 gint
-gl_merge_get_record_count (glMerge *merge)
+gl_merge_get_record_count (const glMerge *merge)
 {
        GList *p;
        glMergeRecord *record;
index 9456ca923b01ca4f453ce4bd158b2a2417744bf4..23233ee7a782d8892ed7448ccb46ec690239739a 100644 (file)
@@ -64,18 +64,18 @@ struct _glMerge {
 struct _glMergeClass {
        GObjectClass     parent_class;
 
-        GList         *(*get_key_list)    (glMerge *merge);
+        GList         *(*get_key_list)    (const glMerge *merge);
 
-        gchar         *(*get_primary_key) (glMerge *merge);
+        gchar         *(*get_primary_key) (const glMerge *merge);
 
-       void           (*open)            (glMerge *merge);
+       void           (*open)            (glMerge       *merge);
 
-       void           (*close)           (glMerge *merge);
+       void           (*close)           (glMerge       *merge);
 
-       glMergeRecord *(*get_record)      (glMerge *merge);
+       glMergeRecord *(*get_record)      (glMerge       *merge);
 
-       void           (*copy)            (glMerge *dst_merge,
-                                          glMerge *src_merge);
+       void           (*copy)            (glMerge       *dst_merge,
+                                          const glMerge *src_merge);
 };
 
 
@@ -94,33 +94,33 @@ gchar            *gl_merge_description_to_name (gchar *description);
 
 GType             gl_merge_get_type            (void) G_GNUC_CONST;
 
-glMerge          *gl_merge_new                 (gchar             *name);
+glMerge          *gl_merge_new                 (const gchar         *name);
 
-glMerge          *gl_merge_dup                 (glMerge           *orig);
+glMerge          *gl_merge_dup                 (const glMerge       *orig);
 
-gchar            *gl_merge_get_name            (glMerge           *merge);
+gchar            *gl_merge_get_name            (const glMerge       *merge);
 
-gchar            *gl_merge_get_description     (glMerge           *merge);
+gchar            *gl_merge_get_description     (const glMerge       *merge);
 
-glMergeSrcType    gl_merge_get_src_type        (glMerge           *merge);
+glMergeSrcType    gl_merge_get_src_type        (const glMerge       *merge);
 
-void              gl_merge_set_src             (glMerge           *merge,
-                                               gchar             *src);
+void              gl_merge_set_src             (glMerge             *merge,
+                                               const gchar         *src);
 
-gchar            *gl_merge_get_src             (glMerge           *merge);
+gchar            *gl_merge_get_src             (const glMerge       *merge);
 
-GList            *gl_merge_get_key_list        (glMerge           *merge);
+GList            *gl_merge_get_key_list        (const glMerge       *merge);
 
-void              gl_merge_free_key_list       (GList            **keys);
+void              gl_merge_free_key_list       (GList              **keys);
 
-gchar            *gl_merge_get_primary_key     (glMerge           *merge);
+gchar            *gl_merge_get_primary_key     (const glMerge       *merge);
 
-gchar            *gl_merge_eval_key            (glMergeRecord     *record,
-                                               gchar             *key);
+gchar            *gl_merge_eval_key            (const glMergeRecord *record,
+                                                const gchar         *key);
 
-const GList      *gl_merge_get_record_list     (glMerge           *merge);
+const GList      *gl_merge_get_record_list     (const glMerge       *merge);
 
-gint              gl_merge_get_record_count    (glMerge           *merge);
+gint              gl_merge_get_record_count    (const glMerge       *merge);
 
 G_END_DECLS
 
index 0d9d5fb10700cd5c5ddf561124ff4b1c485ec97e..bce9a2a8830eadd47163e9ca2fb22025226048fd 100644 (file)
@@ -264,7 +264,6 @@ void
 gl_object_editor_load_bc_styles (glObjectEditor      *editor,
                                  const gchar         *backend_id)
 {
-       const gchar *backend_name;
         GList       *styles;
  
        gl_debug (DEBUG_EDITOR, "START");
@@ -286,23 +285,20 @@ gl_object_editor_load_bc_styles (glObjectEditor      *editor,
 /* Set barcode style.                                                        */
 /*****************************************************************************/
 void
-gl_object_editor_set_bc_style (glObjectEditor      *editor,
-                              const gchar         *backend_id,
-                              const gchar         *id,
-                              gboolean             text_flag,
-                              gboolean             checksum_flag,
-                              guint                format_digits)
+gl_object_editor_set_bc_style (glObjectEditor            *editor,
+                              const glLabelBarcodeStyle *bc_style)
 {
        const gchar *backend_name;
        const gchar *style_name;
        gchar       *ex_string;
+        gint         format_digits;
  
        gl_debug (DEBUG_EDITOR, "START");
 
         editor->priv->stop_signals = TRUE;
 
-        backend_name = gl_barcode_backends_backend_id_to_name (backend_id);
-        style_name   = gl_barcode_backends_style_id_to_name (backend_id, id);
+        backend_name = gl_barcode_backends_backend_id_to_name (bc_style->backend_id);
+        style_name   = gl_barcode_backends_style_id_to_name (bc_style->backend_id, bc_style->id);
 
        gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo),
                                        backend_name);
@@ -310,28 +306,28 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
                                        style_name);
  
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check),
-                                      text_flag);
+                                      bc_style->text_flag);
  
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check),
-                                      checksum_flag);
+                                      bc_style->checksum_flag);
 
        gtk_widget_set_sensitive (editor->priv->bc_text_check,
-                                 gl_barcode_backends_style_text_optional (backend_id, id));
+                                 gl_barcode_backends_style_text_optional (bc_style->backend_id, bc_style->id));
        gtk_widget_set_sensitive (editor->priv->bc_cs_check,
-                                 gl_barcode_backends_style_csum_optional (backend_id, id));
+                                 gl_barcode_backends_style_csum_optional (bc_style->backend_id, bc_style->id));
 
-       editor->priv->data_format_fixed_flag = !gl_barcode_backends_style_can_freeform (backend_id, id);
+       editor->priv->data_format_fixed_flag = !gl_barcode_backends_style_can_freeform (bc_style->backend_id, bc_style->id);
 
+        format_digits = bc_style->format_digits;
        if (editor->priv->data_format_fixed_flag) {
-               format_digits = gl_barcode_backends_style_get_prefered_n (backend_id, id);
+               format_digits = gl_barcode_backends_style_get_prefered_n (bc_style->backend_id, bc_style->id);
        }
 
-       ex_string = gl_barcode_backends_style_default_digits (backend_id, id, format_digits);
+       ex_string = gl_barcode_backends_style_default_digits (bc_style->backend_id, bc_style->id, format_digits);
        gtk_label_set_text (GTK_LABEL(editor->priv->data_ex_label), ex_string);
        g_free (ex_string);
 
-        gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin), 
-                                   format_digits);
+        gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin), format_digits);
 
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) {
                gtk_widget_set_sensitive (editor->priv->data_format_label, FALSE);
@@ -356,41 +352,39 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
 /*****************************************************************************/
 /* Query barcode style.                                                      */
 /*****************************************************************************/
-void
-gl_object_editor_get_bc_style (glObjectEditor      *editor,
-                               gchar              **backend_id,
-                              gchar              **id,
-                              gboolean            *text_flag,
-                              gboolean            *checksum_flag,
-                              guint               *format_digits)
+glLabelBarcodeStyle *
+gl_object_editor_get_bc_style (glObjectEditor      *editor)
 {
-        gchar *backend_name;
-        gchar *style_name;
+        gchar       *backend_name;
+        const gchar *backend_id;
+        gchar       *style_name;
+        const gchar *id;
+
+        glLabelBarcodeStyle *bc_style;
 
        gl_debug (DEBUG_EDITOR, "START");
                                                                                 
-        backend_name =
-               gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
-        *backend_id = g_strdup (gl_barcode_backends_backend_name_to_id (backend_name));
+        backend_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
+        backend_id = gl_barcode_backends_backend_name_to_id (backend_name);
 
-        style_name =
-               gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
-        *id = g_strdup (gl_barcode_backends_style_name_to_id (*backend_id, style_name));
-                                                                                
-        *text_flag =
-            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check));
-                                                                                
-        *checksum_flag =
-            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check));
-                                                                                
+        style_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
+        id = gl_barcode_backends_style_name_to_id (backend_id, style_name);
 
-       *format_digits =
-               gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->data_digits_spin));
+        bc_style = gl_label_barcode_style_new ();
+
+        gl_label_barcode_style_set_backend_id (bc_style, backend_id);
+        gl_label_barcode_style_set_style_id (bc_style, id);
+
+        bc_style->text_flag     = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check));
+        bc_style->checksum_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check));
+       bc_style->format_digits = gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->data_digits_spin));
 
         g_free (backend_name);
         g_free (style_name);
 
        gl_debug (DEBUG_EDITOR, "END");
+
+        return bc_style;
 }
 
 
index f60d15425ce72dded6ec56737d0eb5dde9528847..957251af5ea584eb748e6a23f73e4bb5d5ad5dee 100644 (file)
@@ -22,6 +22,7 @@
 #define __OBJECT_EDITOR_PRIVATE_H__
 
 #include <gtk/gtk.h>
+#include "label-barcode.h"
 
 G_BEGIN_DECLS
 
@@ -350,28 +351,19 @@ void        gl_object_editor_set_text_buffer      (glObjectEditor      *editor,
 /*
  * Barcode Page
  */
-void        gl_object_editor_load_bc_styles       (glObjectEditor      *editor,
-                                                   const gchar         *backend_id);
-
-void        gl_object_editor_set_bc_style         (glObjectEditor      *editor,
-                                                   const gchar         *backend_id,
-                                                  const gchar         *id,
-                                                  gboolean             text_flag,
-                                                  gboolean             checksum_flag,
-                                                  guint                format_digits);
-
-void        gl_object_editor_get_bc_style         (glObjectEditor      *editor,
-                                                   gchar              **backend_id,
-                                                  gchar              **id,
-                                                  gboolean            *text_flag,
-                                                  gboolean            *checksum_flag,
-                                                  guint               *format_digits);
-
-void        gl_object_editor_set_bc_color         (glObjectEditor      *editor,
-                                                  gboolean             merge_flag,
-                                                  glColorNode         *color_node);
+void        gl_object_editor_load_bc_styles        (glObjectEditor            *editor,
+                                                    const gchar               *backend_id);
+
+void        gl_object_editor_set_bc_style          (glObjectEditor            *editor,
+                                                    const glLabelBarcodeStyle *bc_style);
+
+glLabelBarcodeStyle *gl_object_editor_get_bc_style (glObjectEditor            *editor);
+
+void        gl_object_editor_set_bc_color          (glObjectEditor            *editor,
+                                                    gboolean                   merge_flag,
+                                                    glColorNode               *color_node);
 
-glColorNode* gl_object_editor_get_bc_color        (glObjectEditor      *editor);
+glColorNode* gl_object_editor_get_bc_color         (glObjectEditor            *editor);
 
 
 /*
index ea5bd83d2797001c1189ed925e22d7e2bc2f22da..6c60b10767b36df686c9e7d5b7db67802619a82d 100644 (file)
@@ -280,15 +280,12 @@ static void
 set_object (glObjectEditor  *editor,
             glLabelObject   *object)
 {
-        gchar         *image;
-        gchar         *title;
-        gchar         *s;
-        GtkTextBuffer *buffer;
-        gint           old_page, new_page;
-        gchar         *backend_id;
-        gchar         *id;
-        gboolean       text_flag, cs_flag;
-        guint          format_digits;
+        gchar               *image;
+        gchar               *title;
+        gchar               *s;
+        GtkTextBuffer       *buffer;
+        gint                 old_page, new_page;
+        glLabelBarcodeStyle *bc_style;
 
        gl_debug (DEBUG_EDITOR, "START");
 
@@ -418,12 +415,9 @@ set_object (glObjectEditor  *editor,
 
                         gtk_widget_hide     (editor->priv->size_reset_image_button);
 
-                        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                                    &backend_id, &id, &text_flag, &cs_flag, &format_digits);
-                        gl_object_editor_load_bc_styles (editor, backend_id);
-                        g_free (backend_id);
-                        g_free (id);
-
+                        bc_style = gl_label_barcode_get_style (GL_LABEL_BARCODE(object));
+                        gl_object_editor_load_bc_styles (editor, bc_style->backend_id);
+                        gl_label_barcode_style_free (bc_style);
                 }
 
                 gtk_image_set_from_stock (GTK_IMAGE(editor->priv->title_image),
@@ -740,32 +734,29 @@ static void
 object_changed_cb (glLabelObject  *object,
                    glObjectEditor *editor)
 {
-        gdouble          x, y;
-        gdouble          w, h;
-        glColorNode     *line_color_node;
-        gdouble          line_width;
-        glColorNode     *fill_color_node;
-        gchar           *font_family;
-        gdouble          font_size;
-        PangoWeight      font_weight;
-        gboolean         font_italic_flag;
-        glColorNode     *text_color_node;
-        PangoAlignment   align;
-        gdouble          text_line_spacing;
-        gboolean         auto_shrink;
-        gdouble          image_w, image_h;
-        glTextNode      *filename;
-        glTextNode      *bc_data;
-        gchar           *backend_id;
-        gchar           *id;
-        gboolean         text_flag, cs_flag;
-        guint            format_digits;
-        gboolean         shadow_state;
-        gdouble          shadow_x, shadow_y;
-        glColorNode     *shadow_color_node;
-        gdouble          shadow_opacity;
-        glLabel         *label;
-        glMerge         *merge;
+        gdouble              x, y;
+        gdouble              w, h;
+        glColorNode         *line_color_node;
+        gdouble              line_width;
+        glColorNode         *fill_color_node;
+        gchar               *font_family;
+        gdouble              font_size;
+        PangoWeight          font_weight;
+        gboolean             font_italic_flag;
+        glColorNode         *text_color_node;
+        PangoAlignment       align;
+        gdouble              text_line_spacing;
+        gboolean             auto_shrink;
+        gdouble              image_w, image_h;
+        glTextNode          *filename;
+        glTextNode          *bc_data;
+        glLabelBarcodeStyle *bc_style;
+        gboolean             shadow_state;
+        gdouble              shadow_x, shadow_y;
+        glColorNode         *shadow_color_node;
+        gdouble              shadow_opacity;
+        glLabel             *label;
+        glMerge             *merge;
 
         gl_debug (DEBUG_EDITOR, "BEGIN");
 
@@ -857,19 +848,17 @@ object_changed_cb (glLabelObject  *object,
         {
 
                 gl_label_object_get_size (object, &w, &h);
-                bc_data = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
-                gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                            &backend_id, &id, &text_flag, &cs_flag, &format_digits);
-                line_color_node   = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
+                bc_data  = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
+                bc_style = gl_label_barcode_get_style (GL_LABEL_BARCODE(object));
+                line_color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
 
                 gl_object_editor_set_size (editor, w, h);
                 gl_object_editor_set_data (editor, (merge != NULL), bc_data);
-                gl_object_editor_set_bc_style (editor, backend_id, id, text_flag, cs_flag, format_digits);
+                gl_object_editor_set_bc_style (editor, bc_style);
                 gl_object_editor_set_bc_color (editor, (merge != NULL), line_color_node);
 
                 gl_text_node_free (&bc_data);
-                g_free (backend_id);
-                g_free (id);
+                gl_label_barcode_style_free (bc_style);
 
         }
 
@@ -899,32 +888,29 @@ object_changed_cb (glLabelObject  *object,
 void
 gl_object_editor_changed_cb (glObjectEditor *editor)
 {
-        glLabelObject     *object = editor->priv->object;
-        gdouble            x, y;
-        glColorNode       *line_color_node;
-        gdouble            line_width;
-        glColorNode       *fill_color_node;
-        gchar             *font_family;
-        gdouble            font_size;
-        PangoWeight        font_weight;
-        gboolean           font_italic_flag;
-        glColorNode       *text_color_node;
-        PangoAlignment     align;
-        gdouble            text_line_spacing;
-        gboolean           auto_shrink;
-        glTextNode        *filename;
-        gdouble            w, h;
-        gdouble            image_w, image_h;
-        gdouble            new_w, new_h;
-        glTextNode        *bc_data;
-        gchar             *backend_id;
-        gchar             *id;
-        gboolean           text_flag, cs_flag;
-        guint              format_digits;
-        gboolean           shadow_state;
-        gdouble            shadow_x, shadow_y;
-        glColorNode       *shadow_color_node;
-        gdouble            shadow_opacity;
+        glLabelObject       *object = editor->priv->object;
+        gdouble              x, y;
+        glColorNode         *line_color_node;
+        gdouble              line_width;
+        glColorNode         *fill_color_node;
+        gchar               *font_family;
+        gdouble              font_size;
+        PangoWeight          font_weight;
+        gboolean             font_italic_flag;
+        glColorNode         *text_color_node;
+        PangoAlignment       align;
+        gdouble              text_line_spacing;
+        gboolean             auto_shrink;
+        glTextNode          *filename;
+        gdouble              w, h;
+        gdouble              image_w, image_h;
+        gdouble              new_w, new_h;
+        glTextNode          *bc_data;
+        glLabelBarcodeStyle *bc_style;
+        gboolean             shadow_state;
+        gdouble              shadow_x, shadow_y;
+        glColorNode         *shadow_color_node;
+        gdouble              shadow_opacity;
 
         gl_debug (DEBUG_EDITOR, "BEGIN");
 
@@ -1014,19 +1000,16 @@ gl_object_editor_changed_cb (glObjectEditor *editor)
         {
 
                 line_color_node = gl_object_editor_get_bc_color (editor);
-                bc_data = gl_object_editor_get_data (editor);
-                gl_object_editor_get_bc_style (editor,
-                                               &backend_id, &id, &text_flag, &cs_flag, &format_digits);
+                bc_data  = gl_object_editor_get_data (editor);
+                bc_style = gl_object_editor_get_bc_style (editor);
 
                 gl_label_object_set_line_color (object, line_color_node, TRUE);
                 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), bc_data, TRUE);
-                gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                            backend_id, id, text_flag, cs_flag, format_digits, TRUE);
+                gl_label_barcode_set_style (GL_LABEL_BARCODE(object), bc_style, TRUE);
 
                 gl_color_node_free (&line_color_node);
                 gl_text_node_free (&bc_data);
-                g_free (backend_id);
-                g_free (id);
+                gl_label_barcode_style_free (bc_style);
 
         }
 
index dc03ca29d084c06fd68c6febf3a5379e84f22bb1..f9dec9cc0cf89b5e649687d7d92464c2df05b485 100644 (file)
 /* Local function prototypes                 */
 /*===========================================*/
 
-static glTextNode *extract_text_node  (gchar          *text,
-                                      gint           *n);
+static glTextNode *extract_text_node  (const gchar         *text,
+                                      gint                *n);
 
-static gboolean    is_empty_field     (glTextNode     *text_node,
-                                      glMergeRecord  *record);
+static gboolean    is_empty_field     (const glTextNode    *text_node,
+                                      const glMergeRecord *record);
 
 
 /****************************************************************************/
 /* Expand single node into representative string.                           */
 /****************************************************************************/
 gchar *
-gl_text_node_expand (glTextNode    *text_node,
-                    glMergeRecord *record)
+gl_text_node_expand (const glTextNode    *text_node,
+                    const glMergeRecord *record)
 {
        gchar *text;
 
@@ -70,8 +70,8 @@ gl_text_node_expand (glTextNode    *text_node,
 /* PRIVATE.  Is node a field that evaluates empty?                          */
 /*--------------------------------------------------------------------------*/
 static gboolean
-is_empty_field (glTextNode    *text_node,
-               glMergeRecord *record)
+is_empty_field (const glTextNode    *text_node,
+               const glMergeRecord *record)
 {
        gchar    *text;
        gboolean  ret = FALSE;
@@ -92,7 +92,7 @@ is_empty_field (glTextNode    *text_node,
 /* Create a single text node from given text.                               */
 /****************************************************************************/
 glTextNode *
-gl_text_node_new_from_text (gchar *text)
+gl_text_node_new_from_text (const gchar *text)
 {
        gint n;
 
@@ -104,8 +104,8 @@ gl_text_node_new_from_text (gchar *text)
 /* PRIVATE.  Create a single text node from given text. n = characters used */
 /*--------------------------------------------------------------------------*/
 static glTextNode *
-extract_text_node (gchar *text,
-                  gint  *n)
+extract_text_node (const gchar *text,
+                  gint        *n)
 {
        glTextNode *text_node;
        gchar      *p;
@@ -118,7 +118,7 @@ extract_text_node (gchar *text,
                text_node->field_flag = TRUE;
                *n = strlen ("${");
                text += *n;
-               for (p = text, m = 0; *p != 0; p++, m++, (*n)++) {
+               for (p = (gchar *)text, m = 0; *p != 0; p++, m++, (*n)++) {
                        if (*p == '}') {
                                (*n)++;
                                break;
@@ -128,7 +128,7 @@ extract_text_node (gchar *text,
        } else {
                /* We are at the beginning of a literal node */
                text_node->field_flag = FALSE;
-               for (p = text, *n = 0; *p != 0; p++, (*n)++) {
+               for (p = (gchar *)text, *n = 0; *p != 0; p++, (*n)++) {
                        if (strncmp (p, "${", strlen ("${")) == 0)
                                break;
                        if (*p == '\n')
@@ -145,7 +145,7 @@ extract_text_node (gchar *text,
 /* Copy a single text node.                                                 */
 /****************************************************************************/
 glTextNode *
-gl_text_node_dup (glTextNode *src)
+gl_text_node_dup (const glTextNode *src)
 {
        glTextNode *dst;
 
@@ -179,8 +179,8 @@ gl_text_node_free (glTextNode **text_node)
 /* Compare 2 text nodes for equality.                                       */
 /****************************************************************************/
 gboolean
-gl_text_node_equal (glTextNode     *text_node1,
-                   glTextNode     *text_node2)
+gl_text_node_equal (const glTextNode     *text_node1,
+                   const glTextNode     *text_node2)
 {
        /* First take care of the case of either or both being NULL. */
        if ( text_node1 == NULL ) {
@@ -214,8 +214,8 @@ gl_text_node_equal (glTextNode     *text_node1,
 /* Expand text lines into single string.                                    */
 /****************************************************************************/
 gchar *
-gl_text_node_lines_expand (GList         *lines,
-                          glMergeRecord *record)
+gl_text_node_lines_expand (GList               *lines,
+                          const glMergeRecord *record)
 {
        GList      *p_line, *p_node;
        glTextNode *text_node;
@@ -261,7 +261,7 @@ gl_text_node_lines_expand (GList         *lines,
 /* Parse a string back into text lines.                                     */
 /****************************************************************************/
 GList *
-gl_text_node_lines_new_from_text (gchar *text)
+gl_text_node_lines_new_from_text (const gchar *text)
 {
        GList      *lines, *nodes;
        glTextNode *text_node;
@@ -270,7 +270,7 @@ gl_text_node_lines_new_from_text (gchar *text)
 
        lines = NULL;
        nodes = NULL;
-       for (p = text; *p != 0; p += n) {
+       for (p = (gchar *)text; *p != 0; p += n) {
                if (*p != '\n') {
                        text_node = extract_text_node (p, &n);
                        nodes = g_list_append (nodes, text_node);
index 68189b6c3d1b8ab2312c6ef295b5560fbb139aab..0c7a8f90436d2244dc8290986b6b259e0fa8e02d 100644 (file)
@@ -31,23 +31,23 @@ typedef struct {
        gchar *data;
 } glTextNode;
 
-gchar      *gl_text_node_expand              (glTextNode     *text_node,
-                                             glMergeRecord  *record);
-glTextNode *gl_text_node_new_from_text       (gchar          *text);
-glTextNode *gl_text_node_dup                 (glTextNode     *text_node);
-void        gl_text_node_free                (glTextNode    **text_node);
+gchar      *gl_text_node_expand              (const glTextNode    *text_node,
+                                             const glMergeRecord *record);
+glTextNode *gl_text_node_new_from_text       (const gchar         *text);
+glTextNode *gl_text_node_dup                 (const glTextNode    *text_node);
+void        gl_text_node_free                (glTextNode         **text_node);
 
-gboolean    gl_text_node_equal               (glTextNode     *text_node1,
-                                             glTextNode     *text_node2);
+gboolean    gl_text_node_equal               (const glTextNode    *text_node1,
+                                             const glTextNode    *text_node2);
 
-gchar      *gl_text_node_lines_expand        (GList          *lines,
-                                             glMergeRecord  *record);
-GList      *gl_text_node_lines_new_from_text (gchar          *text);
-GList      *gl_text_node_lines_dup           (GList          *lines);
-void        gl_text_node_lines_free          (GList         **lines);
+gchar      *gl_text_node_lines_expand        (GList               *lines,
+                                             const glMergeRecord *record);
+GList      *gl_text_node_lines_new_from_text (const gchar         *text);
+GList      *gl_text_node_lines_dup           (GList               *lines);
+void        gl_text_node_lines_free          (GList              **lines);
 
 /* debug function */
-void        gl_text_node_lines_print         (GList          *lines);
+void        gl_text_node_lines_print         (GList               *lines);
 
 G_END_DECLS
 
index 1abedf54bdc37b138f4ba41e749a590ce447d78c..fc42cd280afe012733a1f287b07397b657c0187c 100644 (file)
@@ -439,28 +439,31 @@ static void
 xml04_parse_barcode_props (xmlNodePtr    node,
                           glLabelBarcode *object)
 {
-       xmlChar       *id;
-        const gchar   *backend_id;
-       gboolean       text_flag;
-       glColorNode   *color_node;
-       gdouble        scale;
-       xmlNodePtr     child;
-       glTextNode    *text_node;
+       gchar               *id;
+        const gchar         *backend_id;
+        glLabelBarcodeStyle *style;
+       glColorNode         *color_node;
+       xmlNodePtr           child;
+       glTextNode          *text_node;
 
        gl_debug (DEBUG_XML, "START");
 
        color_node = gl_color_node_new_default ();
        color_node->color = lgl_xml_get_prop_uint (node, "color", 0);
 
-       id = xmlGetProp (node, (xmlChar *)"style");
+        style = gl_label_barcode_style_new ();
+
+       id = lgl_xml_get_prop_string (node, "style", "POSTNET");
         backend_id = gl_barcode_backends_guess_backend_id (id);
+        gl_label_barcode_style_set_backend_id (style, backend_id);
+        gl_label_barcode_style_set_style_id (style, id);
+
+       style->text_flag     = lgl_xml_get_prop_boolean (node, "text", FALSE);
+        style->checksum_flag = TRUE;
+        style->format_digits = 0;
+
+       gl_label_barcode_set_style (object, style, FALSE);
 
-       text_flag = lgl_xml_get_prop_boolean (node, "text", FALSE);
-       scale = lgl_xml_get_prop_double (node, "scale", 1.0);
-       if (scale == 0.0) {
-               scale = 0.5; /* Set to a valid value */
-       }
-       gl_label_barcode_set_props (object, (gchar *)id, (gchar *)backend_id, text_flag, TRUE, 0, FALSE);
        gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color_node, FALSE);
 
        child = node->xmlChildrenNode;
@@ -478,7 +481,8 @@ xml04_parse_barcode_props (xmlNodePtr    node,
 
        gl_color_node_free (&color_node);
        gl_text_node_free (&text_node);
-       xmlFree (id);
+       g_free (id);
+        gl_label_barcode_style_free (style);
 
        gl_debug (DEBUG_XML, "END");
 }
index 3483846dd656eae3627684c12ae56879e9c3e564..04f7875582128ee74579a0b7c69e6d69bdf0923d 100644 (file)
@@ -740,17 +740,15 @@ static void
 xml_parse_object_barcode (xmlNodePtr  node,
                          glLabel    *label)
 {
-       GObject            *object;
-       gdouble             x, y;
-       gdouble             w, h;
-       gchar              *string;
-       glTextNode         *text_node;
-       gchar              *backend_id;
-       gchar              *id;
-       gboolean            text_flag;
-       gboolean            checksum_flag;
-       glColorNode        *color_node;
-       guint               format_digits;
+       GObject             *object;
+       gdouble              x, y;
+       gdouble              w, h;
+       gchar               *string;
+       glTextNode          *text_node;
+       gchar               *backend_id;
+       gchar               *id;
+        glLabelBarcodeStyle *style;
+       glColorNode         *color_node;
 
        gl_debug (DEBUG_XML, "START");
 
@@ -766,20 +764,23 @@ xml_parse_object_barcode (xmlNodePtr  node,
        h = lgl_xml_get_prop_length (node, "h", 0);
        gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h, FALSE);
 
-       /* prop attrs */
+       /* style attrs */
+        style = gl_label_barcode_style_new ();
        backend_id = lgl_xml_get_prop_string (node, "backend", NULL);
        id = lgl_xml_get_prop_string (node, "style", NULL);
         if ( !backend_id )
         {
                 backend_id = g_strdup (gl_barcode_backends_guess_backend_id (id));
         }
-       text_flag = lgl_xml_get_prop_boolean (node, "text", FALSE);
-       checksum_flag = lgl_xml_get_prop_boolean (node, "checksum", TRUE);
-       format_digits = lgl_xml_get_prop_uint (node, "format", 10);
-       gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   backend_id, id, text_flag, checksum_flag, format_digits, FALSE);
+        gl_label_barcode_style_set_backend_id (style, backend_id);
+        gl_label_barcode_style_set_style_id (style, id);
+       style->text_flag = lgl_xml_get_prop_boolean (node, "text", FALSE);
+       style->checksum_flag = lgl_xml_get_prop_boolean (node, "checksum", TRUE);
+       style->format_digits = lgl_xml_get_prop_uint (node, "format", 10);
+       gl_label_barcode_set_style (GL_LABEL_BARCODE(object), style, FALSE);
        g_free (backend_id);
        g_free (id);
+        gl_label_barcode_style_free (style);
        
        color_node = gl_color_node_new_default ();
        string = lgl_xml_get_prop_string (node, "color_field", NULL);
@@ -1590,16 +1591,12 @@ xml_create_object_barcode (xmlNodePtr     parent,
                           xmlNsPtr       ns,
                           glLabelObject *object)
 {
-       xmlNodePtr        node;
-       gdouble           x, y;
-       gdouble           w, h;
-       glTextNode       *text_node;
-       gchar            *backend_id;
-       gchar            *id;
-       gboolean          text_flag;
-       gboolean          checksum_flag;
-       glColorNode      *color_node;
-       guint             format_digits;
+       xmlNodePtr           node;
+       gdouble              x, y;
+       gdouble              w, h;
+       glTextNode          *text_node;
+        glLabelBarcodeStyle *style;
+       glColorNode         *color_node;
 
        gl_debug (DEBUG_XML, "START");
 
@@ -1616,15 +1613,11 @@ xml_create_object_barcode (xmlNodePtr     parent,
        lgl_xml_set_prop_length (node, "h", h);
 
        /* Barcode properties attrs */
-       gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
-       lgl_xml_set_prop_string (node, "backend", backend_id);
-       lgl_xml_set_prop_string (node, "style", id);
-       lgl_xml_set_prop_boolean (node, "text", text_flag);
-       lgl_xml_set_prop_boolean (node, "checksum", checksum_flag);
-       
-       g_free (backend_id);
-       g_free (id);
+       style = gl_label_barcode_get_style (GL_LABEL_BARCODE(object));
+       lgl_xml_set_prop_string (node, "backend", style->backend_id);
+       lgl_xml_set_prop_string (node, "style", style->id);
+       lgl_xml_set_prop_boolean (node, "text", style->text_flag);
+       lgl_xml_set_prop_boolean (node, "checksum", style->checksum_flag);
        
        color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
        if (color_node->field_flag)
@@ -1642,7 +1635,7 @@ xml_create_object_barcode (xmlNodePtr     parent,
        text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
        if (text_node->field_flag) {
                lgl_xml_set_prop_string (node, "field", text_node->data);
-               lgl_xml_set_prop_int (node, "format", format_digits);
+               lgl_xml_set_prop_int (node, "format", style->format_digits);
        } else {
                lgl_xml_set_prop_string (node, "data", text_node->data);
        }
@@ -1654,6 +1647,8 @@ xml_create_object_barcode (xmlNodePtr     parent,
        /* shadow attrs */
        xml_create_shadow_attrs (node, object);
 
+        gl_label_barcode_style_free (style);
+
        gl_debug (DEBUG_XML, "END");
 }