Fix #268: Picture diff or picture compare feature
authorColin Clark <colin.clark@cclark.uk>
Tue, 19 May 2020 13:42:27 +0000 (14:42 +0100)
committerColin Clark <colin.clark@cclark.uk>
Tue, 19 May 2020 13:42:27 +0000 (14:42 +0100)
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.

doc/docbook/GuideImageSearchFindingDuplicates.xml
src/dupe.c
src/dupe.h

index 29ba7e2..d724667 100644 (file)
           </para>\r
         </listitem>\r
       </varlistentry>\r
+      <varlistentry>\r
+        <term>\r
+          <guilabel>Name ≠ Content</guilabel>\r
+        </term>\r
+        <listitem>\r
+          <para>\r
+            Show images with the same name but different content.\r
+          </para>\r
+        </listitem>\r
+      </varlistentry>\r
+      <varlistentry>\r
+        <term>\r
+          <guilabel>Name case-insensitive ≠ Content</guilabel>\r
+        </term>\r
+        <listitem>\r
+          <para>\r
+            Show images with the same name, ignoring case, but different content.\r
+          </para>\r
+        </listitem>\r
+      </varlistentry>\r
       <varlistentry>\r
         <term>\r
           <guilabel>Show all</guilabel>\r
index 21de2a5..66d6446 100644 (file)
@@ -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);
index c96d60e..1aab6f7 100644 (file)
@@ -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