annotate src/dupe.c @ 1755:decb3b64ae74

fixed pan-view popup menu - removed wrong callback - consider sidecar files in the editor popup
author nadvornik
date Mon, 21 Sep 2009 18:48:32 +0000
parents bfe04f01de5e
children 9a351e8f3b97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2005 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1272
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 264
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "dupe.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "collect-table.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "editors.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 516
diff changeset
22 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "image-load.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include "md5-util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include "menu.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1012
diff changeset
29 #include "misc.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #include "print.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 #include "ui_tree_edit.h"
904
1698baa37871 Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents: 864
diff changeset
36 #include "uri_utils.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1012
diff changeset
37 #include "utilops.h"
648
e34c1002e553 Move some functions from main.[ch] to new window.[ch].
zas_
parents: 586
diff changeset
38 #include "window.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 #include <math.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
1049
85e50c989da5 enlarge the dupe window - patch by Klaus Ethgen
nadvornik
parents: 1043
diff changeset
46 #define DUPE_DEF_WIDTH 800
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define DUPE_DEF_HEIGHT 400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 /* column assignment order (simply change them here) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 DUPE_COLUMN_POINTER = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 DUPE_COLUMN_RANK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 DUPE_COLUMN_THUMB,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 DUPE_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 DUPE_COLUMN_SIZE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 DUPE_COLUMN_DATE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 DUPE_COLUMN_DIMENSIONS,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 DUPE_COLUMN_PATH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 DUPE_COLUMN_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 DUPE_COLUMN_COUNT /* total columns */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 static GList *dupe_window_list = NULL; /* list of open DupeWindow *s */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 * Well, after adding the 'compare two sets' option things got a little sloppy in here
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 * because we have to account for two 'modes' everywhere. (be careful).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 static void dupe_match_unlink(DupeItem *a, DupeItem *b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 static DupeItem *dupe_match_find_parent(DupeWindow *dw, DupeItem *child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 static gint dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble *rank, gint fast);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 static void dupe_thumb_step(DupeWindow *dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 static gint dupe_check_cb(gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 static void dupe_second_add(DupeWindow *dw, DupeItem *di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 static void dupe_second_remove(DupeWindow *dw, DupeItem *di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 static GtkWidget *dupe_menu_popup_second(DupeWindow *dw, DupeItem *di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 static void dupe_dnd_init(DupeWindow *dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
85 static void dupe_notify_cb(FileData *fd, NotifyType type, gpointer data);
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
86
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 * Window updates
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
94 static void dupe_window_update_count(DupeWindow *dw, gboolean count_only)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 if (!dw->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 text = g_strdup(_("Drop files to compare them."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 else if (count_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 text = g_strdup_printf(_("%d files"), g_list_length(dw->list));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 text = g_strdup_printf(_("%d matches found in %d files"), g_list_length(dw->dupes), g_list_length(dw->list));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 gchar *buf = g_strconcat(text, " ", _("[set 1]"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 text = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 gtk_label_set_text(GTK_LABEL(dw->status_label), text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 static guint64 msec_time(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 struct timeval tv;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 if (gettimeofday(&tv, NULL) == -1) return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 return (guint64)tv.tv_sec * 1000000 + (guint64)tv.tv_usec;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 static gint dupe_iterations(gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 return (n * ((n + 1) / 2));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
136 static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdouble value, gboolean force)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 const gchar *status_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 if (status)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 guint64 new_time = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 if (dw->setup_n % 10 == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 new_time = msec_time() - dw->setup_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
148
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 if (!force &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 value != 0.0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 dw->setup_count > 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 new_time > 2000000)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 gint t;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 gint d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 guint32 rem;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 if (new_time - dw->setup_time_count < 250000) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 dw->setup_time_count = new_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 if (dw->setup_done)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 t = dw->setup_count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 d = dw->setup_count - dw->setup_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 t = dupe_iterations(dw->setup_count);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 d = dupe_iterations(dw->setup_count - dw->setup_n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 t = dw->setup_count;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 d = dw->setup_count - dw->setup_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 rem = (t - d) ? ((gdouble)(dw->setup_time_count / 1000000) / (t - d)) * d : 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 buf = g_strdup_printf("%s %d:%02d ", status, rem / 60, rem % 60);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dw->extra_label), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 else if (force ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 value == 0.0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 dw->setup_count == 0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 dw->setup_time_count == 0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 (new_time > 0 && new_time - dw->setup_time_count >= 250000))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 if (dw->setup_time_count == 0) dw->setup_time_count = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 if (new_time > 0) dw->setup_time_count = new_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 status_text = status;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 status_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
206 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 status_text = " ";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 if (status_text) gtk_progress_bar_set_text(GTK_PROGRESS_BAR(dw->extra_label), status_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 static void widget_set_cursor(GtkWidget *widget, gint icon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 GdkCursor *cursor;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 if (!widget->window) return;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
221
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 if (icon == -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 cursor = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 {
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
228 cursor = gdk_cursor_new(icon);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
230
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 gdk_window_set_cursor(widget->window, cursor);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
232
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 if (cursor) gdk_cursor_unref(cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 * row color utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 static void dupe_listview_realign_colors(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 gboolean color_set = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 DupeItem *parent = NULL;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
248 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 store = gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 DupeItem *child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 DupeItem *child_parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &child, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 child_parent = dupe_match_find_parent(dw, child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 if (!parent || parent != child_parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 if (!parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 /* keep the first row as it is */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 gtk_tree_model_get(store, &iter, DUPE_COLUMN_COLOR, &color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 color_set = !color_set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 parent = dupe_match_find_parent(dw, child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DUPE_COLUMN_COLOR, color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 * Dupe item utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
284 static DupeItem *dupe_item_new(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 di = g_new0(DupeItem, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
290 di->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 di->group_rank = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 return di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 static void dupe_item_free(DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
298 file_data_unref(di->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 image_sim_free(di->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 g_free(di->md5sum);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 if (di->pixbuf) g_object_unref(di->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 g_free(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 static void dupe_list_free(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 dupe_item_free(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
259
fa7d69e7d02d Comment out unused code.
zas_
parents: 254
diff changeset
318 /*
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
319 static DupeItem *dupe_item_find_fd_by_list(FileData *fd, GList *work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
320 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
321 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
322 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
323 DupeItem *di = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
324
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
325 if (di->fd == fd) return di;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
326
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
327 work = work->next;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
328 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
329
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
330 return NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
331 }
259
fa7d69e7d02d Comment out unused code.
zas_
parents: 254
diff changeset
332 */
fa7d69e7d02d Comment out unused code.
zas_
parents: 254
diff changeset
333
fa7d69e7d02d Comment out unused code.
zas_
parents: 254
diff changeset
334 /*
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
335 static DupeItem *dupe_item_find_fd(DupeWindow *dw, FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
336 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
337 DupeItem *di;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
338
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
339 di = dupe_item_find_fd_by_list(fd, dw->list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
340 if (!di && dw->second_set) di = dupe_item_find_fd_by_list(fd, dw->second_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
341
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
342 return di;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
343 }
259
fa7d69e7d02d Comment out unused code.
zas_
parents: 254
diff changeset
344 */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
345
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 static DupeItem *dupe_item_find_path_by_list(const gchar *path, GList *work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
352 if (strcmp(di->fd->path, path) == 0) return di;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 static DupeItem *dupe_item_find_path(DupeWindow *dw, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 di = dupe_item_find_path_by_list(path, dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 if (!di && dw->second_set) di = dupe_item_find_path_by_list(path, dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 return di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 * Image property cache
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 static void dupe_item_read_cache(DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 CacheData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
383 path = cache_find_location(CACHE_TYPE_SIM, di->fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 if (!path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
386 if (filetime(di->fd->path) != filetime(path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 cd = cache_sim_data_load(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 if (cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 if (!di->simd && cd->sim)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 di->simd = cd->sim;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 cd->sim = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 if (di->width == 0 && di->height == 0 && cd->dimensions)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 di->width = cd->width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 di->height = cd->height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 if (di->checksum == 0 && cd->have_checksum)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 di->checksum = cd->checksum;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 if (!di->md5sum && cd->have_md5sum)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 di->md5sum = md5_digest_to_text(cd->md5sum);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 cache_sim_data_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 static void dupe_item_write_cache(DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
426 base = cache_get_location(CACHE_TYPE_SIM, di->fd->path, FALSE, &mode);
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1055
diff changeset
427 if (recursive_mkdir_if_not_exists(base, mode))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 CacheData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 cd = cache_sim_data_new();
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
432 cd->path = cache_get_location(CACHE_TYPE_SIM, di->fd->path, TRUE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 if (di->width != 0) cache_sim_data_set_dimensions(cd, di->width, di->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 if (di->checksum != 0) cache_sim_data_set_checksum(cd, di->checksum);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 if (di->md5sum)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 guchar digest[16];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 if (md5_digest_from_text(di->md5sum, digest)) cache_sim_data_set_md5sum(cd, digest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 if (di->simd) cache_sim_data_set_similarity(cd, di->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 if (cache_sim_data_save(cd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
445 filetime_set(cd->path, filetime(di->fd->path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 cache_sim_data_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 * Window list utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 static gint dupe_listview_find_item(GtkListStore *store, DupeItem *item, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 {
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
460 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 DupeItem *item_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DUPE_COLUMN_POINTER, &item_n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 if (item_n == item) return row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 static void dupe_listview_add(DupeWindow *dw, DupeItem *parent, DupeItem *child)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 gint row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 gchar *text[DUPE_COLUMN_COUNT];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 gboolean color_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 gint rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 if (!parent) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 if (child)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 DupeMatch *dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 row = dupe_listview_find_item(store, parent, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, DUPE_COLUMN_COLOR, &color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 if (child->group)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 dm = child->group->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 rank = (gint)floor(dm->rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 rank = 1;
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
508 log_printf("NULL group in item!\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, DUPE_COLUMN_COLOR, &color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 color_set = !color_set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 color_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 rank = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 di = (child) ? child : parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 if (!child && dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 text[DUPE_COLUMN_RANK] = g_strdup("[1]");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 else if (rank == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 text[DUPE_COLUMN_RANK] = g_strdup((di->second) ? "(2)" : "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 text[DUPE_COLUMN_RANK] = g_strdup_printf("%d%s", rank, (di->second) ? " (2)" : "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 text[DUPE_COLUMN_THUMB] = "";
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
542 text[DUPE_COLUMN_NAME] = (gchar *)di->fd->name;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
543 text[DUPE_COLUMN_SIZE] = text_from_size(di->fd->size);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
544 text[DUPE_COLUMN_DATE] = (gchar *)text_from_time(di->fd->date);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 if (di->width > 0 && di->height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 text[DUPE_COLUMN_DIMENSIONS] = g_strdup_printf("%d x %d", di->width, di->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 text[DUPE_COLUMN_DIMENSIONS] = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
553 text[DUPE_COLUMN_PATH] = di->fd->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 text[DUPE_COLUMN_COLOR] = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 gtk_list_store_insert(store, &iter, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 gtk_list_store_set(store, &iter,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 DUPE_COLUMN_POINTER, di,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 DUPE_COLUMN_RANK, text[DUPE_COLUMN_RANK],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 DUPE_COLUMN_THUMB, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 DUPE_COLUMN_NAME, text[DUPE_COLUMN_NAME],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 DUPE_COLUMN_SIZE, text[DUPE_COLUMN_SIZE],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 DUPE_COLUMN_DATE, text[DUPE_COLUMN_DATE],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 DUPE_COLUMN_DIMENSIONS, text[DUPE_COLUMN_DIMENSIONS],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 DUPE_COLUMN_PATH, text[DUPE_COLUMN_PATH],
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 DUPE_COLUMN_COLOR, color_set,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 g_free(text[DUPE_COLUMN_RANK]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 g_free(text[DUPE_COLUMN_SIZE]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 g_free(text[DUPE_COLUMN_DIMENSIONS]);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 static void dupe_listview_populate(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 work = g_list_last(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 DupeItem *parent = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 GList *temp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 dupe_listview_add(dw, parent, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 temp = g_list_last(parent->group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 while (temp)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 DupeMatch *dm = temp->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 DupeItem *child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 child = dm->di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 dupe_listview_add(dw, parent, child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 temp = temp->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 static void dupe_listview_remove(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 gint row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 row = dupe_listview_find_item(store, di, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 if (row < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 tree_view_move_cursor_away(GTK_TREE_VIEW(dw->listview), &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 gtk_list_store_remove(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 if (g_list_find(dw->dupes, di) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 if (!dw->color_frozen) dupe_listview_realign_colors(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
631 static GList *dupe_listview_get_filelist(DupeWindow *dw, GtkWidget *listview)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 GtkTreeIter iter;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
635 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 store = gtk_tree_view_get_model(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
644 list = g_list_prepend(list, file_data_ref(di->fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 return g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 static GList *dupe_listview_get_selection(DupeWindow *dw, GtkWidget *listview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 if (di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
674 list = g_list_prepend(list, file_data_ref(di->fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 return g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
684 static gboolean dupe_listview_item_is_selected(DupeWindow *dw, DupeItem *di, GtkWidget *listview)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 GList *work;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
690 gboolean found = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 while (!found && work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 DupeItem *di_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di_n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 if (di_n == di) found = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 return found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 static void dupe_listview_select_dupes(DupeWindow *dw, gint parents)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 GtkTreeIter iter;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
717 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 store = gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 if ( (dupe_match_find_parent(dw, di) == di) == (parents) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 * Match group manipulation
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 static DupeMatch *dupe_match_find_match(DupeItem *child, DupeItem *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 work = parent->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 if (dm->di == child) return dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 static void dupe_match_link_child(DupeItem *child, DupeItem *parent, gdouble rank)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 DupeMatch *dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 dm = g_new0(DupeMatch, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 dm->di = child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 dm->rank = rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 parent->group = g_list_append(parent->group, dm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 static void dupe_match_link(DupeItem *a, DupeItem *b, gdouble rank)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 dupe_match_link_child(a, b, rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 dupe_match_link_child(b, a, rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 static void dupe_match_unlink_child(DupeItem *child, DupeItem *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 DupeMatch *dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 dm = dupe_match_find_match(child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 if (dm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 parent->group = g_list_remove(parent->group, dm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 g_free(dm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 static void dupe_match_unlink(DupeItem *a, DupeItem *b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 dupe_match_unlink_child(a, b);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 dupe_match_unlink_child(b, a);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
791 static void dupe_match_link_clear(DupeItem *parent, gboolean unlink_children)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
794
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 work = parent->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 if (unlink_children) dupe_match_unlink_child(parent, dm->di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 g_free(dm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 g_list_free(parent->group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 parent->group = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 parent->group_rank = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 static gint dupe_match_link_exists(DupeItem *child, DupeItem *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 return (dupe_match_find_match(child, parent) != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 static gdouble dupe_match_link_rank(DupeItem *child, DupeItem *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 DupeMatch *dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 dm = dupe_match_find_match(child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 if (dm) return dm->rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 return 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 static DupeItem *dupe_match_highest_rank(DupeItem *child)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 DupeMatch *dr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 dr = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 work = child->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 if (!dr || dm->rank > dr->rank) dr = dm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 return (dr) ? dr->di : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 static void dupe_match_rank_update(DupeItem *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 gdouble rank = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 work = parent->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 rank += dm->rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 if (c > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 parent->group_rank = rank / c;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 parent->group_rank = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 static DupeItem *dupe_match_find_parent(DupeWindow *dw, DupeItem *child)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 if (g_list_find(dw->dupes, child)) return child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 work = child->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 if (g_list_find(dw->dupes, dm->di)) return dm->di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 static void dupe_match_reset_list(GList *work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 dupe_match_link_clear(di, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 static void dupe_match_reparent(DupeWindow *dw, DupeItem *old, DupeItem *new)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 if (!old || !new || !dupe_match_link_exists(old, new)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 dupe_match_link_clear(new, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 work = old->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 dupe_match_unlink_child(old, dm->di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 dupe_match_link_child(new, dm->di, dm->rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 new->group = old->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 old->group = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 work = g_list_find(dw->dupes, old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 if (work) work->data = new;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 static void dupe_match_print_group(DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
923 log_printf("+ %f %s\n", di->group_rank, di->fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 work = di->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
931 log_printf(" %f %s\n", dm->rank, dm->di->fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
934 log_printf("\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 static void dupe_match_print_list(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 dupe_match_print_group(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 /* level 3, unlinking and orphan handling */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 static GList *dupe_match_unlink_by_rank(DupeItem *child, DupeItem *parent, GList *list, DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 DupeItem *best;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 best = dupe_match_highest_rank(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 if (best == child || dupe_match_highest_rank(child) == parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 gdouble rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
961 DEBUG_2("link found %s to %s [%d]", child->fd->name, parent->fd->name, g_list_length(parent->group));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 work = parent->group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 DupeItem *orphan;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 orphan = dm->di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 if (orphan != child && g_list_length(orphan->group) < 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 dupe_match_link_clear(orphan, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 if (!dw->second_set || orphan->second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 dupe_match(orphan, child, dw->match_mask, &rank, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 dupe_match_link(orphan, child, rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 list = g_list_remove(list, orphan);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
982
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 rank = dupe_match_link_rank(child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 dupe_match_link_clear(parent, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 dupe_match_link(child, parent, rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 list = g_list_remove(list, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
990 DEBUG_2("unlinking %s and %s", child->fd->name, parent->fd->name);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
991
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 dupe_match_unlink(child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 /* level 2 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 static GList *dupe_match_group_filter(GList *list, DupeItem *di, DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 work = g_list_last(di->group);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 DupeMatch *dm = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 list = dupe_match_unlink_by_rank(di, dm->di, list, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 /* level 1 (top) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 static GList *dupe_match_group_trim(GList *list, DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 if (!di->second) list = dupe_match_group_filter(list, di, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 if (di->second) list = g_list_remove(list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 static gint dupe_match_sort_groups_cb(gconstpointer a, gconstpointer b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 DupeMatch *da = (DupeMatch *)a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 DupeMatch *db = (DupeMatch *)b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 if (da->rank > db->rank) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 if (da->rank < db->rank) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 static void dupe_match_sort_groups(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 di->group = g_list_sort(di->group, dupe_match_sort_groups_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 static gint dupe_match_rank_sort_cb(gconstpointer a, gconstpointer b)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 DupeItem *da = (DupeItem *)a;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 DupeItem *db = (DupeItem *)b;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 if (da->group_rank > db->group_rank) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 if (da->group_rank < db->group_rank) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 /* returns allocated GList of dupes sorted by rank */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 static GList *dupe_match_rank_sort(GList *source_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 work = source_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 if (di->group)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 dupe_match_rank_update(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 list = g_list_prepend(list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1080
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 return g_list_sort(list, dupe_match_rank_sort_cb);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 static void dupe_match_rank(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 list = dupe_match_rank_sort(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents: 506
diff changeset
1093 if (required_debug_level(2)) dupe_match_print_list(list);
495
c7a2471e5c4e Introduce macros to display debug messages.
zas_
parents: 479
diff changeset
1094
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1095 DEBUG_1("Similar items: %d", g_list_length(list));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 list = dupe_match_group_trim(list, dw);
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1097 DEBUG_1("Unique groups: %d", g_list_length(list));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 dupe_match_sort_groups(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents: 506
diff changeset
1101 if (required_debug_level(2)) dupe_match_print_list(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 list = dupe_match_rank_sort(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 g_list_free(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 dw->dupes = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 * Match group tests
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
1115 static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble *rank, gint fast)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 *rank = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 if (a == b) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 if (mask & DUPE_MATCH_PATH)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 {
786
a20ff446347e Compare paths using utf8_collate_key() since paths are utf8-encoded.
zas_
parents: 785
diff changeset
1123 if (utf8_compare(a->fd->path, b->fd->path, TRUE) != 0) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 if (mask & DUPE_MATCH_NAME)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 {
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 783
diff changeset
1127 if (strcmp(a->fd->collate_key_name, b->fd->collate_key_name) != 0) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 }
264
1015282898fe Add the possibility to match duplicates on the name but ignoring the case.
zas_
parents: 259
diff changeset
1129 if (mask & DUPE_MATCH_NAME_CI)
1015282898fe Add the possibility to match duplicates on the name but ignoring the case.
zas_
parents: 259
diff changeset
1130 {
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 783
diff changeset
1131 if (strcmp(a->fd->collate_key_name_nocase, b->fd->collate_key_name_nocase) != 0) return FALSE;
264
1015282898fe Add the possibility to match duplicates on the name but ignoring the case.
zas_
parents: 259
diff changeset
1132 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 if (mask & DUPE_MATCH_SIZE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1135 if (a->fd->size != b->fd->size) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 if (mask & DUPE_MATCH_DATE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1139 if (a->fd->date != b->fd->date) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 if (mask & DUPE_MATCH_SUM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1143 if (!a->md5sum) a->md5sum = md5_text_from_file_utf8(a->fd->path, "");
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1144 if (!b->md5sum) b->md5sum = md5_text_from_file_utf8(b->fd->path, "");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 if (a->md5sum[0] == '\0' ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 b->md5sum[0] == '\0' ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 strcmp(a->md5sum, b->md5sum) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 if (mask & DUPE_MATCH_DIM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1151 if (a->width == 0) image_load_dimensions(a->fd, &a->width, &a->height);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1152 if (b->width == 0) image_load_dimensions(b->fd, &b->width, &b->height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 if (a->width != b->width || a->height != b->height) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 if (mask & DUPE_MATCH_SIM_HIGH ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 mask & DUPE_MATCH_SIM_MED ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 mask & DUPE_MATCH_SIM_LOW ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 mask & DUPE_MATCH_SIM_CUSTOM)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gdouble f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 gdouble m;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 if (mask & DUPE_MATCH_SIM_HIGH) m = 0.95;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 else if (mask & DUPE_MATCH_SIM_MED) m = 0.90;
342
07490120df2d Rename dupe_custom_threshold option to duplicates_similarity_threshold.
zas_
parents: 333
diff changeset
1165 else if (mask & DUPE_MATCH_SIM_CUSTOM) m = (gdouble)options->duplicates_similarity_threshold / 100.0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 else m = 0.85;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 if (fast)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 f = image_sim_compare_fast(a->simd, b->simd, m);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 f = image_sim_compare(a->simd, b->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 *rank = f * 100.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 if (f < m) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1181 DEBUG_3("similar: %32s %32s = %f", a->fd->name, b->fd->name, f);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 static void dupe_list_check_match(DupeWindow *dw, DupeItem *needle, GList *start)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 work = dw->second_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 else if (start)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 work = start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 work = g_list_last(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 DupeItem *di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 /* speed opt: forward for second set, back for simple compare */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 work = work->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 if (!dupe_match_link_exists(needle, di))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 gdouble rank;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 if (dupe_match(di, needle, dw->match_mask, &rank, TRUE))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 dupe_match_link(di, needle, rank);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 * Thumbnail handling
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 static void dupe_listview_set_thumb(DupeWindow *dw, DupeItem *di, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 GtkTreeIter iter_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 if (!iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 if (dupe_listview_find_item(store, di, &iter_n) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 iter = &iter_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 if (iter) gtk_list_store_set(store, iter, DUPE_COLUMN_THUMB, di->pixbuf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 static void dupe_thumb_do(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 if (!dw->thumb_loader || !dw->thumb_item) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 di = dw->thumb_item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 if (di->pixbuf) g_object_unref(di->pixbuf);
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 838
diff changeset
1257 di->pixbuf = thumb_loader_get_pixbuf(dw->thumb_loader);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 dupe_listview_set_thumb(dw, di, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 static void dupe_thumb_error_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 dupe_thumb_do(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 static void dupe_thumb_done_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 dupe_thumb_do(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 static void dupe_thumb_step(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 DupeItem *di = NULL;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
1283 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 store = gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 while (!di && valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 length++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, DUPE_COLUMN_THUMB, &pixbuf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 if (pixbuf || di->pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 if (!pixbuf) gtk_list_store_set(GTK_LIST_STORE(store), &iter, DUPE_COLUMN_THUMB, di->pixbuf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 if (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 while (gtk_tree_model_iter_next(store, &iter)) length++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309 if (!di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 dw->thumb_item = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 thumb_loader_free(dw->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 dw->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 dupe_window_update_progress(dw, _("Loading thumbs..."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 length == 0 ? 0.0 : (gdouble)(row) / length, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 dw->thumb_item = di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 thumb_loader_free(dw->thumb_loader);
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1324 dw->thumb_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 thumb_loader_set_callbacks(dw->thumb_loader,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 dupe_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 dupe_thumb_error_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 /* start it */
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 803
diff changeset
1333 if (!thumb_loader_start(dw->thumb_loader, di->fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 /* error, handle it, do next */
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1336 DEBUG_1("error loading thumb for %s", di->fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 dupe_thumb_do(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 * Dupe checking loop
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 static void dupe_check_stop(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 {
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1350 if (dw->idle_id || dw->img_loader || dw->thumb_loader)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 g_source_remove(dw->idle_id);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1353 dw->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 widget_set_cursor(dw->listview, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 thumb_loader_free(dw->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 dw->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 image_loader_free(dw->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 dw->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 static void dupe_loader_done_cb(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370 pixbuf = image_loader_get_pixbuf(il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 if (dw->setup_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 DupeItem *di = dw->setup_point->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 if (!di->simd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 di->simd = image_sim_new_from_pixbuf(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 image_sim_fill_data(di->simd, pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 if (di->width == 0 && di->height == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 di->width = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 di->height = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 }
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1390 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 dupe_item_write_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 image_sim_alternate_processing(di->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 image_loader_free(dw->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 dw->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 dw->idle_id = g_idle_add(dupe_check_cb, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 static void dupe_setup_reset(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 dw->setup_point = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 dw->setup_n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 dw->setup_time = msec_time();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 dw->setup_time_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 static GList *dupe_setup_point_step(DupeWindow *dw, GList *p)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 if (!p) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 if (p->next) return p->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 if (dw->second_set && g_list_first(p) == dw->list) return dw->second_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
1423 static gboolean dupe_check_cb(gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1427 if (!dw->idle_id) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 if (!dw->setup_done)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 if ((dw->match_mask & DUPE_MATCH_SUM) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 !(dw->setup_mask & DUPE_MATCH_SUM) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 if (!dw->setup_point) dw->setup_point = dw->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 while (dw->setup_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 DupeItem *di = dw->setup_point->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 dw->setup_point = dupe_setup_point_step(dw, dw->setup_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 dw->setup_n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 if (!di->md5sum)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 dupe_window_update_progress(dw, _("Reading checksums..."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 dw->setup_count == 0 ? 0.0 : (gdouble)(dw->setup_n - 1) / dw->setup_count, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1448 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 dupe_item_read_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451 if (di->md5sum) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1454 di->md5sum = md5_text_from_file_utf8(di->fd->path, "");
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1455 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 dupe_item_write_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 dw->setup_mask |= DUPE_MATCH_SUM;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 dupe_setup_reset(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 if ((dw->match_mask & DUPE_MATCH_DIM) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 !(dw->setup_mask & DUPE_MATCH_DIM) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 if (!dw->setup_point) dw->setup_point = dw->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 while (dw->setup_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 DupeItem *di = dw->setup_point->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 dw->setup_point = dupe_setup_point_step(dw, dw->setup_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 dw->setup_n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 if (di->width == 0 && di->height == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 dupe_window_update_progress(dw, _("Reading dimensions..."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 dw->setup_count == 0 ? 0.0 : (gdouble)(dw->setup_n - 1) / dw->setup_count, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1481 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 dupe_item_read_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 if (di->width != 0 || di->height != 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1487 image_load_dimensions(di->fd, &di->width, &di->height);
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1488 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 dupe_item_write_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495 dw->setup_mask |= DUPE_MATCH_DIM;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 dupe_setup_reset(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 if ((dw->match_mask & DUPE_MATCH_SIM_HIGH ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 dw->match_mask & DUPE_MATCH_SIM_MED ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 dw->match_mask & DUPE_MATCH_SIM_LOW ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 dw->match_mask & DUPE_MATCH_SIM_CUSTOM) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 !(dw->setup_mask & DUPE_MATCH_SIM_MED) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 if (!dw->setup_point) dw->setup_point = dw->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 while (dw->setup_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 DupeItem *di = dw->setup_point->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510 if (!di->simd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 dupe_window_update_progress(dw, _("Reading similarity data..."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1513 dw->setup_count == 0 ? 0.0 : (gdouble)dw->setup_n / dw->setup_count, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1514
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
1515 if (options->thumbnails.enable_caching)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 dupe_item_read_cache(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518 if (cache_sim_data_filled(di->simd))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520 image_sim_alternate_processing(di->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1524
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1525 dw->img_loader = image_loader_new(di->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1526 image_loader_set_buffer_size(dw->img_loader, 8);
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1292
diff changeset
1527 g_signal_connect(G_OBJECT(dw->img_loader), "error", (GCallback)dupe_loader_done_cb, dw);
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1292
diff changeset
1528 g_signal_connect(G_OBJECT(dw->img_loader), "done", (GCallback)dupe_loader_done_cb, dw);
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 904
diff changeset
1529
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 904
diff changeset
1530 if (!image_loader_start(dw->img_loader))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 image_sim_free(di->simd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 di->simd = image_sim_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534 image_loader_free(dw->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 dw->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 }
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1538 dw->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542 dw->setup_point = dupe_setup_point_step(dw, dw->setup_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543 dw->setup_n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1544 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1545 dw->setup_mask |= DUPE_MATCH_SIM_MED;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546 dupe_setup_reset(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 dupe_window_update_progress(dw, _("Comparing..."), 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 dw->setup_done = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550 dupe_setup_reset(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 dw->setup_count = g_list_length(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554 if (!dw->working)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 if (dw->setup_count > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 dw->setup_count = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559 dupe_window_update_progress(dw, _("Sorting..."), 1.0, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1561 }
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1562 dw->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 dupe_match_rank(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 dupe_window_update_count(dw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568 dupe_listview_populate(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 /* check thumbs */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 if (dw->show_thumbs) dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573 widget_set_cursor(dw->listview, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1575 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 dupe_list_check_match(dw, (DupeItem *)dw->working->data, dw->working);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579 dupe_window_update_progress(dw, _("Comparing..."), dw->setup_count == 0 ? 0.0 : (gdouble) dw->setup_n / dw->setup_count, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580 dw->setup_n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 dw->working = dw->working->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 static void dupe_check_start(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 dw->setup_done = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591 dw->setup_count = g_list_length(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 if (dw->second_set) dw->setup_count += g_list_length(dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1594 dw->setup_mask = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595 dupe_setup_reset(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597 dw->working = g_list_last(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 dupe_window_update_count(dw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 widget_set_cursor(dw->listview, GDK_WATCH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1513
diff changeset
1602 if (dw->idle_id) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604 dw->idle_id = g_idle_add(dupe_check_cb, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1605 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1606
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1607 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 * Item addition, removal
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 static void dupe_item_remove(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1615 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 /* handle things that may be in progress... */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618 if (dw->working && dw->working->data == di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1620 dw->working = dw->working->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1621 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 if (dw->thumb_loader && dw->thumb_item == di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1624 dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1625 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1626 if (dw->setup_point && dw->setup_point->data == di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1627 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1628 dw->setup_point = dupe_setup_point_step(dw, dw->setup_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1629 if (dw->img_loader)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1630 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1631 image_loader_free(dw->img_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1632 dw->img_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 dw->idle_id = g_idle_add(dupe_check_cb, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1635 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637 if (di->group && dw->dupes)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1638 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1639 /* is a dupe, must remove from group/reset children if a parent */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 DupeItem *parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1642 parent = dupe_match_find_parent(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1643 if (di == parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645 if (g_list_length(parent->group) < 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1646 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647 DupeItem *child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649 child = dupe_match_highest_rank(parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650 dupe_match_link_clear(child, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651 dupe_listview_remove(dw, child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1653 dupe_match_link_clear(parent, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 dupe_listview_remove(dw, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 dw->dupes = g_list_remove(dw->dupes, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 DupeItem *new_parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660 DupeMatch *dm;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1661
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 dm = parent->group->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663 new_parent = dm->di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664 dupe_match_reparent(dw, parent, new_parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665 dupe_listview_remove(dw, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 if (g_list_length(parent->group) < 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1671 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1672 dupe_match_link_clear(parent, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673 dupe_listview_remove(dw, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674 dw->dupes = g_list_remove(dw->dupes, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1676 dupe_match_link_clear(di, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677 dupe_listview_remove(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682 /* not a dupe, or not sorted yet, simply reset */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 dupe_match_link_clear(di, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686 if (dw->second_list && g_list_find(dw->second_list, di))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 dupe_second_remove(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1692 dw->list = g_list_remove(dw->list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1693 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 dupe_item_free(di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696 dupe_window_update_count(dw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
1699 static gboolean dupe_item_remove_by_path(DupeWindow *dw, const gchar *path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1702
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1703 di = dupe_item_find_path(dw, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1704 if (!di) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 dupe_item_remove(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711 static void dupe_files_add(DupeWindow *dw, CollectionData *collection, CollectInfo *info,
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
1712 FileData *fd, gboolean recurse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 if (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1718 di = dupe_item_new(info->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1720 else if (fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1722 if (isfile(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1724 di = dupe_item_new(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1726 else if (isdir(fd->path) && recurse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1728 GList *f, *d;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1729 if (filelist_read(fd, &f, &d))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1731 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1732
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1733 f = filelist_filter(f, FALSE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1734 d = filelist_filter(d, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1736 work = f;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
1737 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1739 dupe_files_add(dw, NULL, NULL, (FileData *)work->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1740 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1741 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1742 filelist_free(f);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1743 work = d;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
1744 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1745 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1746 dupe_files_add(dw, NULL, NULL, (FileData *)work->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1749 filelist_free(d);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1756 if (dw->second_drop)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1757 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1758 dupe_second_add(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1759 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1760 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1761 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1762 dw->list = g_list_prepend(dw->list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1763 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1764 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1765
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1766 void dupe_window_add_collection(DupeWindow *dw, CollectionData *collection)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1767 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1768 CollectInfo *info;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1769
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1770 info = collection_get_first(collection);
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
1771 while (info)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1772 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1773 dupe_files_add(dw, collection, info, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1774 info = collection_next_by_info(collection, info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1775 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1776
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1777 dupe_check_start(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1778 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1779
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
1780 void dupe_window_add_files(DupeWindow *dw, GList *list, gboolean recurse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1781 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1782 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1783
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1784 work = list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
1785 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1786 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1787 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1788 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1789
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1790 dupe_files_add(dw, NULL, NULL, fd, recurse);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1791 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1792
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1793 dupe_check_start(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1794 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1795
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1796 static void dupe_item_update(DupeWindow *dw, DupeItem *di)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1797 {
264
1015282898fe Add the possibility to match duplicates on the name but ignoring the case.
zas_
parents: 259
diff changeset
1798 if ( (dw->match_mask & DUPE_MATCH_NAME) || (dw->match_mask & DUPE_MATCH_PATH || (dw->match_mask & DUPE_MATCH_NAME_CI)) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1799 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1800 /* only effects matches on name or path */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1801 /*
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1802 FileData *fd = file_data_ref(di->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1803 gint second;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1804
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1805 second = di->second;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1806 dupe_item_remove(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1808 dw->second_drop = second;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1809 dupe_files_add(dw, NULL, NULL, fd, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1810 dw->second_drop = FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1811
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1812 file_data_unref(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1813 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1814 dupe_check_start(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1815 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1816 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1817 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1818 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1819 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1820 gint row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1821 /* update the listview(s) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1822
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1823 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1824 row = dupe_listview_find_item(store, di, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1825 if (row >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1826 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1827 gtk_list_store_set(store, &iter,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1828 DUPE_COLUMN_NAME, di->fd->name,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1829 DUPE_COLUMN_PATH, di->fd->path, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1830 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1831
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1832 if (dw->second_listview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1833 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1834 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->second_listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1835 row = dupe_listview_find_item(store, di, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1836 if (row >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1837 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1838 gtk_list_store_set(store, &iter, 1, di->fd->path, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1839 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1840 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1841 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1842
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1843 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1844
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1845 static void dupe_item_update_fd_in_list(DupeWindow *dw, FileData *fd, GList *work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1846 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1847 while (work)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1848 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1849 DupeItem *di = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1850
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1851 if (di->fd == fd)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1852 dupe_item_update(dw, di);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1853
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1854 work = work->next;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1855 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1856 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1857
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1858 static void dupe_item_update_fd(DupeWindow *dw, FileData *fd)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1859 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1860 dupe_item_update_fd_in_list(dw, fd, dw->list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1861 if (dw->second_set) dupe_item_update_fd_in_list(dw, fd, dw->second_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1862 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1863
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1864
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1865 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1866 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1867 * Misc.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1868 * ------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1869 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1870
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1871 static GtkWidget *dupe_display_label(GtkWidget *vbox, const gchar *description, const gchar *text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1872 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1873 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1874 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1875
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1876 hbox = gtk_hbox_new(FALSE, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1878 label = gtk_label_new(description);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1879 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1880 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1881
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1882 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1883 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1884 gtk_widget_show(label);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1885
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1886 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1887 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1888
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1889 return label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1890 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1892 static void dupe_display_stats(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1893 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1894 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1895 gchar *buf;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1896
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1897 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1898
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
1899 gd = file_util_gen_dlg("Image thumbprint debug info", "thumbprint",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1900 dw->window, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1901 NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1902 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1903
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1904 dupe_display_label(gd->vbox, "name:", di->fd->name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1905 buf = text_from_size(di->fd->size);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1906 dupe_display_label(gd->vbox, "size:", buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1907 g_free(buf);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1908 dupe_display_label(gd->vbox, "date:", text_from_time(di->fd->date));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1909 buf = g_strdup_printf("%d x %d", di->width, di->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1910 dupe_display_label(gd->vbox, "dimensions:", buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1911 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1912 dupe_display_label(gd->vbox, "md5sum:", (di->md5sum) ? di->md5sum : "not generated");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1913
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1914 dupe_display_label(gd->vbox, "thumbprint:", (di->simd) ? "" : "not generated");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1915 if (di->simd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1916 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1917 GtkWidget *image;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1918 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1919 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1920 guchar *d_pix;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1921 guchar *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1922 gint rs;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1923 gint sp;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1924
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1925 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 32, 32);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1926 rs = gdk_pixbuf_get_rowstride(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1927 d_pix = gdk_pixbuf_get_pixels(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1928
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1929 for (y = 0; y < 32; y++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1930 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1931 dp = d_pix + (y * rs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1932 sp = y * 32;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1933 for (x = 0; x < 32; x++)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1934 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1935 *(dp++) = di->simd->avg_r[sp + x];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1936 *(dp++) = di->simd->avg_g[sp + x];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1937 *(dp++) = di->simd->avg_b[sp + x];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1938 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1939 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1941 image = gtk_image_new_from_pixbuf(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1942 gtk_box_pack_start(GTK_BOX(gd->vbox), image, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1943 gtk_widget_show(image);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1944
1043
5fc64d6252e7 Replaced gtk depreceated code.
bruclik
parents: 1029
diff changeset
1945 g_object_unref(pixbuf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1946 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
1947
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1948 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1949 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1950
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1951 static void dupe_window_recompare(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1952 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1953 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1954
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1955 dupe_check_stop(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1956
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1957 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1958 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1959
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1960 g_list_free(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1961 dw->dupes = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1962
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1963 dupe_match_reset_list(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1964 dupe_match_reset_list(dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1965
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1966 dupe_check_start(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1967 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1969 static void dupe_menu_view(DupeWindow *dw, DupeItem *di, GtkWidget *listview, gint new_window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1970 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1971 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1972
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1973 if (di->collection && collection_info_valid(di->collection, di->info))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1974 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1975 if (new_window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1976 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1977 view_window_new_from_collection(di->collection, di->info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1978 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1979 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1980 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1981 layout_image_set_collection(NULL, di->collection, di->info);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1982 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1983 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1984 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1985 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1986 if (new_window)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1987 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1988 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1989
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1990 list = dupe_listview_get_selection(dw, listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1991 view_window_new_from_list(list);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
1992 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1993 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1994 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1995 {
1445
cb0040be832e fixed viewing image from dupe and search windows
nadvornik
parents: 1444
diff changeset
1996 layout_set_fd(NULL, di->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1997 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1998 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1999 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2001 static void dupe_window_remove_selection(DupeWindow *dw, GtkWidget *listview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2002 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2003 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2004 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2005 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2006 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2007 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2008 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2009
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2010 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2011 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2012 work = slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2013 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2014 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2015 GtkTreePath *tpath = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2016 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2017
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2018 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2019 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2020 if (di) list = g_list_prepend(list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2021 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2022 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2023 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2024 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2026 dw->color_frozen = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2027 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2028 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2029 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2030 DupeItem *di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2031
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2032 di = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2033 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2034 dupe_item_remove(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2035 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2036 dw->color_frozen = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2037
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2038 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2039
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2040 dupe_listview_realign_colors(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2041 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2042
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
2043 static void dupe_window_edit_selected(DupeWindow *dw, const gchar *key)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2044 {
1656
349ebc02b8e2 fixed leak in file_util_* functions
nadvornik
parents: 1652
diff changeset
2045 file_util_start_editor_from_filelist(key, dupe_listview_get_selection(dw, dw->listview), NULL, dw->window);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2046 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2048 static void dupe_window_collection_from_selection(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2049 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2050 CollectWindow *w;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2051 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2052
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2053 list = dupe_listview_get_selection(dw, dw->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2054 w = collection_window_new(NULL);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2055 collection_table_add_filelist(w->table, list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2056 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2057 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2059 static void dupe_window_append_file_list(DupeWindow *dw, gint on_second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2060 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2061 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2063 dw->second_drop = (dw->second_set && on_second);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2065 list = layout_list(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2066 dupe_window_add_files(dw, list, FALSE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2067 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2068 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2070 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2071 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2072 * main pop-up menu callbacks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2073 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2074 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2076 static void dupe_menu_view_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2077 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2078 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2079
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2080 if (dw->click_item) dupe_menu_view(dw, dw->click_item, dw->listview, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2081 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2082
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2083 static void dupe_menu_viewnew_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2084 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2085 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2086
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2087 if (dw->click_item) dupe_menu_view(dw, dw->click_item, dw->listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2088 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2090 static void dupe_menu_select_all_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2092 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2093 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2094
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2095 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2096 gtk_tree_selection_select_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2097 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2098
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2099 static void dupe_menu_select_none_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2100 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2101 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2102 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2104 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2105 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2106 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2108 static void dupe_menu_select_dupes_set1_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2109 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2110 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2112 dupe_listview_select_dupes(dw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2113 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2115 static void dupe_menu_select_dupes_set2_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2117 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2119 dupe_listview_select_dupes(dw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2120 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2122 static void dupe_menu_edit_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2123 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2124 DupeWindow *dw;
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
2125 const gchar *key = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2126
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2127 dw = submenu_item_get_data(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2128 if (!dw) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2129
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
2130 dupe_window_edit_selected(dw, key);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2133 static void dupe_menu_collection_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2134 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2135 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2136
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2137 dupe_window_collection_from_selection(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2140 static void dupe_menu_print_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2141 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2142 DupeWindow *dw = data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2143 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2144
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2145 fd = (dw->click_item) ? dw->click_item->fd : NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2146
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2147 print_window_new(fd,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2148 dupe_listview_get_selection(dw, dw->listview),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2149 dupe_listview_get_filelist(dw, dw->listview), dw->window);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2150 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2152 static void dupe_menu_copy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2153 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2154 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2156 file_util_copy(NULL, dupe_listview_get_selection(dw, dw->listview), NULL, dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2157 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2159 static void dupe_menu_move_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2161 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2163 file_util_move(NULL, dupe_listview_get_selection(dw, dw->listview), NULL, dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2164 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2166 static void dupe_menu_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2167 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2168 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2170 file_util_rename(NULL, dupe_listview_get_selection(dw, dw->listview), dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2171 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2173 static void dupe_menu_delete_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2174 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2175 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2176
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2177 file_util_delete(NULL, dupe_listview_get_selection(dw, dw->listview), dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2179
497
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2180 static void dupe_menu_copy_path_cb(GtkWidget *widget, gpointer data)
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2181 {
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2182 DupeWindow *dw = data;
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2183
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2184 file_util_copy_path_list_to_clipboard(dupe_listview_get_selection(dw, dw->listview));
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2185 }
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
2186
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2187 static void dupe_menu_remove_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2188 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2189 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2191 dupe_window_remove_selection(dw, dw->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2192 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2194 static void dupe_menu_clear_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2195 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2196 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2198 dupe_window_clear(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2201 static void dupe_menu_close_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2203 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2205 dupe_window_close(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2207
1397
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2208 static void dupe_menu_popup_destroy_cb(GtkWidget *widget, gpointer data)
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2209 {
1698
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2210 GList *editmenu_fd_list = data;
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2211
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2212 filelist_free(editmenu_fd_list);
1397
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2213 }
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2214
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2215 static GList *dupe_window_get_fd_list(DupeWindow *dw)
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2216 {
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2217 GList *list;
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2218
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2219 if (GTK_WIDGET_HAS_FOCUS(dw->second_listview))
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2220 {
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2221 list = dupe_listview_get_selection(dw, dw->second_listview);
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2222 }
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2223 else
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2224 {
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2225 list = dupe_listview_get_selection(dw, dw->listview);
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2226 }
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2227
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2228 return list;
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2229 }
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2230
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2231 static GtkWidget *dupe_menu_popup_main(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2233 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2234 GtkWidget *item;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2235 gint on_row;
1698
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2236 GList *editmenu_fd_list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2238 on_row = (di != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2240 menu = popup_menu_short_lived();
1397
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2241
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2242 menu_item_add_sensitive(menu, _("_View"), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2243 G_CALLBACK(dupe_menu_view_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2244 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2245 G_CALLBACK(dupe_menu_viewnew_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2246 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2247 menu_item_add_sensitive(menu, _("Select all"), (dw->dupes != NULL),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2248 G_CALLBACK(dupe_menu_select_all_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2249 menu_item_add_sensitive(menu, _("Select none"), (dw->dupes != NULL),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2250 G_CALLBACK(dupe_menu_select_none_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2251 menu_item_add_sensitive(menu, _("Select group _1 duplicates"), (dw->dupes != NULL),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2252 G_CALLBACK(dupe_menu_select_dupes_set1_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2253 menu_item_add_sensitive(menu, _("Select group _2 duplicates"), (dw->dupes != NULL),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2254 G_CALLBACK(dupe_menu_select_dupes_set2_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2255 menu_item_add_divider(menu);
1397
a0bd58a6535f In various Edit context menus, only display editors that match the file types in the selection.
zas_
parents: 1367
diff changeset
2256
1698
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2257 editmenu_fd_list = dupe_window_get_fd_list(dw);
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2258 g_signal_connect(G_OBJECT(menu), "destroy",
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2259 G_CALLBACK(dupe_menu_popup_destroy_cb), editmenu_fd_list);
bfe04f01de5e fixed destroying of menu data
nadvornik
parents: 1656
diff changeset
2260 submenu_add_edit(menu, &item, G_CALLBACK(dupe_menu_edit_cb), dw, editmenu_fd_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2261 if (!on_row) gtk_widget_set_sensitive(item, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2262 menu_item_add_stock_sensitive(menu, _("Add to new collection"), GTK_STOCK_INDEX, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2263 G_CALLBACK(dupe_menu_collection_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2264 menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2265 G_CALLBACK(dupe_menu_print_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2266 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2267 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2268 G_CALLBACK(dupe_menu_copy_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2269 menu_item_add_sensitive(menu, _("_Move..."), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2270 G_CALLBACK(dupe_menu_move_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2271 menu_item_add_sensitive(menu, _("_Rename..."), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2272 G_CALLBACK(dupe_menu_rename_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2273 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2274 G_CALLBACK(dupe_menu_delete_cb), dw);
1513
c9ed5a43c576 dropped show_copy_path option
nadvornik
parents: 1498
diff changeset
2275 menu_item_add_sensitive(menu, _("_Copy path"), on_row,
c9ed5a43c576 dropped show_copy_path option
nadvornik
parents: 1498
diff changeset
2276 G_CALLBACK(dupe_menu_copy_path_cb), dw);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2277 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2278 menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2279 G_CALLBACK(dupe_menu_remove_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2280 menu_item_add_stock_sensitive(menu, _("C_lear"), GTK_STOCK_CLEAR, (dw->list != NULL),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2281 G_CALLBACK(dupe_menu_clear_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2282 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2283 menu_item_add_stock(menu, _("Close _window"), GTK_STOCK_CLOSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2284 G_CALLBACK(dupe_menu_close_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2286 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2287 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2288
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2289 static gboolean dupe_listview_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2290 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2291 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2292 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2293 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2294 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2295 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2297 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2299 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2300 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2302 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2303 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2304 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2307 dw->click_item = di;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2308
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2309 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2311 /* right click menu */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2312 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2313
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2314 if (bevent->state & GDK_CONTROL_MASK && bevent->state & GDK_SHIFT_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2315 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2316 dupe_display_stats(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2317 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2318 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2319 if (widget == dw->listview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2320 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2321 menu = dupe_menu_popup_main(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2323 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2325 menu = dupe_menu_popup_second(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2327 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2328 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2329
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2330 if (!di) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2331
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2332 if (bevent->button == MOUSE_BUTTON_LEFT &&
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2333 bevent->type == GDK_2BUTTON_PRESS)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2334 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2335 dupe_menu_view(dw, di, widget, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2337
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2338 if (bevent->button == MOUSE_BUTTON_MIDDLE) return TRUE;
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2339
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2340 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2341 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2342 if (!dupe_listview_item_is_selected(dw, di, widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2343 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2344 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2345
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2346 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2347 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2348 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2350 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2351 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2352 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2353 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2355 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2357
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2358 if (bevent->button == MOUSE_BUTTON_LEFT &&
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2359 bevent->type == GDK_BUTTON_PRESS &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2360 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2361 !(bevent->state & GDK_CONTROL_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2362 dupe_listview_item_is_selected(dw, di, widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2363 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2364 /* this selection handled on release_cb */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2365 gtk_widget_grab_focus(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2366 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2367 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2369 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2370 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2371
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2372 static gboolean dupe_listview_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2374 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2375 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2376 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2377 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2378 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2379
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2380 if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2381
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2382 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2383
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2384 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2385 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2386 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2388 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2389 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2390 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2391 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2392
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 446
diff changeset
2393 if (bevent->button == MOUSE_BUTTON_MIDDLE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2394 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2395 if (di && dw->click_item == di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2397 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2399 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2400 if (dupe_listview_item_is_selected(dw, di, widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2401 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2402 gtk_tree_selection_unselect_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2403 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2404 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2405 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2406 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2407 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2408 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2409 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2412 if (di && dw->click_item == di &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2413 !(bevent->state & GDK_SHIFT_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2414 !(bevent->state & GDK_CONTROL_MASK ) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2415 dupe_listview_item_is_selected(dw, di, widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2416 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2417 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2419 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2420 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2421 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2422
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2423 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2424 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2425 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2427 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2428 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2430 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2433 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2434 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2435 * second set stuff
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2436 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2437 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2438
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2439 static void dupe_second_update_status(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2440 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2441 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2443 buf = g_strdup_printf(_("%d files (set 2)"), g_list_length(dw->second_list));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2444 gtk_label_set_text(GTK_LABEL(dw->second_status_label), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2445 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2446 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2447
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2448 static void dupe_second_add(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2450 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2451 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2453 if (!di) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2454
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2455 di->second = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2456 dw->second_list = g_list_prepend(dw->second_list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2458 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->second_listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2459 gtk_list_store_append(store, &iter);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
2460 gtk_list_store_set(store, &iter, DUPE_COLUMN_POINTER, di, 1, di->fd->path, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2462 dupe_second_update_status(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2463 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2465 static void dupe_second_remove(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2466 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2467 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2468 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2470 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->second_listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2471 if (dupe_listview_find_item(store, di, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2473 tree_view_move_cursor_away(GTK_TREE_VIEW(dw->second_listview), &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2474 gtk_list_store_remove(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2475 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2477 dw->second_list = g_list_remove(dw->second_list, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2479 dupe_second_update_status(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2480 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2482 static void dupe_second_clear(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2483 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2484 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2486 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->second_listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2487 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2488 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dw->second_listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2489
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2490 g_list_free(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2491 dw->dupes = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2493 dupe_list_free(dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2494 dw->second_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2496 dupe_match_reset_list(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2498 dupe_second_update_status(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2501 static void dupe_second_menu_view_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2502 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2503 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2504
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2505 if (dw->click_item) dupe_menu_view(dw, dw->click_item, dw->second_listview, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2506 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2508 static void dupe_second_menu_viewnew_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2509 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2510 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2512 if (dw->click_item) dupe_menu_view(dw, dw->click_item, dw->second_listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2513 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2515 static void dupe_second_menu_select_all_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2516 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2517 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2518 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2520 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->second_listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2521 gtk_tree_selection_select_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2524 static void dupe_second_menu_select_none_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2525 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2526 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2527 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2529 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->second_listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2530 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2531 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2533 static void dupe_second_menu_remove_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2534 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2535 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2537 dupe_window_remove_selection(dw, dw->second_listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2538 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2540 static void dupe_second_menu_clear_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2541 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2542 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2544 dupe_second_clear(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2545 dupe_window_recompare(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2546 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2548 static GtkWidget *dupe_menu_popup_second(DupeWindow *dw, DupeItem *di)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2549 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2550 GtkWidget *menu;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2551 gboolean notempty = (dw->second_list != NULL);
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2552 gboolean on_row = (di != NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2554 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2555 menu_item_add_sensitive(menu, _("_View"), on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2556 G_CALLBACK(dupe_second_menu_view_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2557 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2558 G_CALLBACK(dupe_second_menu_viewnew_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2559 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2560 menu_item_add_sensitive(menu, _("Select all"), notempty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2561 G_CALLBACK(dupe_second_menu_select_all_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2562 menu_item_add_sensitive(menu, _("Select none"), notempty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2563 G_CALLBACK(dupe_second_menu_select_none_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2564 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2565 menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, on_row,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2566 G_CALLBACK(dupe_second_menu_remove_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2567 menu_item_add_stock_sensitive(menu, _("C_lear"), GTK_STOCK_CLEAR, notempty,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2568 G_CALLBACK(dupe_second_menu_clear_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2569 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2570 menu_item_add_stock(menu, _("Close _window"), GTK_STOCK_CLOSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2571 G_CALLBACK(dupe_menu_close_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2573 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2574 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2575
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2576 static void dupe_second_set_toggle_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2578 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2580 dw->second_set = GTK_TOGGLE_BUTTON(widget)->active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2582 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2584 dupe_second_update_status(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2585 gtk_table_set_col_spacings(GTK_TABLE(dw->table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2586 gtk_widget_show(dw->second_vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2587 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2588 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2589 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2590 gtk_table_set_col_spacings(GTK_TABLE(dw->table), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2591 gtk_widget_hide(dw->second_vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2592 dupe_second_clear(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2593 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2595 dupe_window_recompare(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2596 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2598 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2599 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2600 * match type menu
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2601 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2602 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2604 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2605 DUPE_MENU_COLUMN_NAME = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2606 DUPE_MENU_COLUMN_MASK
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2607 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2609 static void dupe_menu_type_cb(GtkWidget *combo, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2610 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2611 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2612 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2613 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2614
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2615 store = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2616 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2617 gtk_tree_model_get(store, &iter, DUPE_MENU_COLUMN_MASK, &dw->match_mask, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2618
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2619 dupe_window_recompare(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2620 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2622 static void dupe_menu_add_item(GtkListStore *store, const gchar *text, DupeMatchType type, DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2624 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2625
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2626 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2627 gtk_list_store_set(store, &iter, DUPE_MENU_COLUMN_NAME, text,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2628 DUPE_MENU_COLUMN_MASK, type, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2630 if (dw->match_mask == type) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dw->combo), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2631 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2633 static void dupe_menu_setup(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2634 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2635 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2636 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2637
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2638 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2639 dw->combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2640 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2642 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2643 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dw->combo), renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2644 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dw->combo), renderer,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2645 "text", DUPE_MENU_COLUMN_NAME, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2646
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2647 dupe_menu_add_item(store, _("Name"), DUPE_MATCH_NAME, dw);
264
1015282898fe Add the possibility to match duplicates on the name but ignoring the case.
zas_
parents: 259
diff changeset
2648 dupe_menu_add_item(store, _("Name case-insensitive"), DUPE_MATCH_NAME_CI, dw);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2649 dupe_menu_add_item(store, _("Size"), DUPE_MATCH_SIZE, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2650 dupe_menu_add_item(store, _("Date"), DUPE_MATCH_DATE, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2651 dupe_menu_add_item(store, _("Dimensions"), DUPE_MATCH_DIM, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2652 dupe_menu_add_item(store, _("Checksum"), DUPE_MATCH_SUM, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2653 dupe_menu_add_item(store, _("Path"), DUPE_MATCH_PATH, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2654 dupe_menu_add_item(store, _("Similarity (high)"), DUPE_MATCH_SIM_HIGH, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2655 dupe_menu_add_item(store, _("Similarity"), DUPE_MATCH_SIM_MED, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2656 dupe_menu_add_item(store, _("Similarity (low)"), DUPE_MATCH_SIM_LOW, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2657 dupe_menu_add_item(store, _("Similarity (custom)"), DUPE_MATCH_SIM_CUSTOM, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2659 g_signal_connect(G_OBJECT(dw->combo), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2660 G_CALLBACK(dupe_menu_type_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2661 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2663 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2664 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2665 * list view columns
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2666 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2667 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2669 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2671 #define CELL_HEIGHT_OVERRIDE 512
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
2672
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2673 void cell_renderer_height_override(GtkCellRenderer *renderer)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2674 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2675 GParamSpec *spec;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2677 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2678 if (spec && G_IS_PARAM_SPEC_INT(spec))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2679 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2680 GParamSpecInt *spec_int;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2681
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2682 spec_int = G_PARAM_SPEC_INT(spec);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2683 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2684 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2685 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2687 static GdkColor *dupe_listview_color_shifted(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2688 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2689 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2690 static GtkWidget *done = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2691
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2692 if (done != widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2693 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2694 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2696 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2697 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2698 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2699 done = widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2700 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2701
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2702 return &color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2703 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2704
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2705 static void dupe_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2706 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2707 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2708 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2709 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2711 gtk_tree_model_get(tree_model, iter, DUPE_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2712 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2713 "cell-background-gdk", dupe_listview_color_shifted(dw->listview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2714 "cell-background-set", set, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2715 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2716
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2717 static void dupe_listview_add_column(DupeWindow *dw, GtkWidget *listview, gint n, const gchar *title, gboolean image, gboolean right_justify)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2718 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2719 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2720 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2722 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2723 gtk_tree_view_column_set_title(column, title);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2724 gtk_tree_view_column_set_min_width(column, 4);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2726 if (n != DUPE_COLUMN_RANK &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2727 n != DUPE_COLUMN_THUMB)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2728 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2729 gtk_tree_view_column_set_resizable(column, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2730 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2732 if (!image)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2733 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2734 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2735 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2736 if (right_justify)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2737 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2738 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2739 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2740 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2741 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2742 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2743 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2744 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2745 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2746 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2747 cell_renderer_height_override(renderer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2748 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2749 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2751
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2752 if (listview == dw->listview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2753 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2754 /* sets background before rendering */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2755 gtk_tree_view_column_set_cell_data_func(column, renderer, dupe_listview_color_cb, dw, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2756 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2758 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2759 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2760
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2761 static void dupe_listview_set_height(GtkWidget *listview, gboolean thumb)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2762 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2763 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2764 GtkCellRenderer *cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2765 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2766
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2767 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), DUPE_COLUMN_THUMB - 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2768 if (!column) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2769
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
2770 gtk_tree_view_column_set_fixed_width(column, (thumb) ? options->thumbnails.max_width : 4);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
2771
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2772 list = gtk_tree_view_column_get_cell_renderers(column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2773 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2774 cell = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2775 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2776
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
2777 g_object_set(G_OBJECT(cell), "height", (thumb) ? options->thumbnails.max_height : -1, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2778 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2781
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2782 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2783 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2784 * misc cb
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2785 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2786 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2788 static void dupe_window_show_thumb_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2789 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2790 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2792 dw->show_thumbs = GTK_TOGGLE_BUTTON(widget)->active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2793
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2794 if (dw->show_thumbs)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2795 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2796 if (!dw->working) dupe_thumb_step(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2797 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2798 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2799 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2800 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2801 GtkTreeIter iter;
1444
a005287bffc7 gint -> gboolean.
zas_
parents: 1432
diff changeset
2802 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2803
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2804 thumb_loader_free(dw->thumb_loader);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2805 dw->thumb_loader = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2806
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2807 store = gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2808 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2809
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2810 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2811 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2812 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DUPE_COLUMN_THUMB, NULL, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2813 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2814 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2815 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2816 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2817
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2818 dupe_listview_set_height(dw->listview, dw->show_thumbs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2819 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2821 static void dupe_popup_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2822 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2823 GtkWidget *view = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2824 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2825 gint cx, cy, cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2826 gint column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2828 gtk_tree_view_get_cursor(GTK_TREE_VIEW(view), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2829 if (!tpath) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2830
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2831 if (gtk_tree_view_get_column(GTK_TREE_VIEW(view), DUPE_COLUMN_NAME - 1) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2832 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2833 column = DUPE_COLUMN_NAME - 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2834 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2835 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2836 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2837 /* dw->second_listview */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2838 column = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2839 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2840 tree_view_get_cell_clamped(GTK_TREE_VIEW(view), tpath, column, TRUE, &cx, &cy, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2841 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2842 cy += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2843 popup_menu_position_clamp(menu, &cx, &cy, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2844 *x = cx;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2845 *y = cy;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2846 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2847
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2848 static gboolean dupe_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2849 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2850 DupeWindow *dw = data;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2851 gboolean stop_signal = FALSE;
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
2852 gboolean on_second;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2853 GtkWidget *listview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2854 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2855 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2856 GList *slist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2857 DupeItem *di = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2858
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2859 on_second = GTK_WIDGET_HAS_FOCUS(dw->second_listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2860
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2861 if (on_second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2862 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2863 listview = dw->second_listview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2864 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2865 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2866 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2867 listview = dw->listview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2868 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2870 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2871 slist = gtk_tree_selection_get_selected_rows(selection, &store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2872 if (slist)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2873 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2874 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2875 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2876 GList *last;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2878 last = g_list_last(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2879 tpath = last->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2880
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2881 /* last is newest selected file */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2882 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2883 gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2884 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2885 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2886 g_list_free(slist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2887
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2888 if (event->state & GDK_CONTROL_MASK)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2889 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2890 gint edit_val = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2892 if (!on_second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2893 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2894 stop_signal = TRUE;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2895 switch (event->keyval)
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2896 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2897 case '1':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2898 edit_val = 0;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2899 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2900 case '2':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2901 edit_val = 1;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2902 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2903 case '3':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2904 edit_val = 2;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2905 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2906 case '4':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2907 edit_val = 3;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2908 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2909 case '5':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2910 edit_val = 4;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2911 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2912 case '6':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2913 edit_val = 5;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2914 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2915 case '7':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2916 edit_val = 6;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2917 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2918 case '8':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2919 edit_val = 7;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2920 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2921 case '9':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2922 edit_val = 8;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2923 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2924 case '0':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2925 edit_val = 9;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2926 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2927 case 'C': case 'c':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2928 file_util_copy(NULL, dupe_listview_get_selection(dw, listview),
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2929 NULL, dw->window);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2930 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2931 case 'M': case 'm':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2932 file_util_move(NULL, dupe_listview_get_selection(dw, listview),
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2933 NULL, dw->window);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2934 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2935 case 'R': case 'r':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2936 file_util_rename(NULL, dupe_listview_get_selection(dw, listview), dw->window);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2937 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2938 case 'D': case 'd':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2939 file_util_delete(NULL, dupe_listview_get_selection(dw, listview), dw->window);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2940 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2941 default:
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2942 stop_signal = FALSE;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2943 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2944 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2945 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2946
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2947 if (!stop_signal)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2948 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2949 stop_signal = TRUE;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2950 switch (event->keyval)
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2951 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2952 case 'A': case 'a':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2953 if (event->state & GDK_SHIFT_MASK)
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2954 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2955 gtk_tree_selection_unselect_all(selection);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2956 }
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2957 else
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2958 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2959 gtk_tree_selection_select_all(selection);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2960 }
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2961 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2962 case GDK_Delete: case GDK_KP_Delete:
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2963 if (on_second)
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2964 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2965 dupe_second_clear(dw);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2966 dupe_window_recompare(dw);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2967 }
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2968 else
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2969 {
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2970 dupe_window_clear(dw);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2971 }
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2972 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2973 case 'L': case 'l':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2974 dupe_window_append_file_list(dw, FALSE);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2975 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2976 case 'T': case 't':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2977 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dw->button_thumbs),
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2978 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dw->button_thumbs)));
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2979 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2980 case 'W': case 'w':
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2981 dupe_window_close(dw);
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2982 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2983 default:
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2984 stop_signal = FALSE;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2985 break;
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2986 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2987 }
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
2988 #if 0
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2989 if (edit_val >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2990 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2991 dupe_window_edit_selected(dw, edit_val);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2992 }
1272
e0e12512cde2 read external editors from .desktop files
nadvornik
parents: 1211
diff changeset
2993 #endif
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2994 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2995 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2996 {
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
2997 stop_signal = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2998 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2999 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3000 case GDK_Return: case GDK_KP_Enter:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3001 dupe_menu_view(dw, di, listview, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3002 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3003 case 'V': case 'v':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3004 dupe_menu_view(dw, di, listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3005 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3006 case GDK_Delete: case GDK_KP_Delete:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3007 dupe_window_remove_selection(dw, listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3008 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3009 case 'C': case 'c':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3010 if (!on_second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3011 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3012 dupe_window_collection_from_selection(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3013 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3014 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3015 case '1':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3016 dupe_listview_select_dupes(dw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3017 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3018 case '2':
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3019 dupe_listview_select_dupes(dw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3020 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3021 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3022 case GDK_F10:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3023 if (!on_second)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3024 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3025 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3026
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3027 menu = dupe_menu_popup_main(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3028 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3029 dupe_popup_menu_pos_cb, listview, 0, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3030 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3031 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3032 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3033 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3035 menu = dupe_menu_popup_second(dw, di);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3036 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3037 dupe_popup_menu_pos_cb, listview, 0, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3038 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3039 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3040 default:
85
9d5c75b5ec28 Fri Oct 20 09:20:10 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
3041 stop_signal = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3042 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3043 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3044 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3045
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3046 return stop_signal;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3047 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3048
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3050 void dupe_window_clear(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3051 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3052 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3054 dupe_check_stop(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3055
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3056 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dw->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3057 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3058 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3059
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3060 g_list_free(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3061 dw->dupes = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3063 dupe_list_free(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3064 dw->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3065
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3066 dupe_match_reset_list(dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3067
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3068 dupe_window_update_count(dw, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3069 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3070 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3071
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3072 void dupe_window_close(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3073 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3074 dupe_check_stop(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3076 dupe_window_list = g_list_remove(dupe_window_list, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3077 gtk_widget_destroy(dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3079 g_list_free(dw->dupes);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3080 dupe_list_free(dw->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3082 dupe_list_free(dw->second_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3083
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3084 file_data_unregister_notify_func(dupe_notify_cb, dw);
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3085
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3086 g_free(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3087 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3088
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3089 static gint dupe_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3090 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3091 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3092 dupe_window_close(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3094 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3095 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3097 /* collection and files can be NULL */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3098 DupeWindow *dupe_window_new(DupeMatchType match_mask)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3099 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3100 DupeWindow *dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3101 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3102 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3103 GtkWidget *frame;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3104 GtkWidget *status_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3105 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3106 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3107 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3108 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3109 GdkGeometry geometry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3110
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3111 dw = g_new0(DupeWindow, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3113 dw->match_mask = match_mask;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3114
289
6a7298988a7a Simplify and unify gtk_window creation with the help of
zas_
parents: 288
diff changeset
3115 dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", NULL, NULL, _("Find duplicates"));
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3116
1029
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1022
diff changeset
3117 geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE;
1a4b18c58556 Use a constant for minimal window size. Set it to 32 for all dialogs.
zas_
parents: 1022
diff changeset
3118 geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3119 geometry.base_width = DUPE_DEF_WIDTH;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3120 geometry.base_height = DUPE_DEF_HEIGHT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3121 gtk_window_set_geometry_hints(GTK_WINDOW(dw->window), NULL, &geometry,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3122 GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3124 gtk_window_set_default_size(GTK_WINDOW(dw->window), DUPE_DEF_WIDTH, DUPE_DEF_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3125
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3126 gtk_window_set_resizable(GTK_WINDOW(dw->window), TRUE);
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
3127 gtk_container_set_border_width(GTK_CONTAINER(dw->window), 0);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3128
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3129 g_signal_connect(G_OBJECT(dw->window), "delete_event",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3130 G_CALLBACK(dupe_window_delete), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3131 g_signal_connect(G_OBJECT(dw->window), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3132 G_CALLBACK(dupe_window_keypress_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3133
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3134 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3135 gtk_container_add(GTK_CONTAINER(dw->window), vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3136 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3138 dw->table = gtk_table_new(1, 3, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3139 gtk_box_pack_start(GTK_BOX(vbox), dw->table, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3140 gtk_widget_show(dw->table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3142 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3143 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3144 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3145 gtk_table_attach_defaults(GTK_TABLE(dw->table), scrolled, 0, 2, 0, 1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3146 gtk_widget_show(scrolled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3148 store = gtk_list_store_new(9, G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3149 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3150 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3151 dw->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3152 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3154 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3155 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3156 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(dw->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3157 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(dw->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3159 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_RANK, "", FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3160 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_THUMB, "", TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3161 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_NAME, _("Name"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3162 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_SIZE, _("Size"), FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3163 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_DATE, _("Date"), FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3164 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_DIMENSIONS, _("Dimensions"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3165 dupe_listview_add_column(dw, dw->listview, DUPE_COLUMN_PATH, _("Path"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3167 gtk_container_add(GTK_CONTAINER(scrolled), dw->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3168 gtk_widget_show(dw->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3170 dw->second_vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3171 gtk_table_attach_defaults(GTK_TABLE(dw->table), dw->second_vbox, 2, 3, 0, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3172 if (dw->second_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3173 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3174 gtk_table_set_col_spacings(GTK_TABLE(dw->table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3175 gtk_widget_show(dw->second_vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3176 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3177 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3178 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3179 gtk_table_set_col_spacings(GTK_TABLE(dw->table), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3182 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3183 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3184 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3185 gtk_box_pack_start(GTK_BOX(dw->second_vbox), scrolled, TRUE, TRUE, 0);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3186 gtk_widget_show(scrolled);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3188 store = gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3189 dw->second_listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3191 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->second_listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3192 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3194 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(dw->second_listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3195 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(dw->second_listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3197 dupe_listview_add_column(dw, dw->second_listview, 1, _("Compare to:"), FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3199 gtk_container_add(GTK_CONTAINER(scrolled), dw->second_listview);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3200 gtk_widget_show(dw->second_listview);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3202 dw->second_status_label = gtk_label_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3203 gtk_box_pack_start(GTK_BOX(dw->second_vbox), dw->second_status_label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3204 gtk_widget_show(dw->second_status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3206 pref_line(dw->second_vbox, GTK_ORIENTATION_HORIZONTAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3208 status_box = pref_box_new(vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3210 label = gtk_label_new(_("Compare by:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3211 gtk_box_pack_start(GTK_BOX(status_box), label, FALSE, FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3212 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3214 dupe_menu_setup(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3215 gtk_box_pack_start(GTK_BOX(status_box), dw->combo, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3216 gtk_widget_show(dw->combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3218 dw->button_thumbs = gtk_check_button_new_with_label(_("Thumbnails"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3219 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dw->button_thumbs), dw->show_thumbs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3220 g_signal_connect(G_OBJECT(dw->button_thumbs), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3221 G_CALLBACK(dupe_window_show_thumb_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3222 gtk_box_pack_start(GTK_BOX(status_box), dw->button_thumbs, FALSE, FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3223 gtk_widget_show(dw->button_thumbs);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3225 button = gtk_check_button_new_with_label(_("Compare two file sets"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3226 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), dw->second_set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3227 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3228 G_CALLBACK(dupe_second_set_toggle_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3229 gtk_box_pack_end(GTK_BOX(status_box), button, FALSE, FALSE, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3230 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3231
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3232 status_box = gtk_hbox_new(FALSE, 0);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3233 gtk_box_pack_start(GTK_BOX(vbox), status_box, FALSE, FALSE, 0);
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3234 gtk_widget_show(status_box);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3235
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3236 frame = gtk_frame_new(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3237 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3238 gtk_box_pack_start(GTK_BOX(status_box), frame, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3239 gtk_widget_show(frame);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3241 dw->status_label = gtk_label_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3242 gtk_container_add(GTK_CONTAINER(frame), dw->status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3243 gtk_widget_show(dw->status_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3245 dw->extra_label = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3246 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3247 gtk_box_pack_end(GTK_BOX(status_box), dw->extra_label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3248 gtk_widget_show(dw->extra_label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3250 dupe_dnd_init(dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3252 /* order is important here, dnd_init should be seeing mouse
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3253 * presses before we possibly handle (and stop) the signal
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3254 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3255 g_signal_connect(G_OBJECT(dw->listview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3256 G_CALLBACK(dupe_listview_press_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3257 g_signal_connect(G_OBJECT(dw->listview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3258 G_CALLBACK(dupe_listview_release_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3259 g_signal_connect(G_OBJECT(dw->second_listview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3260 G_CALLBACK(dupe_listview_press_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3261 g_signal_connect(G_OBJECT(dw->second_listview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3262 G_CALLBACK(dupe_listview_release_cb), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3264 gtk_widget_show(dw->window);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3266 dupe_window_update_count(dw, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3267 dupe_window_update_progress(dw, NULL, 0.0, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3269 dupe_window_list = g_list_append(dupe_window_list, dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3270
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3271 file_data_register_notify_func(dupe_notify_cb, dw, NOTIFY_PRIORITY_MEDIUM);
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3272
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3273 return dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3274 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3275
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3276 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3277 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3278 * dnd confirm dir
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3279 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3280 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3282 typedef struct {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3283 DupeWindow *dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3284 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3285 } CDupeConfirmD;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3287 static void confirm_dir_list_cancel(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3289 /* do nothing */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3290 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3292 static void confirm_dir_list_add(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3293 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3294 CDupeConfirmD *d = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3295 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3297 dupe_window_add_files(d->dw, d->list, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3299 work = d->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3300 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3301 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3302 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3303 work = work->next;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3304 if (isdir(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3305 {
780
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 753
diff changeset
3306 GList *list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3307
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
3308 filelist_read(fd, &list, NULL);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3309 list = filelist_filter(list, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3310 if (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3311 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3312 dupe_window_add_files(d->dw, list, FALSE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3313 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3314 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3315 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3319 static void confirm_dir_list_recurse(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3320 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3321 CDupeConfirmD *d = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3322 dupe_window_add_files(d->dw, d->list, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3323 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3325 static void confirm_dir_list_skip(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3327 CDupeConfirmD *d = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3328 dupe_window_add_files(d->dw, d->list, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3329 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3330
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3331 static void confirm_dir_list_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3332 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3333 CDupeConfirmD *d = data;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3334 filelist_free(d->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3335 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3338 static GtkWidget *dupe_confirm_dir_list(DupeWindow *dw, GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3340 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3341 CDupeConfirmD *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3343 d = g_new0(CDupeConfirmD, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3344 d->dw = dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3345 d->list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3347 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3348 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3349 G_CALLBACK(confirm_dir_list_destroy), d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3351 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3352 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3353 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK, G_CALLBACK(confirm_dir_list_add), d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3354 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD, G_CALLBACK(confirm_dir_list_recurse), d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3355 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE, G_CALLBACK(confirm_dir_list_skip), d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3356 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3357 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, G_CALLBACK(confirm_dir_list_cancel), d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3359 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3362 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3363 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3364 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3365 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3366 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3368 static GtkTargetEntry dupe_drag_types[] = {
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3369 { "text/uri-list", 0, TARGET_URI_LIST },
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3370 { "text/plain", 0, TARGET_TEXT_PLAIN }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3371 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3372 static gint n_dupe_drag_types = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3373
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3374 static GtkTargetEntry dupe_drop_types[] = {
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3375 { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER },
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 342
diff changeset
3376 { "text/uri-list", 0, TARGET_URI_LIST }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3377 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3378 static gint n_dupe_drop_types = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3379
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3380 static void dupe_dnd_data_set(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3381 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3382 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3383 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3384 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3385 gchar *uri_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3386 gint length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3387 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3389 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3391 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3392 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3393 list = dupe_listview_get_selection(dw, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3394 if (!list) return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3395 uri_text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3396 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3397 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3398 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3399 uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3400 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3403 if (uri_text) gtk_selection_data_set(selection_data, selection_data->target,
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
3404 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3405 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3406 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3408 static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3409 gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3410 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3411 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3412 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3413 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3414 GtkWidget *source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3415 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3416 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3418 source = gtk_drag_get_source_widget(context);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3419 if (source == dw->listview || source == dw->second_listview) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3420
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3421 dw->second_drop = (dw->second_set && widget == dw->second_listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3422
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3423 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3424 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3425 case TARGET_APP_COLLECTION_MEMBER:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3426 collection_from_dnd_data((gchar *)selection_data->data, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3427 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3428 case TARGET_URI_LIST:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3429 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3430 work = list;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 513
diff changeset
3431 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3432 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3433 FileData *fd = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3434 if (isdir(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3436 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3437 menu = dupe_confirm_dir_list(dw, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3438 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3439 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3440 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3441 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3442 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3443 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3444 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3445 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3446 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3447 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3449 if (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3450 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3451 dupe_window_add_files(dw, list, FALSE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 85
diff changeset
3452 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3453 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3455
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1397
diff changeset
3456 static void dupe_dest_set(GtkWidget *widget, gboolean enable)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3457 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3458 if (enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3459 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3460 gtk_drag_dest_set(widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3461 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3462 dupe_drop_types, n_dupe_drop_types,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3463 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3465 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3466 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3467 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3468 gtk_drag_dest_unset(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3470 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3471
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3472 static void dupe_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3473 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3474 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3475 dupe_dest_set(dw->listview, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3476 dupe_dest_set(dw->second_listview, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3477
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3478 if (dw->click_item && !dupe_listview_item_is_selected(dw, dw->click_item, widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3479 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3480 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3481 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3483 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3484 if (dupe_listview_find_item(store, dw->click_item, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3486 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3487 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3489 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3490 gtk_tree_selection_unselect_all(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3491 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3493 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3494 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3495 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3496 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3497 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3499 if (dw->show_thumbs &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3500 widget == dw->listview &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3501 dw->click_item && dw->click_item->pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3502 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3503 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3504 gint items;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3506 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3507 items = gtk_tree_selection_count_selected_rows(selection);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3508 dnd_set_drag_icon(widget, context, dw->click_item->pixbuf, items);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3509 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3510 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3512 static void dupe_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3513 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3514 DupeWindow *dw = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3515 dupe_dest_set(dw->listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3516 dupe_dest_set(dw->second_listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3517 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3519 static void dupe_dnd_init(DupeWindow *dw)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3520 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3521 gtk_drag_source_set(dw->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3522 dupe_drag_types, n_dupe_drag_types,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3523 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3524 g_signal_connect(G_OBJECT(dw->listview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3525 G_CALLBACK(dupe_dnd_data_set), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3526 g_signal_connect(G_OBJECT(dw->listview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3527 G_CALLBACK(dupe_dnd_begin), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3528 g_signal_connect(G_OBJECT(dw->listview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3529 G_CALLBACK(dupe_dnd_end), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3530
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3531 dupe_dest_set(dw->listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3532 g_signal_connect(G_OBJECT(dw->listview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3533 G_CALLBACK(dupe_dnd_data_get), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3535 gtk_drag_source_set(dw->second_listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3536 dupe_drag_types, n_dupe_drag_types,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3537 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3538 g_signal_connect(G_OBJECT(dw->second_listview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3539 G_CALLBACK(dupe_dnd_data_set), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3540 g_signal_connect(G_OBJECT(dw->second_listview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3541 G_CALLBACK(dupe_dnd_begin), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3542 g_signal_connect(G_OBJECT(dw->second_listview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3543 G_CALLBACK(dupe_dnd_end), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3544
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3545 dupe_dest_set(dw->second_listview, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3546 g_signal_connect(G_OBJECT(dw->second_listview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3547 G_CALLBACK(dupe_dnd_data_get), dw);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3548 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3550 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3551 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3552 * maintenance (move, delete, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3553 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3554 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3555
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3556 static void dupe_notify_cb(FileData *fd, NotifyType type, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3557 {
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3558 DupeWindow *dw = data;
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3559
1432
cf4029d10d38 improved notification system
nadvornik
parents: 1420
diff changeset
3560 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
1498
5f49f305a6b6 improved debug messages
nadvornik
parents: 1445
diff changeset
3561
5f49f305a6b6 improved debug messages
nadvornik
parents: 1445
diff changeset
3562 DEBUG_1("Notify dupe: %s %04x", fd->path, type);
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3563
1347
79937bc55f3a Add missing space between switch and first parenthesis.
zas_
parents: 1346
diff changeset
3564 switch (fd->change->type)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3565 {
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3566 case FILEDATA_CHANGE_MOVE:
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3567 case FILEDATA_CHANGE_RENAME:
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3568 dupe_item_update_fd(dw, fd);
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3569 break;
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3570 case FILEDATA_CHANGE_COPY:
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3571 break;
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3572 case FILEDATA_CHANGE_DELETE:
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3573 while (dupe_item_remove_by_path(dw, fd->path));
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3574 break;
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3575 case FILEDATA_CHANGE_UNSPECIFIED:
1211
e2bbe90b0dcd most of the metadata options now works
nadvornik
parents: 1174
diff changeset
3576 case FILEDATA_CHANGE_WRITE_METADATA:
794
03614b7883ea used new notification in dupe.c
nadvornik
parents: 786
diff changeset
3577 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3580 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1049
diff changeset
3581 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */