}
+/*****************************************************************************/
+/* Test if backend id is valid. */
+/*****************************************************************************/
+gboolean
+gl_barcode_backends_is_backend_id_valid (const gchar *backend_id)
+{
+ gint i;
+
+ if (backend_id == NULL)
+ {
+ return FALSE;
+ }
+
+ for (i=0; backends[i].id != NULL; i++)
+ {
+ if (g_ascii_strcasecmp (backend_id, backends[i].id) == 0)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
/*****************************************************************************/
/* Guess backend id from style id (for backwards compatability). */
/*****************************************************************************/
const gchar *gl_barcode_backends_backend_id_to_name (const gchar *backend_id);
const gchar *gl_barcode_backends_backend_name_to_id (const gchar *backend_name);
+gboolean gl_barcode_backends_is_backend_id_valid (const gchar *backend_id);
const gchar *gl_barcode_backends_guess_backend_id (const gchar *id);
GList *gl_barcode_backends_get_styles_list (const gchar *backend_id);
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 )
+ if ( !gl_barcode_backends_is_backend_id_valid (backend_id) )
{
- backend_id = g_strdup (gl_barcode_backends_guess_backend_id (id));
+ if ( backend_id == NULL )
+ {
+ backend_id = g_strdup (gl_barcode_backends_guess_backend_id (id));
+ }
+ else
+ {
+ g_free (backend_id);
+ backend_id = g_strdup ("built-in");
+ }
}
gl_label_barcode_style_set_backend_id (style, backend_id);
gl_label_barcode_style_set_style_id (style, id);