Mercurial > geeqie.yaz
changeset 1422:91bed0d66cf2
gint -> gboolean and tidy up.
author | zas_ |
---|---|
date | Thu, 12 Mar 2009 22:35:45 +0000 |
parents | 130054d9dd8a |
children | 6933974f0885 |
files | src/exif-common.c src/exif.c src/exif.h src/exiv2.cc src/filecache.c src/filedata.c src/filedata.h |
diffstat | 7 files changed, 76 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/src/exif-common.c Thu Mar 12 21:27:13 2009 +0000 +++ b/src/exif-common.c Thu Mar 12 22:35:45 2009 +0000 @@ -119,7 +119,7 @@ } -static gint remove_suffix(gchar *str, const gchar *suffix, gint suffix_len) +static gboolean remove_suffix(gchar *str, const gchar *suffix, gint suffix_len) { gint str_len = strlen(str); @@ -189,8 +189,11 @@ gchar *text = exif_get_data_as_text(exif, "Exif.Photo.DateTimeOriginal"); gchar *subsec = NULL; - if (text) subsec = exif_get_data_as_text(exif, "Exif.Photo.SubSecTimeOriginal"); - if (!text) + if (text) + { + subsec = exif_get_data_as_text(exif, "Exif.Photo.SubSecTimeOriginal"); + } + else { text = exif_get_data_as_text(exif, "Exif.Image.DateTime"); if (text) subsec = exif_get_data_as_text(exif, "Exif.Photo.SubSecTime"); @@ -524,7 +527,7 @@ { NULL, NULL, NULL } }; -gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_valid) +gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gboolean *key_valid) { if (strncmp(key, EXIF_FORMATTED(), EXIF_FORMATTED_LEN) == 0) { @@ -579,7 +582,7 @@ { ExifItem *item; gchar *text; - gint key_valid; + gboolean key_valid; if (!key) return NULL; @@ -653,7 +656,7 @@ NNN.: the data in this segment */ -gint exif_jpeg_segment_find(guchar *data, guint size, +gboolean exif_jpeg_segment_find(guchar *data, guint size, guchar app_marker, const gchar *magic, guint magic_len, guint *seg_offset, guint *seg_length) { @@ -692,7 +695,7 @@ return FALSE; } -gint exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size) +gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size) { guint seg_offset = 0; guint seg_length = 0;
--- a/src/exif.c Thu Mar 12 21:27:13 2009 +0000 +++ b/src/exif.c Thu Mar 12 22:35:45 2009 +0000 @@ -607,7 +607,7 @@ return g_strdup(_(item->marker->description)); } -const gchar *exif_item_get_format_name(ExifItem *item, gint brief) +const gchar *exif_item_get_format_name(ExifItem *item, gboolean brief) { if (!item || !item->marker) return NULL; return (brief) ? ExifFormatList[item->format].short_name : ExifFormatList[item->format].description;
--- a/src/exif.h Thu Mar 12 21:27:13 2009 +0000 +++ b/src/exif.h Thu Mar 12 22:35:45 2009 +0000 @@ -139,7 +139,7 @@ gchar *exif_item_get_data(ExifItem *item, guint *data_len); gchar *exif_item_get_description(ExifItem *item); guint exif_item_get_format_id(ExifItem *item); -const gchar *exif_item_get_format_name(ExifItem *item, gint brief); +const gchar *exif_item_get_format_name(ExifItem *item, gboolean brief); gchar *exif_item_get_data_as_text(ExifItem *item); gint exif_item_get_integer(ExifItem *item, gint *value); ExifRational *exif_item_get_rational(ExifItem *item, gint *sign, guint n); @@ -149,7 +149,7 @@ gchar *exif_get_description_by_key(const gchar *key); gchar *exif_get_tag_description_by_key(const gchar *key); -gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_valid); +gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gboolean *key_valid); gint exif_update_metadata(ExifData *exif, const gchar *key, const GList *values); GList *exif_get_metadata(ExifData *exif, const gchar *key, MetadataFormat format); @@ -161,10 +161,10 @@ void exif_add_jpeg_color_profile(ExifData *exif, guchar *cp_data, guint cp_length); -gint exif_jpeg_segment_find(guchar *data, guint size, - guchar app_marker, const gchar *magic, guint magic_len, - guint *seg_offset, guint *seg_length); -gint exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size); +gboolean exif_jpeg_segment_find(guchar *data, guint size, + guchar app_marker, const gchar *magic, guint magic_len, + guint *seg_offset, guint *seg_length); +gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size); /*raw support */ guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, gint requested_height);
--- a/src/exiv2.cc Thu Mar 12 21:27:13 2009 +0000 +++ b/src/exiv2.cc Thu Mar 12 22:35:45 2009 +0000 @@ -669,7 +669,7 @@ } } -const char *exif_item_get_format_name(ExifItem *item, gint brief) +const char *exif_item_get_format_name(ExifItem *item, gboolean brief) { try { if (!item) return NULL;
--- a/src/filecache.c Thu Mar 12 21:27:13 2009 +0000 +++ b/src/filecache.c Thu Mar 12 22:35:45 2009 +0000 @@ -23,19 +23,20 @@ GList *list; gulong max_size; gulong size; - }; +}; typedef struct _FileCacheEntry FileCacheEntry; struct _FileCacheEntry { FileData *fd; gulong size; - }; +}; static void file_cache_notify_cb(FileData *fd, NotifyType type, gpointer data); FileCacheData *file_cache_new(FileCacheReleaseFunc release, gulong max_size) { FileCacheData *fc = g_new(FileCacheData, 1); + fc->release = release; fc->list = NULL; fc->max_size = max_size; @@ -163,9 +164,9 @@ void file_cache_dump(FileCacheData *fc) { - GList *work; - work = fc->list; + GList *work = fc->list; gulong n = 0; + DEBUG_1("cache dump: fc=%p max size:%ld size:%ld", fc, fc->max_size, fc->size); while (work)
--- a/src/filedata.c Thu Mar 12 21:27:13 2009 +0000 +++ b/src/filedata.c Thu Mar 12 22:35:45 2009 +0000 @@ -222,7 +222,9 @@ fd->extension = extension_from_path(fd->path); if (fd->extension == NULL) + { fd->extension = fd->name + strlen(fd->name); + } file_data_set_collate_keys(fd); } @@ -531,7 +533,6 @@ fd->ref--; #ifdef DEBUG_FILEDATA DEBUG_2("file_data_unref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line); - #else DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path); #endif @@ -540,15 +541,13 @@ GList *work; FileData *parent = fd->parent ? fd->parent : fd; - if (parent->ref > 0) - return; + if (parent->ref > 0) return; work = parent->sidecar_files; while (work) { FileData *sfd = work->data; - if (sfd->ref > 0) - return; + if (sfd->ref > 0) return; work = work->next; } @@ -643,19 +642,16 @@ void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) { - if (!fdci && fd) - fdci = fd->change; + if (!fdci && fd) fdci = fd->change; - if (!fdci) - return; + if (!fdci) return; g_free(fdci->source); g_free(fdci->dest); g_free(fdci); - if (fd) - fd->change = NULL; + if (fd) fd->change = NULL; } static gboolean file_data_can_write_directly(FileData *fd) @@ -672,6 +668,7 @@ { gchar *sidecar_path = NULL; GList *work; + if (!file_data_can_write_sidecar(fd)) return NULL; work = fd->parent ? fd->parent->sidecar_files : fd->sidecar_files; @@ -734,7 +731,7 @@ */ static SortType filelist_sort_method = SORT_NONE; -static gint filelist_sort_ascend = TRUE; +static gboolean filelist_sort_ascend = TRUE; gint filelist_sort_compare_filedata(FileData *fa, FileData *fb) @@ -775,7 +772,7 @@ return strcmp(fa->collate_key_name_nocase, fb->collate_key_name_nocase); } -gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend) +gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend) { filelist_sort_method = method; filelist_sort_ascend = ascend; @@ -787,26 +784,26 @@ return filelist_sort_compare_filedata(a, b); } -GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb) +GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, GCompareFunc cb) { filelist_sort_method = method; filelist_sort_ascend = ascend; return g_list_sort(list, cb); } -GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gint ascend, GCompareFunc cb) +GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, GCompareFunc cb) { filelist_sort_method = method; filelist_sort_ascend = ascend; return g_list_insert_sorted(list, data, cb); } -GList *filelist_sort(GList *list, SortType method, gint ascend) +GList *filelist_sort(GList *list, SortType method, gboolean ascend) { return filelist_sort_full(list, method, ascend, (GCompareFunc) filelist_sort_file_cb); } -GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend) +GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gboolean ascend) { return filelist_insert_sort_full(list, fd, method, ascend, (GCompareFunc) filelist_sort_file_cb); } @@ -832,7 +829,7 @@ return flist_filtered; } -static gint filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gint follow_symlinks) +static gboolean filelist_read_real(FileData *dir_fd, GList **files, GList **dirs, gboolean follow_symlinks) { DIR *dp; struct dirent *dir; @@ -906,12 +903,12 @@ return TRUE; } -gint filelist_read(FileData *dir_fd, GList **files, GList **dirs) +gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs) { return filelist_read_real(dir_fd, files, dirs, TRUE); } -gint filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs) +gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs) { return filelist_read_real(dir_fd, files, dirs, FALSE); } @@ -988,7 +985,7 @@ return g_list_reverse(new_list); } -GList *filelist_filter(GList *list, gint is_dir_list) +GList *filelist_filter(GList *list, gboolean is_dir_list) { GList *work; @@ -1090,14 +1087,17 @@ gboolean file_data_get_mark(FileData *fd, gint n) { gboolean valid = (fd->valid_marks & (1 << n)); + if (file_data_get_mark_func[n] && !valid) { guint old = fd->marks; gboolean value = (file_data_get_mark_func[n])(fd, n, file_data_mark_func_data[n]); + if (!value != !(fd->marks & (1 << n))) { fd->marks = fd->marks ^ (1 << n); } + fd->valid_marks |= (1 << n); if (old && !fd->marks) /* keep files with non-zero marks in memory */ { @@ -1319,8 +1319,7 @@ { FileDataChangeInfo *fdci = fd->change; - if (!fdci) - return; + if (!fdci) return; file_data_planned_change_remove(fd); @@ -1658,29 +1657,29 @@ g_free(dest_path_full); } -static gint file_data_sc_check_update_ci(FileData *fd, const gchar *dest_path, FileDataChangeType type) +static gboolean file_data_sc_check_update_ci(FileData *fd, const gchar *dest_path, FileDataChangeType type) { if (!file_data_sc_check_ci(fd, type)) return FALSE; file_data_sc_update_ci(fd, dest_path); return TRUE; } -gint file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path) +gboolean file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path) { return file_data_sc_check_update_ci(fd, dest_path, FILEDATA_CHANGE_COPY); } -gint file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path) +gboolean file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path) { return file_data_sc_check_update_ci(fd, dest_path, FILEDATA_CHANGE_MOVE); } -gint file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path) +gboolean file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path) { return file_data_sc_check_update_ci(fd, dest_path, FILEDATA_CHANGE_RENAME); } -gint file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path) +gboolean file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path) { return file_data_sc_check_update_ci(fd, dest_path, FILEDATA_CHANGE_UNSPECIFIED); } @@ -2130,6 +2129,7 @@ gboolean file_data_perform_ci(FileData *fd) { FileDataChangeType type = fd->change->type; + switch (type) { case FILEDATA_CHANGE_MOVE: @@ -2177,7 +2177,7 @@ * updates FileData structure according to FileDataChangeInfo */ -gint file_data_apply_ci(FileData *fd) +gboolean file_data_apply_ci(FileData *fd) { FileDataChangeType type = fd->change->type; @@ -2207,7 +2207,7 @@ return TRUE; } -gint file_data_sc_apply_ci(FileData *fd) +gboolean file_data_sc_apply_ci(FileData *fd) { GList *work; FileDataChangeType type = fd->change->type; @@ -2245,7 +2245,7 @@ FileDataNotifyFunc func; gpointer data; NotifyPriority priority; - }; +}; static GList *notify_func_list = NULL; @@ -2259,7 +2259,7 @@ return 0; } -gint file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority) +gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority) { NotifyData *nd; @@ -2274,7 +2274,7 @@ return TRUE; } -gint file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data) +gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data) { GList *work = notify_func_list; @@ -2329,7 +2329,7 @@ return TRUE; } -gint file_data_register_real_time_monitor(FileData *fd) +gboolean file_data_register_real_time_monitor(FileData *fd) { gint count; @@ -2353,7 +2353,7 @@ return TRUE; } -gint file_data_unregister_real_time_monitor(FileData *fd) +gboolean file_data_unregister_real_time_monitor(FileData *fd) { gint count;
--- a/src/filedata.h Thu Mar 12 21:27:13 2009 +0000 +++ b/src/filedata.h Thu Mar 12 22:35:45 2009 +0000 @@ -45,20 +45,20 @@ void file_data_disable_grouping(FileData *fd, gboolean disable); gint filelist_sort_compare_filedata(FileData *fa, FileData *fb); -gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gint ascend); -GList *filelist_sort(GList *list, SortType method, gint ascend); -GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gint ascend); -GList *filelist_sort_full(GList *list, SortType method, gint ascend, GCompareFunc cb); -GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gint ascend, GCompareFunc cb); +gint filelist_sort_compare_filedata_full(FileData *fa, FileData *fb, SortType method, gboolean ascend); +GList *filelist_sort(GList *list, SortType method, gboolean ascend); +GList *filelist_insert_sort(GList *list, FileData *fd, SortType method, gboolean ascend); +GList *filelist_sort_full(GList *list, SortType method, gboolean ascend, GCompareFunc cb); +GList *filelist_insert_sort_full(GList *list, gpointer data, SortType method, gboolean ascend, GCompareFunc cb); -gint filelist_read(FileData *dir_fd, GList **files, GList **dirs); -gint filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs); +gboolean filelist_read(FileData *dir_fd, GList **files, GList **dirs); +gboolean filelist_read_lstat(FileData *dir_fd, GList **files, GList **dirs); void filelist_free(GList *list); GList *filelist_copy(GList *list); GList *filelist_from_path_list(GList *list); GList *filelist_to_path_list(GList *list); -GList *filelist_filter(GList *list, gint is_dir_list); +GList *filelist_filter(GList *list, gboolean is_dir_list); GList *filelist_sort_path(GList *list); GList *filelist_recursive(FileData *dir_fd); @@ -102,10 +102,10 @@ gboolean file_data_sc_update_ci_unspecified_list(GList *fd_list, const gchar *dest); -gint file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path); -gint file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path); -gint file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path); -gint file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path); +gboolean file_data_sc_update_ci_copy(FileData *fd, const gchar *dest_path); +gboolean file_data_sc_update_ci_move(FileData *fd, const gchar *dest_path); +gboolean file_data_sc_update_ci_rename(FileData *fd, const gchar *dest_path); +gboolean file_data_sc_update_ci_unspecified(FileData *fd, const gchar *dest_path); gchar *file_data_get_error_string(gint error); @@ -113,7 +113,7 @@ gint file_data_verify_ci_list(GList *list, gchar **desc, gboolean with_sidecars); gboolean file_data_perform_ci(FileData *fd); -gint file_data_apply_ci(FileData *fd); +gboolean file_data_apply_ci(FileData *fd); void file_data_free_ci(FileData *fd); void file_data_free_ci_list(GList *fd_list); @@ -121,17 +121,17 @@ gint file_data_sc_verify_ci(FileData *fd); gboolean file_data_sc_perform_ci(FileData *fd); -gint file_data_sc_apply_ci(FileData *fd); +gboolean file_data_sc_apply_ci(FileData *fd); void file_data_sc_free_ci(FileData *fd); void file_data_sc_free_ci_list(GList *fd_list); typedef void (*FileDataNotifyFunc)(FileData *fd, NotifyType type, gpointer data); -gint file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority); -gint file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data); +gboolean file_data_register_notify_func(FileDataNotifyFunc func, gpointer data, NotifyPriority priority); +gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data); void file_data_send_notification(FileData *fd, NotifyType type); -gint file_data_register_real_time_monitor(FileData *fd); -gint file_data_unregister_real_time_monitor(FileData *fd); +gboolean file_data_register_real_time_monitor(FileData *fd); +gboolean file_data_unregister_real_time_monitor(FileData *fd); #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */