Mercurial > geeqie.yaz
changeset 849:db68d673448f
added possibility to disable grouping of selected files
author | nadvornik |
---|---|
date | Sun, 22 Jun 2008 09:19:42 +0000 |
parents | e1d158ac6d36 |
children | ff937cdfaee9 |
files | src/filedata.c src/filedata.h src/typedefs.h src/utilops.c |
diffstat | 4 files changed, 88 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filedata.c Sat Jun 21 22:01:45 2008 +0000 +++ b/src/filedata.c Sun Jun 22 09:19:42 2008 +0000 @@ -337,7 +337,7 @@ file_data_set_path(fd, path_utf8); /* set path, name, collate_key_*, original_path */ - if (check_sidecars && sidecar_file_priority(fd->extension)) + if (check_sidecars) file_data_check_sidecars(fd); return fd; @@ -345,10 +345,17 @@ static void file_data_check_sidecars(FileData *fd) { - int base_len = fd->extension - fd->path; - GString *fname = g_string_new_len(fd->path, base_len); + int base_len; + GString *fname; FileData *parent_fd = NULL; - GList *work = sidecar_ext_get_list(); + GList *work; + + if (fd->disable_grouping || !sidecar_file_priority(fd->extension)) + return; + + base_len = fd->extension - fd->path; + fname = g_string_new_len(fd->path, base_len); + work = sidecar_ext_get_list(); while (work) { @@ -377,6 +384,13 @@ continue; new_fd = file_data_new(fname->str, &nst, FALSE); + + if (new_fd->disable_grouping) + { + file_data_unref(new_fd); + continue; + } + new_fd->ref--; /* do not use ref here */ } @@ -537,6 +551,45 @@ return sfd; } +/* disables / enables grouping for particular file, sends UPDATE notification */ +void file_data_disable_grouping(FileData *fd, gboolean disable) +{ + if (!fd->disable_grouping == !disable) return; + fd->disable_grouping = !!disable; + + if (disable) + { + if (fd->parent) + { + FileData *parent = file_data_ref(fd->parent); + file_data_disconnect_sidecar_file(parent, fd); + file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(parent, NOTIFY_TYPE_INTERNAL); + file_data_unref(parent); + } + else if (fd->sidecar_files) + { + GList *sidecar_files = filelist_copy(fd->sidecar_files); + GList *work = sidecar_files; + while (work) + { + FileData *sfd = work->data; + work = work->next; + file_data_disconnect_sidecar_file(fd, sfd); + file_data_send_notification(sfd, NOTIFY_TYPE_INTERNAL); + } + file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_check_sidecars((FileData *)sidecar_files->data); /* this will group the sidecars back together */ + filelist_free(sidecar_files); + } + } + else + { + file_data_check_sidecars(fd); + file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + } +} + /* compare name without extension */ gint file_data_compare_name_without_ext(FileData *fd1, FileData *fd2) { @@ -1035,16 +1088,7 @@ } -/* disables / enables grouping for particular file, sends UPDATE notification */ -void file_data_disable_grouping(FileData *fd); // now file_data_disconnect_sidecar_file, broken -void file_data_disable_grouping(FileData *fd); - -/* runs stat on a file and sends UPDATE notification if it has been changed */ -void file_data_sc_update(FileData *fd); - - - - + /* * add FileDataChangeInfo (see typedefs.h) for the given operation * uses file_data_add_change_info
--- a/src/filedata.h Sat Jun 21 22:01:45 2008 +0000 +++ b/src/filedata.h Sun Jun 22 09:19:42 2008 +0000 @@ -29,6 +29,8 @@ gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest); void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd); +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);
--- a/src/typedefs.h Sat Jun 21 22:01:45 2008 +0000 +++ b/src/typedefs.h Sun Jun 22 09:19:42 2008 +0000 @@ -446,10 +446,13 @@ FileDataChangeInfo *change; /* for rename, move ... */ GdkPixbuf *thumb_pixbuf; - GdkPixbuf *pixbuf; /* full-size image */ + GdkPixbuf *pixbuf; /* full-size image, only complete images, NULL during loading + all FileData with non-NULL pixbuf are referenced by image_cache */ gint ref; gint version; /* increased when any field in this structure is changed */ + gint disable_grouping; + gint user_orientation; gint exif_orientation;
--- a/src/utilops.c Sat Jun 21 22:01:45 2008 +0000 +++ b/src/utilops.c Sun Jun 22 09:19:42 2008 +0000 @@ -1187,6 +1187,20 @@ file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL); } +static void file_util_disable_grouping_sc_list(GList *list) +{ + GList *work = list; + + while(work) + { + FileData *fd = work->data; + work = work->next; + + if (fd->parent) file_data_disable_grouping(fd, TRUE); + } + +} + static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) { UtilityData *ud; @@ -1195,6 +1209,8 @@ if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); + file_util_disable_grouping_sc_list(flist); + if (!file_data_sc_add_ci_delete_list(flist)) { file_util_warn_op_in_progress(_("File deletion failed")); @@ -1229,6 +1245,8 @@ if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); + file_util_disable_grouping_sc_list(flist); + if (!file_data_sc_add_ci_move_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Move failed")); @@ -1264,6 +1282,8 @@ if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); + file_util_disable_grouping_sc_list(flist); + if (!file_data_sc_add_ci_copy_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Copy failed")); @@ -1300,6 +1320,8 @@ if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); + file_util_disable_grouping_sc_list(flist); + if (!file_data_sc_add_ci_rename_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Rename failed")); @@ -1334,6 +1356,8 @@ if (source_fd) flist = g_list_append(flist, file_data_ref(source_fd)); + file_util_disable_grouping_sc_list(flist); + if (!file_data_sc_add_ci_unspecified_list(flist, dest_path)) { file_util_warn_op_in_progress(_("Can't run external editor"));