From: Colin Clark Date: Tue, 19 May 2020 13:42:27 +0000 (+0100) Subject: Fix #268: Picture diff or picture compare feature X-Git-Tag: v1.6~48 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=f5d36d3ef2a47d90f676e2e95c8b0d1be7e36d9c Fix #268: Picture diff or picture compare feature https://github.com/BestImageViewer/geeqie/issues/268 Two extra options on Duplicates window: Name ≠ Content Name case-insensitive ≠ Content Shows files with the same name but different checksums. --- diff --git a/doc/docbook/GuideImageSearchFindingDuplicates.xml b/doc/docbook/GuideImageSearchFindingDuplicates.xml index 29ba7e27..d724667d 100644 --- a/doc/docbook/GuideImageSearchFindingDuplicates.xml +++ b/doc/docbook/GuideImageSearchFindingDuplicates.xml @@ -136,6 +136,26 @@ + + + Name ≠ Content + + + + Show images with the same name but different content. + + + + + + Name case-insensitive ≠ Content + + + + Show images with the same name, ignoring case, but different content. + + + Show all diff --git a/src/dupe.c b/src/dupe.c index 21de2a52..66d64460 100644 --- a/src/dupe.c +++ b/src/dupe.c @@ -1200,6 +1200,50 @@ static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble { if (strcmp(a->fd->collate_key_name_nocase, b->fd->collate_key_name_nocase) != 0) return FALSE; } + if (mask & DUPE_MATCH_NAME_CONTENT) + { + if (strcmp(a->fd->collate_key_name, b->fd->collate_key_name) == 0) + { + if (!a->md5sum) a->md5sum = md5_text_from_file_utf8(a->fd->path, ""); + if (!b->md5sum) b->md5sum = md5_text_from_file_utf8(b->fd->path, ""); + if (a->md5sum[0] != '\0' || + b->md5sum[0] != '\0' || + strcmp(a->md5sum, b->md5sum) != 0) + { + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + } + if (mask & DUPE_MATCH_NAME_CI_CONTENT) + { + if (strcmp(a->fd->collate_key_name_nocase, b->fd->collate_key_name_nocase) == 0) + { + if (!a->md5sum) a->md5sum = md5_text_from_file_utf8(a->fd->path, ""); + if (!b->md5sum) b->md5sum = md5_text_from_file_utf8(b->fd->path, ""); + if (a->md5sum[0] != '\0' || + b->md5sum[0] != '\0' || + strcmp(a->md5sum, b->md5sum) != 0) + { + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + } if (mask & DUPE_MATCH_SIZE) { if (a->fd->size != b->fd->size) return FALSE; @@ -2840,6 +2884,8 @@ static void dupe_menu_setup(DupeWindow *dw) dupe_menu_add_item(store, _("Similarity"), DUPE_MATCH_SIM_MED, dw); dupe_menu_add_item(store, _("Similarity (low)"), DUPE_MATCH_SIM_LOW, dw); dupe_menu_add_item(store, _("Similarity (custom)"), DUPE_MATCH_SIM_CUSTOM, dw); + dupe_menu_add_item(store, _("Name ≠ content"), DUPE_MATCH_NAME_CONTENT, dw); + dupe_menu_add_item(store, _("Name case-insensitive ≠ content"), DUPE_MATCH_NAME_CI_CONTENT, dw); dupe_menu_add_item(store, _("Show all"), DUPE_MATCH_ALL, dw); g_signal_connect(G_OBJECT(dw->combo), "changed", @@ -3487,6 +3533,8 @@ DupeWindow *dupe_window_new() if (options->duplicates_match == DUPE_MATCH_SIM_LOW) dw->match_mask = DUPE_MATCH_SIM_LOW; if (options->duplicates_match == DUPE_MATCH_SIM_CUSTOM) dw->match_mask = DUPE_MATCH_SIM_CUSTOM; if (options->duplicates_match == DUPE_MATCH_NAME_CI) dw->match_mask = DUPE_MATCH_NAME_CI; + if (options->duplicates_match == DUPE_MATCH_NAME_CONTENT) dw->match_mask = DUPE_MATCH_NAME_CONTENT; + if (options->duplicates_match == DUPE_MATCH_NAME_CI_CONTENT) dw->match_mask = DUPE_MATCH_NAME_CI_CONTENT; dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", NULL, NULL, _("Find duplicates")); DEBUG_NAME(dw->window); diff --git a/src/dupe.h b/src/dupe.h index c96d60e2..1aab6f7c 100644 --- a/src/dupe.h +++ b/src/dupe.h @@ -39,7 +39,9 @@ typedef enum DUPE_MATCH_SIM_LOW = 1 << 8, DUPE_MATCH_SIM_CUSTOM = 1 << 9, DUPE_MATCH_NAME_CI = 1 << 10, /* same as name, but case insensitive */ - DUPE_MATCH_ALL = 1 << 11 + DUPE_MATCH_NAME_CONTENT = 1 << 11, /* same name, but different content */ + DUPE_MATCH_NAME_CI_CONTENT = 1 << 12, /* same name - case insensitive, but different content */ + DUPE_MATCH_ALL = 1 << 13 } DupeMatchType; typedef enum