Simplify vflist_get_formatted()
[geeqie.git] / src / dupe.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef DUPE_H
23 #define DUPE_H
24
25 #include "similar.h"
26
27 /** @typedef DupeMatchType
28  *  match methods
29  */
30 typedef enum
31 {
32         DUPE_MATCH_NONE = 0,
33         DUPE_MATCH_NAME = 1 << 0,
34         DUPE_MATCH_SIZE = 1 << 1,
35         DUPE_MATCH_DATE = 1 << 2,
36         DUPE_MATCH_DIM  = 1 << 3,       /**< image dimensions */
37         DUPE_MATCH_SUM  = 1 << 4,       /**< MD5sum */
38         DUPE_MATCH_PATH = 1 << 5,
39         DUPE_MATCH_SIM_HIGH = 1 << 6,   /**< similarity */
40         DUPE_MATCH_SIM_MED  = 1 << 7,
41         DUPE_MATCH_SIM_LOW  = 1 << 8,
42         DUPE_MATCH_SIM_CUSTOM = 1 << 9,
43         DUPE_MATCH_NAME_CI = 1 << 10,   /**< same as name, but case insensitive */
44         DUPE_MATCH_NAME_CONTENT = 1 << 11,      /**< same name, but different content */
45         DUPE_MATCH_NAME_CI_CONTENT = 1 << 12,   /**< same name - case insensitive, but different content */
46         DUPE_MATCH_ALL = 1 << 13 /**< N.B. this is used as a clamp value in rcfile.c */
47 } DupeMatchType;
48
49 typedef enum
50 {
51         DUPE_SELECT_NONE,
52         DUPE_SELECT_GROUP1,
53         DUPE_SELECT_GROUP2
54 } DupeSelectType;
55
56 typedef struct _DupeItem DupeItem;
57 struct _DupeItem
58 {
59         CollectionData *collection;     /**< NULL if from #DupeWindow->files */
60         CollectInfo *info;
61
62         FileData *fd;
63
64         gchar *md5sum;
65         gint width;
66         gint height;
67         gint dimensions; /**< Computed as (#DupeItem->width << 16) + #DupeItem->height */
68
69         ImageSimilarityData *simd;
70
71         GdkPixbuf *pixbuf; /**< thumb */
72
73         GList *group;           /**< List of match data (#DupeMatch) */
74         gdouble group_rank;     /**< (sum of all child ranks) / n */
75
76         gint second;
77 };
78
79 typedef struct _DupeMatch DupeMatch;
80 struct _DupeMatch
81 {
82         DupeItem *di;
83         gdouble rank;
84 };
85
86 typedef struct _DupeWindow DupeWindow;
87 struct _DupeWindow
88 {
89         GList *list;    /**< one entry for each dropped file in 1st set window (#DupeItem) */
90         GList *dupes;                   /**< list of dupes (#DupeItem, grouping the #DupeMatch-es) */
91         DupeMatchType match_mask;       /**< mask of things to check for match */
92
93         GtkWidget *window;
94         GtkWidget *table;
95         GtkWidget *listview;
96         GtkWidget *combo;
97         GtkWidget *status_label;
98         GtkWidget *extra_label; /**< Progress bar widget */
99         GtkWidget *button_thumbs;
100         GtkWidget *button_rotation_invariant;
101         GtkWidget *custom_threshold;
102         GList *add_files_queue;
103         guint add_files_queue_id;
104         GHashTable *list_cache; /**< Caches the #DupeItem-s of all items in list. Used when ensuring #FileData-s are unique */
105         GHashTable *second_list_cache; /**< Caches the #DupeItem-s of all items in second_list. Used when ensuring #FileData-s are unique */
106         GtkWidget *controls_box;
107
108         gboolean show_thumbs;
109
110         guint idle_id; /**< event source id */
111         GList *working;
112         gint setup_done; /**< Boolean. Set TRUE when all checksums/dimensions/similarity data have been read or created */
113         gint setup_count; /**< length of set1 or if 2 sets, total length of both */
114         gint setup_n;                   /**< Set to zero on start/reset. These are merely for speed optimization */
115         GList *setup_point;             /**< these are merely for speed optimization */
116         DupeMatchType setup_mask;       /**< these are merely for speed optimization */
117         guint64 setup_time; /**< Time in µsec since Epoch, restored at each phase of operation */
118         guint64 setup_time_count; /**< Time in µsec since time-to-go status display was updated */
119
120         DupeItem *click_item;           /**< for popup menu */
121
122         ThumbLoader *thumb_loader;
123         DupeItem *thumb_item;
124
125         ImageLoader *img_loader;
126
127         GtkTreeSortable *sortable;
128         gint set_count; /**< Index/counter for number of duplicate sets found */
129
130         /* second set comparison stuff */
131
132         gboolean second_set;            /**< second set enabled ? */
133         GList *second_list;             /**< second set dropped files */
134         gboolean second_drop;           /**< drop is on second set */
135
136         GtkWidget *second_vbox;         /**< box of second widgets */
137         GtkWidget *second_listview;
138         GtkWidget *second_status_label;
139
140         gboolean color_frozen;
141
142         /* required for similarity threads */
143         GThreadPool *dupe_comparison_thread_pool;
144         GList *search_matches; /**< List of similarity matches (#DupeSearchMatch) */
145         GMutex search_matches_mutex;
146         GList *search_matches_sorted; /**< \a search_matches sorted by order of entry into thread pool */
147         gint queue_count; /**< Incremented each time an item is pushed onto the similarity thread pool */
148         gint thread_count; /**< Incremented each time a similarity check thread item is completed */
149         GMutex thread_count_mutex;
150         gboolean abort; /**< Stop the similarity check thread queue */
151 };
152
153
154 DupeWindow *dupe_window_new(void);
155
156 void dupe_window_clear(DupeWindow *dw);
157 void dupe_window_close(DupeWindow *dw);
158
159 void dupe_window_add_collection(DupeWindow *dw, CollectionData *collection);
160 void dupe_window_add_files(DupeWindow *dw, GList *list, gboolean recurse);
161
162 void cell_renderer_height_override(GtkCellRenderer *renderer); /**< cell max with/height hack utility */
163
164 #endif
165 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */