Encapsulate barcode style into a single struct and related clean-up.
/*========================================================*/
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;
+
};
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);
gboolean checkpoint)
{
glLabelBarcode *lbc;
+ glLabelBarcodeStyle *style;
glColorNode *line_color_node;
lbc = g_object_new (gl_label_barcode_get_type(), NULL);
}
/* 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));
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");
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");
}
/* 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;
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;
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 )
{
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));
}
}
-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);
}
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);
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);
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;
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);
{
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));
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");
}
}
+/*****************************************************************************/
+/* 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);
+}
+
+
+
/*
};
-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
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);
/* 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;
/* 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));
}
/* 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;
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);
/* 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;
/* 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);
/* 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;
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);
/* 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;
/* 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));
}
/* 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;
/* 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);
/* New merge object. */
/*****************************************************************************/
glMerge *
-gl_merge_new (gchar *name)
+gl_merge_new (const gchar *name)
{
glMerge *merge = NULL;
GList *p;
/* Duplicate merge. */
/*****************************************************************************/
glMerge *
-gl_merge_dup (glMerge *src_merge)
+gl_merge_dup (const glMerge *src_merge)
{
glMerge *dst_merge;
/* Get name of merge. */
/*****************************************************************************/
gchar *
-gl_merge_get_name (glMerge *merge)
+gl_merge_get_name (const glMerge *merge)
{
gl_debug (DEBUG_MERGE, "");
/* Get description of merge. */
/*****************************************************************************/
gchar *
-gl_merge_get_description (glMerge *merge)
+gl_merge_get_description (const glMerge *merge)
{
gl_debug (DEBUG_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, "");
/* 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;
/* Get src of merge. */
/*****************************************************************************/
gchar *
-gl_merge_get_src (glMerge *merge)
+gl_merge_get_src (const glMerge *merge)
{
gl_debug (DEBUG_MERGE, "");
/* Get Key List. */
/*****************************************************************************/
GList *
-gl_merge_get_key_list (glMerge *merge)
+gl_merge_get_key_list (const glMerge *merge)
{
GList *key_list = NULL;
/* Get Key List. */
/*****************************************************************************/
gchar *
-gl_merge_get_primary_key (glMerge *merge)
+gl_merge_get_primary_key (const glMerge *merge)
{
gchar *key = NULL;
/* 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;
/* 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;
/* 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, "");
/* Count selected records. */
/*****************************************************************************/
gint
-gl_merge_get_record_count (glMerge *merge)
+gl_merge_get_record_count (const glMerge *merge)
{
GList *p;
glMergeRecord *record;
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);
};
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
gl_object_editor_load_bc_styles (glObjectEditor *editor,
const gchar *backend_id)
{
- const gchar *backend_name;
GList *styles;
gl_debug (DEBUG_EDITOR, "START");
/* 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);
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);
/*****************************************************************************/
/* 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;
}
#define __OBJECT_EDITOR_PRIVATE_H__
#include <gtk/gtk.h>
+#include "label-barcode.h"
G_BEGIN_DECLS
/*
* 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);
/*
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");
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),
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");
{
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);
}
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");
{
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);
}
/* 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;
/* 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;
/* 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;
/* 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;
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;
} 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')
/* Copy a single text node. */
/****************************************************************************/
glTextNode *
-gl_text_node_dup (glTextNode *src)
+gl_text_node_dup (const glTextNode *src)
{
glTextNode *dst;
/* 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 ) {
/* 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;
/* 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;
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);
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
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;
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");
}
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");
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);
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");
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)
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);
}
/* shadow attrs */
xml_create_shadow_attrs (node, object);
+ gl_label_barcode_style_free (style);
+
gl_debug (DEBUG_XML, "END");
}