+2007-11-18 Jim Evins <evins@snaught.com>
+
+ * libglabels/db.c: (lgl_db_register_template), (read_templates):
+ When registering a new template, don't add to "User defined" category before
+ writing to file. Add to "User defined" category when reading from "~/.glabels"
+ directory instead. This will allow legacy templates (and manually created
+ templates) to be automatically added to the "user defined" category.
+ * libglabels/xml-template.c:
+ (lgl_xml_template_create_template_node):
+ Fixed typo/bug causing brand to be wrong.
+
2007-11-16 Jim Evins <evins@snaught.com>
* libglabels/db.c:
if (lgl_db_is_paper_id_known (template->paper_id))
{
- template_copy = lgl_template_dup (template);
- lgl_template_add_category (template_copy, "user-defined");
-
dir = LGL_USER_DATA_DIR;
mkdir (dir, 0775); /* Try to make sure directory exists. */
filename = g_strdup_printf ("%s_%s.template", template->brand, template->part);
abs_filename = g_build_filename (dir, filename, NULL);
- bytes_written = lgl_xml_template_write_template_to_file (template_copy, abs_filename);
+ bytes_written = lgl_xml_template_write_template_to_file (template, abs_filename);
g_free (dir);
g_free (filename);
g_free (abs_filename);
if (bytes_written > 0)
{
+ template_copy = lgl_template_dup (template);
+ lgl_template_add_category (template_copy, "user-defined");
templates = g_list_append (templates, template_copy);
return LGL_DB_REG_OK;
}
static GList *
read_templates (void)
{
- gchar *data_dir;
- GList *templates = NULL;
+ gchar *data_dir;
+ GList *templates = NULL;
+ GList *p;
+ lglTemplate *template;
- data_dir = LGL_SYSTEM_DATA_DIR;
+ /*
+ * User defined templates. Add to user-defined category.
+ */
+ data_dir = LGL_USER_DATA_DIR;
templates = read_template_files_from_dir (templates, data_dir);
g_free (data_dir);
+ for ( p=templates; p != NULL; p=p->next )
+ {
+ template = (lglTemplate *)p->data;
+ lgl_template_add_category (template, "user-defined");
+ }
- data_dir = LGL_USER_DATA_DIR;
+ /*
+ * System templates.
+ */
+ data_dir = LGL_SYSTEM_DATA_DIR;
templates = read_template_files_from_dir (templates, data_dir);
g_free (data_dir);
node = xmlNewChild (root, ns, (xmlChar *)"Template", NULL);
- lgl_xml_set_prop_string (node, "brand", template->part);
+ lgl_xml_set_prop_string (node, "brand", template->brand);
lgl_xml_set_prop_string (node, "part", template->part);
lgl_xml_set_prop_string (node, "size", template->paper_id);