gboolean metadata_write_string(FileData *fd, const gchar *key, const char *value) { GList *list = g_list_append(NULL, g_strdup(value)); gboolean ret = metadata_write_list(fd, key, list); string_list_free(list); return ret; }
gboolean meta_data_set_keyword_mark(FileData *fd, gint n, gboolean value, gpointer data) { GList *path = data; GList *keywords = NULL; GtkTreeIter iter; if (!keyword_tree_get_iter(GTK_TREE_MODEL(keyword_tree), &iter, path)) return FALSE; keywords = metadata_read_list(fd, KEYWORD_KEY, METADATA_PLAIN); if (!!keyword_tree_is_set(GTK_TREE_MODEL(keyword_tree), &iter, keywords) != !!value) { if (value) { keyword_tree_set(GTK_TREE_MODEL(keyword_tree), &iter, &keywords); } else { keyword_tree_reset(GTK_TREE_MODEL(keyword_tree), &iter, &keywords); } metadata_write_list(fd, KEYWORD_KEY, keywords); } string_list_free(keywords); return TRUE; }
static void bar_pane_keywords_set_selection(PaneKeywordsData *pkd, gboolean append) { GList *keywords = NULL; GList *list = NULL; GList *work; keywords = keyword_list_pull(pkd->keyword_view); list = layout_selection_list(pkd->pane.lw); list = file_data_process_groups_in_selection(list, FALSE, NULL); work = list; while (work) { FileData *fd = work->data; work = work->next; if (append) { metadata_append_list(fd, KEYWORD_KEY, keywords); } else { metadata_write_list(fd, KEYWORD_KEY, keywords); } } filelist_free(list); string_list_free(keywords); }
gboolean metadata_write_list(FileData *fd, const gchar *key, const GList *values) { if (!fd->modified_xmp) { fd->modified_xmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)string_list_free); } g_hash_table_insert(fd->modified_xmp, g_strdup(key), string_list_copy((GList *)values)); if (fd->exif) { exif_update_metadata(fd->exif, key, values); } metadata_write_queue_add(fd); file_data_increment_version(fd); file_data_send_notification(fd, NOTIFY_METADATA); if (options->metadata.sync_grouped_files && metadata_check_key(group_keys, key)) { GList *work = fd->sidecar_files; while (work) { FileData *sfd = work->data; work = work->next; if (filter_file_class(sfd->extension, FORMAT_CLASS_META)) continue; metadata_write_list(sfd, key, values); } } return TRUE; }
gboolean metadata_append_list(FileData *fd, const gchar *key, const GList *values) { GList *list = metadata_read_list(fd, key, METADATA_PLAIN); if (!list) { return metadata_write_list(fd, key, values); } else { gboolean ret; list = g_list_concat(list, string_list_copy(values)); list = remove_duplicate_strings_from_list(list); ret = metadata_write_list(fd, key, list); string_list_free(list); return ret; } }
static void bar_pane_keywords_write(PaneKeywordsData *pkd) { GList *list; if (!pkd->fd) return; list = keyword_list_pull(pkd->keyword_view); metadata_write_list(pkd->fd, KEYWORD_KEY, list); string_list_free(list); }