# HG changeset patch # User zas_ # Date 1228081381 0 # Node ID bb02d0e2a5731ad93badf21cacab44b03ba1a459 # Parent a4ea0c74a6e24157fc95fe5c99c76666de0221c6 Rename most comment_*() functions to more appropriate metadata_*(). diff -r a4ea0c74a6e2 -r bb02d0e2a573 src/bar_info.c --- a/src/bar_info.c Sun Nov 30 11:46:34 2008 +0000 +++ b/src/bar_info.c Sun Nov 30 21:43:01 2008 +0000 @@ -406,7 +406,7 @@ list = keyword_list_pull(bd->keyword_view); comment = comment_pull(bd->comment_view); - comment_write(bd->fd, list, comment); + metadata_write(bd->fd, list, comment); string_list_free(list); g_free(comment); @@ -511,7 +511,7 @@ gtk_label_set_text(GTK_LABEL(bd->label_file_time), (bd->fd) ? text_from_time(bd->fd->date) : ""); } - if (comment_read(bd->fd, &keywords, &comment)) + if (metadata_read(bd->fd, &keywords, &comment)) { keyword_list_push(bd->keyword_view, keywords); gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view)), diff -r a4ea0c74a6e2 -r bb02d0e2a573 src/image-overlay.c --- a/src/image-overlay.c Sun Nov 30 11:46:34 2008 +0000 +++ b/src/image-overlay.c Sun Nov 30 21:43:01 2008 +0000 @@ -178,7 +178,7 @@ g_assert(fd); - if (comment_read(fd, &keywords, NULL)) + if (metadata_read(fd, &keywords, NULL)) { GList *work = keywords; @@ -275,7 +275,7 @@ } else if (strcmp(name, "comment") == 0) { - comment_read(imd->image_fd, NULL, &data); + metadata_read(imd->image_fd, NULL, &data); } else { diff -r a4ea0c74a6e2 -r bb02d0e2a573 src/metadata.c --- a/src/metadata.c Sun Nov 30 11:46:34 2008 +0000 +++ b/src/metadata.c Sun Nov 30 21:43:01 2008 +0000 @@ -23,6 +23,12 @@ #include "ui_misc.h" #include "utilops.h" +typedef enum { + MK_NONE, + MK_KEYWORDS, + MK_COMMENT +} MetadataKey; + /* *------------------------------------------------------------------- @@ -30,7 +36,7 @@ *------------------------------------------------------------------- */ -static gint comment_file_write(gchar *path, GList *keywords, const gchar *comment) +static gint metadata_file_write(gchar *path, GList *keywords, const gchar *comment) { SecureSaveInfo *ssi; @@ -57,61 +63,55 @@ return (secure_close(ssi) == 0); } -static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *comment) +static gint metadata_legacy_write(FileData *fd, GList *keywords, const gchar *comment) { - gchar *comment_path; + gchar *metadata_path; gint success = FALSE; /* If an existing metadata file exists, we will try writing to * it's location regardless of the user's preference. */ - comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); - if (comment_path && !access_file(comment_path, W_OK)) + metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); + if (metadata_path && !access_file(metadata_path, W_OK)) { - g_free(comment_path); - comment_path = NULL; + g_free(metadata_path); + metadata_path = NULL; } - if (!comment_path) + if (!metadata_path) { - gchar *comment_dir; + gchar *metadata_dir; mode_t mode = 0755; - comment_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode); - if (recursive_mkdir_if_not_exists(comment_dir, mode)) + metadata_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode); + if (recursive_mkdir_if_not_exists(metadata_dir, mode)) { gchar *filename = g_strconcat(fd->name, GQ_CACHE_EXT_METADATA, NULL); - comment_path = g_build_filename(comment_dir, filename, NULL); + metadata_path = g_build_filename(metadata_dir, filename, NULL); g_free(filename); } - g_free(comment_dir); + g_free(metadata_dir); } - if (comment_path) + if (metadata_path) { - gchar *comment_pathl; + gchar *metadata_pathl; - DEBUG_1("Saving comment: %s", comment_path); + DEBUG_1("Saving comment: %s", metadata_path); - comment_pathl = path_from_utf8(comment_path); + metadata_pathl = path_from_utf8(metadata_path); - success = comment_file_write(comment_pathl, keywords, comment); + success = metadata_file_write(metadata_pathl, keywords, comment); - g_free(comment_pathl); - g_free(comment_path); + g_free(metadata_pathl); + g_free(metadata_path); } return success; } -typedef enum { - MK_NONE, - MK_KEYWORDS, - MK_COMMENT -} MetadataKey; - -static gint comment_file_read(gchar *path, GList **keywords, gchar **comment) +static gint metadata_file_read(gchar *path, GList **keywords, gchar **comment) { FILE *f; gchar s_buf[1024]; @@ -197,42 +197,42 @@ return TRUE; } -static gint comment_delete_legacy(FileData *fd) +static gint metadata_legacy_delete(FileData *fd) { - gchar *comment_path; - gchar *comment_pathl; + gchar *metadata_path; + gchar *metadata_pathl; gint success = FALSE; if (!fd) return FALSE; - comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); - if (!comment_path) return FALSE; + metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); + if (!metadata_path) return FALSE; - comment_pathl = path_from_utf8(comment_path); + metadata_pathl = path_from_utf8(metadata_path); - success = !unlink(comment_pathl); + success = !unlink(metadata_pathl); - g_free(comment_pathl); - g_free(comment_path); + g_free(metadata_pathl); + g_free(metadata_path); return success; } -static gint comment_legacy_read(FileData *fd, GList **keywords, gchar **comment) +static gint metadata_legacy_read(FileData *fd, GList **keywords, gchar **comment) { - gchar *comment_path; - gchar *comment_pathl; + gchar *metadata_path; + gchar *metadata_pathl; gint success = FALSE; if (!fd) return FALSE; - comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); - if (!comment_path) return FALSE; + metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); + if (!metadata_path) return FALSE; - comment_pathl = path_from_utf8(comment_path); + metadata_pathl = path_from_utf8(metadata_path); - success = comment_file_read(comment_pathl, keywords, comment); + success = metadata_file_read(metadata_pathl, keywords, comment); - g_free(comment_pathl); - g_free(comment_path); + g_free(metadata_pathl); + g_free(metadata_path); return success; } @@ -264,7 +264,7 @@ #define COMMENT_KEY "Xmp.dc.description" #define KEYWORD_KEY "Xmp.dc.subject" -static gint comment_xmp_read(FileData *fd, GList **keywords, gchar **comment) +static gint metadata_xmp_read(FileData *fd, GList **keywords, gchar **comment) { ExifData *exif; @@ -339,7 +339,7 @@ return (comment && *comment) || (keywords && *keywords); } -static gint comment_xmp_write(FileData *fd, GList *keywords, const gchar *comment) +static gint metadata_xmp_write(FileData *fd, GList *keywords, const gchar *comment) { gint success; gint write_comment = (comment && comment[0]); @@ -385,21 +385,21 @@ return success; } -gint comment_write(FileData *fd, GList *keywords, const gchar *comment) +gint metadata_write(FileData *fd, GList *keywords, const gchar *comment) { if (!fd) return FALSE; if (options->save_metadata_in_image_file && - comment_xmp_write(fd, keywords, comment)) + metadata_xmp_write(fd, keywords, comment)) { - comment_delete_legacy(fd); + metadata_legacy_delete(fd); return TRUE; } - return comment_legacy_write(fd, keywords, comment); + return metadata_legacy_write(fd, keywords, comment); } -gint comment_read(FileData *fd, GList **keywords, gchar **comment) +gint metadata_read(FileData *fd, GList **keywords, gchar **comment) { GList *keywords1 = NULL; GList *keywords2 = NULL; @@ -409,8 +409,8 @@ if (!fd) return FALSE; - res1 = comment_xmp_read(fd, &keywords1, &comment1); - res2 = comment_legacy_read(fd, &keywords2, &comment2); + res1 = metadata_xmp_read(fd, &keywords1, &comment1); + res2 = metadata_legacy_read(fd, &keywords2, &comment2); if (!res1 && !res2) { @@ -461,7 +461,7 @@ GList *keywords = NULL; GList *save_list = NULL; - comment_read(fd, &keywords, &comment); + metadata_read(fd, &keywords, &comment); if (comment_to_use) { @@ -513,7 +513,7 @@ } } - comment_write(fd, save_list, comment); + metadata_write(fd, save_list, comment); string_list_free(keywords); g_free(comment); diff -r a4ea0c74a6e2 -r bb02d0e2a573 src/metadata.h --- a/src/metadata.h Sun Nov 30 11:46:34 2008 +0000 +++ b/src/metadata.h Sun Nov 30 21:43:01 2008 +0000 @@ -14,9 +14,9 @@ #ifndef METADATA_H #define METADATA_H -gint comment_write(FileData *fd, GList *keywords, const gchar *comment); +gint metadata_write(FileData *fd, GList *keywords, const gchar *comment); -gint comment_read(FileData *fd, GList **keywords, gchar **comment); +gint metadata_read(FileData *fd, GList **keywords, gchar **comment); void metadata_set_keywords(FileData *fd, GList *keywords_to_use, gchar *comment_to_use, gint add); gint keyword_list_find(GList *list, const gchar *keyword); diff -r a4ea0c74a6e2 -r bb02d0e2a573 src/search.c --- a/src/search.c Sun Nov 30 11:46:34 2008 +0000 +++ b/src/search.c Sun Nov 30 21:43:01 2008 +0000 @@ -1804,7 +1804,7 @@ tested = TRUE; match = FALSE; - if (comment_read(fd, &list, NULL)) + if (metadata_read(fd, &list, NULL)) { GList *needle; GList *haystack; @@ -1882,7 +1882,7 @@ tested = TRUE; match = FALSE; - if (comment_read(fd, NULL, &comment)) + if (metadata_read(fd, NULL, &comment)) { if (! sd->search_comment_match_case) {