mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Replaced the tag implementation
The new implementation supports custom tags which are provided by the user as well as default tags which are provided by subsurface. Default tags can be translated and will be written to XML in their non-localized form. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
This commit is contained in:
parent
2ef80930ff
commit
6fe8cb6521
7 changed files with 265 additions and 66 deletions
26
save-xml.c
26
save-xml.c
|
@ -392,20 +392,28 @@ static void save_events(FILE *f, struct event *ev)
|
|||
}
|
||||
}
|
||||
|
||||
static void save_tags(FILE *f, int tags)
|
||||
static void save_tags(FILE *f, struct tag_entry *tag_list)
|
||||
{
|
||||
int i, more = 0;
|
||||
int more = 0;
|
||||
struct tag_entry *tmp = tag_list->next;
|
||||
|
||||
fprintf(f, " tags='");
|
||||
for (i = 0; i < DTAG_NR; i++) {
|
||||
if (tags & (1 << i)) {
|
||||
/* Only write tag attribute if the list contains at least one item */
|
||||
if (tmp != NULL) {
|
||||
fprintf(f, " tags='");
|
||||
|
||||
while (tmp != NULL) {
|
||||
if (more)
|
||||
fprintf(f, ", ");
|
||||
fprintf(f, "%s", dtag_names[i]);
|
||||
/* If the tag has been translated, write the source to the xml file */
|
||||
if (tmp->tag->source != NULL)
|
||||
fprintf(f, "%s", tmp->tag->source);
|
||||
else
|
||||
fprintf(f, "%s", tmp->tag->name);
|
||||
tmp = tmp->next;
|
||||
more = 1;
|
||||
}
|
||||
fprintf(f, "'");
|
||||
}
|
||||
fprintf(f, "'");
|
||||
}
|
||||
|
||||
static void show_date(FILE *f, timestamp_t when)
|
||||
|
@ -468,8 +476,8 @@ void save_dive(FILE *f, struct dive *dive)
|
|||
fprintf(f, " rating='%d'", dive->rating);
|
||||
if (dive->visibility)
|
||||
fprintf(f, " visibility='%d'", dive->visibility);
|
||||
if (dive->dive_tags)
|
||||
save_tags(f, dive->dive_tags);
|
||||
if (dive->tag_list != NULL)
|
||||
save_tags(f, dive->tag_list);
|
||||
|
||||
show_date(f, dive->when);
|
||||
fprintf(f, " duration='%u:%02u min'>\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue