1 use crate::help_functions::*;
2 use gtk::prelude::*;
3 use gtk::TreeViewColumn;
4 
create_tree_view_duplicates(tree_view: &mut gtk::TreeView)5 pub fn create_tree_view_duplicates(tree_view: &mut gtk::TreeView) {
6     let model = get_list_store(tree_view);
7 
8     let renderer = gtk::CellRendererToggle::new();
9     renderer.connect_toggled(move |_r, path| {
10         let iter = model.iter(&path).unwrap();
11         let mut fixed = model
12             .value(&iter, ColumnsDuplicates::ActiveSelectButton as i32)
13             .get::<bool>()
14             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
15         fixed = !fixed;
16         model.set_value(&iter, ColumnsDuplicates::ActiveSelectButton as u32, &fixed.to_value());
17     });
18     let column = gtk::TreeViewColumn::new();
19     column.pack_start(&renderer, true);
20     column.set_resizable(false);
21     column.set_fixed_width(30);
22     column.add_attribute(&renderer, "activatable", ColumnsDuplicates::ActivatableSelectButton as i32);
23     column.add_attribute(&renderer, "active", ColumnsDuplicates::ActiveSelectButton as i32);
24     column.add_attribute(&renderer, "cell-background", ColumnsDuplicates::Color as i32);
25     tree_view.append_column(&column);
26 
27     let renderer = gtk::CellRendererText::new();
28     let column: gtk::TreeViewColumn = TreeViewColumn::new();
29     column.pack_start(&renderer, true);
30     column.set_title("File Name");
31     column.set_resizable(true);
32     column.set_min_width(50);
33     column.add_attribute(&renderer, "text", ColumnsDuplicates::Name as i32);
34     column.add_attribute(&renderer, "background", ColumnsDuplicates::Color as i32);
35     column.add_attribute(&renderer, "foreground", ColumnsDuplicates::TextColor as i32);
36     tree_view.append_column(&column);
37 
38     let renderer = gtk::CellRendererText::new();
39     let column: gtk::TreeViewColumn = TreeViewColumn::new();
40     column.pack_start(&renderer, true);
41     column.set_title("Path");
42     column.set_resizable(true);
43     column.set_min_width(50);
44     column.add_attribute(&renderer, "text", ColumnsDuplicates::Path as i32);
45     column.add_attribute(&renderer, "background", ColumnsDuplicates::Color as i32);
46     column.add_attribute(&renderer, "foreground", ColumnsDuplicates::TextColor as i32);
47     tree_view.append_column(&column);
48 
49     let renderer = gtk::CellRendererText::new();
50     let column: gtk::TreeViewColumn = TreeViewColumn::new();
51     column.pack_start(&renderer, true);
52     column.set_title("Modification Date");
53     column.set_resizable(true);
54     column.set_min_width(50);
55     column.add_attribute(&renderer, "text", ColumnsDuplicates::Modification as i32);
56     column.add_attribute(&renderer, "background", ColumnsDuplicates::Color as i32);
57     column.add_attribute(&renderer, "foreground", ColumnsDuplicates::TextColor as i32);
58     tree_view.append_column(&column);
59 
60     tree_view.set_vexpand(true);
61 }
62 
create_tree_view_empty_folders(tree_view: &mut gtk::TreeView)63 pub fn create_tree_view_empty_folders(tree_view: &mut gtk::TreeView) {
64     let model = get_list_store(tree_view);
65 
66     let renderer = gtk::CellRendererToggle::new();
67     renderer.connect_toggled(move |_r, path| {
68         let iter = model.iter(&path).unwrap();
69         let mut fixed = model
70             .value(&iter, ColumnsEmptyFolders::ActiveSelectButton as i32)
71             .get::<bool>()
72             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
73         fixed = !fixed;
74         model.set_value(&iter, ColumnsEmptyFolders::ActiveSelectButton as u32, &fixed.to_value());
75     });
76     let column = gtk::TreeViewColumn::new();
77     column.pack_start(&renderer, true);
78     column.set_resizable(false);
79     column.set_fixed_width(30);
80     column.add_attribute(&renderer, "active", ColumnsEmptyFolders::ActiveSelectButton as i32);
81     tree_view.append_column(&column);
82 
83     let renderer = gtk::CellRendererText::new();
84     let column: gtk::TreeViewColumn = TreeViewColumn::new();
85     column.pack_start(&renderer, true);
86     column.set_title("Folder Name");
87     column.set_resizable(true);
88     column.set_min_width(50);
89     column.add_attribute(&renderer, "text", ColumnsEmptyFolders::Name as i32);
90     tree_view.append_column(&column);
91 
92     let renderer = gtk::CellRendererText::new();
93     let column: gtk::TreeViewColumn = TreeViewColumn::new();
94     column.pack_start(&renderer, true);
95     column.set_title("Path");
96     column.set_resizable(true);
97     column.set_min_width(50);
98     column.add_attribute(&renderer, "text", ColumnsEmptyFolders::Path as i32);
99     tree_view.append_column(&column);
100 
101     let renderer = gtk::CellRendererText::new();
102     let column: gtk::TreeViewColumn = TreeViewColumn::new();
103     column.pack_start(&renderer, true);
104     column.set_title("Modification Date");
105     column.set_resizable(true);
106     column.set_min_width(50);
107     column.add_attribute(&renderer, "text", ColumnsEmptyFolders::Modification as i32);
108     tree_view.append_column(&column);
109 
110     tree_view.set_vexpand(true);
111 }
112 
create_tree_view_big_files(tree_view: &mut gtk::TreeView)113 pub fn create_tree_view_big_files(tree_view: &mut gtk::TreeView) {
114     let model = get_list_store(tree_view);
115 
116     let renderer = gtk::CellRendererToggle::new();
117     renderer.connect_toggled(move |_r, path| {
118         let iter = model.iter(&path).unwrap();
119         let mut fixed = model
120             .value(&iter, ColumnsBigFiles::ActiveSelectButton as i32)
121             .get::<bool>()
122             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
123         fixed = !fixed;
124         model.set_value(&iter, ColumnsBigFiles::ActiveSelectButton as u32, &fixed.to_value());
125     });
126     let column = gtk::TreeViewColumn::new();
127     column.pack_start(&renderer, true);
128     column.set_resizable(false);
129     column.set_fixed_width(30);
130     column.add_attribute(&renderer, "active", ColumnsBigFiles::ActiveSelectButton as i32);
131     tree_view.append_column(&column);
132 
133     let renderer = gtk::CellRendererText::new();
134     let column: gtk::TreeViewColumn = TreeViewColumn::new();
135     column.pack_start(&renderer, true);
136     column.set_title("Size");
137     column.set_resizable(true);
138     column.set_min_width(50);
139     column.add_attribute(&renderer, "text", ColumnsBigFiles::Size as i32);
140 
141     tree_view.append_column(&column);
142     let renderer = gtk::CellRendererText::new();
143     let column: gtk::TreeViewColumn = TreeViewColumn::new();
144     column.pack_start(&renderer, true);
145     column.set_title("File Name");
146     column.set_resizable(true);
147     column.set_min_width(50);
148     column.add_attribute(&renderer, "text", ColumnsBigFiles::Name as i32);
149     tree_view.append_column(&column);
150 
151     let renderer = gtk::CellRendererText::new();
152     let column: gtk::TreeViewColumn = TreeViewColumn::new();
153     column.pack_start(&renderer, true);
154     column.set_title("Path");
155     column.set_resizable(true);
156     column.set_min_width(50);
157     column.add_attribute(&renderer, "text", ColumnsBigFiles::Path as i32);
158     tree_view.append_column(&column);
159 
160     let renderer = gtk::CellRendererText::new();
161     let column: gtk::TreeViewColumn = TreeViewColumn::new();
162     column.pack_start(&renderer, true);
163     column.set_title("Modification Date");
164     column.set_resizable(true);
165     column.set_min_width(50);
166     column.add_attribute(&renderer, "text", ColumnsBigFiles::Modification as i32);
167     tree_view.append_column(&column);
168 
169     tree_view.set_vexpand(true);
170 }
171 
create_tree_view_temporary_files(tree_view: &mut gtk::TreeView)172 pub fn create_tree_view_temporary_files(tree_view: &mut gtk::TreeView) {
173     let model = get_list_store(tree_view);
174 
175     let renderer = gtk::CellRendererToggle::new();
176     renderer.connect_toggled(move |_r, path| {
177         let iter = model.iter(&path).unwrap();
178         let mut fixed = model
179             .value(&iter, ColumnsTemporaryFiles::ActiveSelectButton as i32)
180             .get::<bool>()
181             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
182         fixed = !fixed;
183         model.set_value(&iter, ColumnsTemporaryFiles::ActiveSelectButton as u32, &fixed.to_value());
184     });
185     let column = gtk::TreeViewColumn::new();
186     column.pack_start(&renderer, true);
187     column.set_resizable(false);
188     column.set_fixed_width(30);
189     column.add_attribute(&renderer, "active", ColumnsTemporaryFiles::ActiveSelectButton as i32);
190     tree_view.append_column(&column);
191 
192     let renderer = gtk::CellRendererText::new();
193     let column: gtk::TreeViewColumn = TreeViewColumn::new();
194     column.pack_start(&renderer, true);
195     column.set_title("File Name");
196     column.set_resizable(true);
197     column.set_min_width(50);
198     column.add_attribute(&renderer, "text", ColumnsTemporaryFiles::Name as i32);
199     tree_view.append_column(&column);
200 
201     let renderer = gtk::CellRendererText::new();
202     let column: gtk::TreeViewColumn = TreeViewColumn::new();
203     column.pack_start(&renderer, true);
204     column.set_title("Path");
205     column.set_resizable(true);
206     column.set_min_width(50);
207     column.add_attribute(&renderer, "text", ColumnsTemporaryFiles::Path as i32);
208     tree_view.append_column(&column);
209 
210     let renderer = gtk::CellRendererText::new();
211     let column: gtk::TreeViewColumn = TreeViewColumn::new();
212     column.pack_start(&renderer, true);
213     column.set_title("Modification Date");
214     column.set_resizable(true);
215     column.set_min_width(50);
216     column.add_attribute(&renderer, "text", ColumnsTemporaryFiles::Modification as i32);
217     tree_view.append_column(&column);
218 
219     tree_view.set_vexpand(true);
220 }
221 
create_tree_view_empty_files(tree_view: &mut gtk::TreeView)222 pub fn create_tree_view_empty_files(tree_view: &mut gtk::TreeView) {
223     let model = get_list_store(tree_view);
224 
225     let renderer = gtk::CellRendererToggle::new();
226     renderer.connect_toggled(move |_r, path| {
227         let iter = model.iter(&path).unwrap();
228         let mut fixed = model
229             .value(&iter, ColumnsEmptyFiles::ActiveSelectButton as i32)
230             .get::<bool>()
231             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
232         fixed = !fixed;
233         model.set_value(&iter, ColumnsEmptyFiles::ActiveSelectButton as u32, &fixed.to_value());
234     });
235     let column = gtk::TreeViewColumn::new();
236     column.pack_start(&renderer, true);
237     column.set_resizable(false);
238     column.set_fixed_width(30);
239     column.add_attribute(&renderer, "active", ColumnsEmptyFiles::ActiveSelectButton as i32);
240     tree_view.append_column(&column);
241 
242     let renderer = gtk::CellRendererText::new();
243     let column: gtk::TreeViewColumn = TreeViewColumn::new();
244     column.pack_start(&renderer, true);
245     column.set_title("File Name");
246     column.set_resizable(true);
247     column.set_min_width(50);
248     column.add_attribute(&renderer, "text", ColumnsEmptyFiles::Name as i32);
249     tree_view.append_column(&column);
250 
251     let renderer = gtk::CellRendererText::new();
252     let column: gtk::TreeViewColumn = TreeViewColumn::new();
253     column.pack_start(&renderer, true);
254     column.set_title("Path");
255     column.set_resizable(true);
256     column.set_min_width(50);
257     column.add_attribute(&renderer, "text", ColumnsEmptyFiles::Path as i32);
258     tree_view.append_column(&column);
259 
260     let renderer = gtk::CellRendererText::new();
261     let column: gtk::TreeViewColumn = TreeViewColumn::new();
262     column.pack_start(&renderer, true);
263     column.set_title("Modification Date");
264     column.set_resizable(true);
265     column.set_min_width(50);
266     column.add_attribute(&renderer, "text", ColumnsEmptyFiles::Modification as i32);
267     tree_view.append_column(&column);
268 
269     tree_view.set_vexpand(true);
270 }
271 
create_tree_view_similar_images(tree_view: &mut gtk::TreeView)272 pub fn create_tree_view_similar_images(tree_view: &mut gtk::TreeView) {
273     let model = get_list_store(tree_view);
274 
275     let renderer = gtk::CellRendererToggle::new();
276     renderer.connect_toggled(move |_r, path| {
277         let iter = model.iter(&path).unwrap();
278         let mut fixed = model
279             .value(&iter, ColumnsSimilarImages::ActiveSelectButton as i32)
280             .get::<bool>()
281             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
282         fixed = !fixed;
283         model.set_value(&iter, ColumnsSimilarImages::ActiveSelectButton as u32, &fixed.to_value());
284     });
285     let column = gtk::TreeViewColumn::new();
286     column.pack_start(&renderer, true);
287     column.set_resizable(false);
288     column.set_fixed_width(30);
289     column.add_attribute(&renderer, "activatable", ColumnsSimilarImages::ActivatableSelectButton as i32);
290     column.add_attribute(&renderer, "active", ColumnsSimilarImages::ActiveSelectButton as i32);
291     column.add_attribute(&renderer, "cell-background", ColumnsSimilarImages::Color as i32);
292     tree_view.append_column(&column);
293 
294     let renderer = gtk::CellRendererText::new();
295     let column: gtk::TreeViewColumn = TreeViewColumn::new();
296     column.pack_start(&renderer, true);
297     column.set_title("Similarity");
298     column.set_resizable(true);
299     column.set_min_width(50);
300     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Similarity as i32);
301     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
302     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
303     tree_view.append_column(&column);
304 
305     let renderer = gtk::CellRendererText::new();
306     let column: gtk::TreeViewColumn = TreeViewColumn::new();
307     column.pack_start(&renderer, true);
308     column.set_title("Size");
309     column.set_resizable(true);
310     column.set_min_width(50);
311     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Size as i32);
312     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
313     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
314     tree_view.append_column(&column);
315 
316     let renderer = gtk::CellRendererText::new();
317     let column: gtk::TreeViewColumn = TreeViewColumn::new();
318     column.pack_start(&renderer, true);
319     column.set_title("Dimensions");
320     column.set_resizable(true);
321     column.set_min_width(50);
322     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Dimensions as i32);
323     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
324     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
325     tree_view.append_column(&column);
326 
327     let renderer = gtk::CellRendererText::new();
328     let column: gtk::TreeViewColumn = TreeViewColumn::new();
329     column.pack_start(&renderer, true);
330     column.set_title("File Name");
331     column.set_resizable(true);
332     column.set_min_width(50);
333     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Name as i32);
334     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
335     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
336     tree_view.append_column(&column);
337 
338     let renderer = gtk::CellRendererText::new();
339     let column: gtk::TreeViewColumn = TreeViewColumn::new();
340     column.pack_start(&renderer, true);
341     column.set_title("Path");
342     column.set_resizable(true);
343     column.set_min_width(50);
344     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Path as i32);
345     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
346     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
347     tree_view.append_column(&column);
348 
349     let renderer = gtk::CellRendererText::new();
350     let column: gtk::TreeViewColumn = TreeViewColumn::new();
351     column.pack_start(&renderer, true);
352     column.set_title("Modification Date");
353     column.set_resizable(true);
354     column.set_min_width(50);
355     column.add_attribute(&renderer, "text", ColumnsSimilarImages::Modification as i32);
356     column.add_attribute(&renderer, "background", ColumnsSimilarImages::Color as i32);
357     column.add_attribute(&renderer, "foreground", ColumnsSimilarImages::TextColor as i32);
358     tree_view.append_column(&column);
359 
360     tree_view.set_vexpand(true);
361 }
362 
create_tree_view_directories(tree_view: &mut gtk::TreeView)363 pub fn create_tree_view_directories(tree_view: &mut gtk::TreeView) {
364     let renderer = gtk::CellRendererText::new();
365     let column: gtk::TreeViewColumn = TreeViewColumn::new();
366     column.pack_start(&renderer, true);
367     column.add_attribute(&renderer, "text", ColumnsDirectory::Path as i32);
368     tree_view.append_column(&column);
369 
370     tree_view.set_headers_visible(false);
371 }
372 
create_tree_view_zeroed_files(tree_view: &mut gtk::TreeView)373 pub fn create_tree_view_zeroed_files(tree_view: &mut gtk::TreeView) {
374     let model = get_list_store(tree_view);
375 
376     let renderer = gtk::CellRendererToggle::new();
377     renderer.connect_toggled(move |_r, path| {
378         let iter = model.iter(&path).unwrap();
379         let mut fixed = model
380             .value(&iter, ColumnsZeroedFiles::ActiveSelectButton as i32)
381             .get::<bool>()
382             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
383         fixed = !fixed;
384         model.set_value(&iter, ColumnsZeroedFiles::ActiveSelectButton as u32, &fixed.to_value());
385     });
386     let column = gtk::TreeViewColumn::new();
387     column.pack_start(&renderer, true);
388     column.set_resizable(false);
389     column.set_fixed_width(30);
390     column.add_attribute(&renderer, "active", ColumnsZeroedFiles::ActiveSelectButton as i32);
391     tree_view.append_column(&column);
392 
393     let renderer = gtk::CellRendererText::new();
394     let column: gtk::TreeViewColumn = TreeViewColumn::new();
395     column.pack_start(&renderer, true);
396     column.set_title("Size");
397     column.set_resizable(true);
398     column.set_min_width(50);
399     column.add_attribute(&renderer, "text", ColumnsZeroedFiles::Size as i32);
400     tree_view.append_column(&column);
401 
402     let renderer = gtk::CellRendererText::new();
403     let column: gtk::TreeViewColumn = TreeViewColumn::new();
404     column.pack_start(&renderer, true);
405     column.set_title("File Name");
406     column.set_resizable(true);
407     column.set_min_width(50);
408     column.add_attribute(&renderer, "text", ColumnsZeroedFiles::Name as i32);
409     tree_view.append_column(&column);
410 
411     let renderer = gtk::CellRendererText::new();
412     let column: gtk::TreeViewColumn = TreeViewColumn::new();
413     column.pack_start(&renderer, true);
414     column.set_title("Path");
415     column.set_resizable(true);
416     column.set_min_width(50);
417     column.add_attribute(&renderer, "text", ColumnsZeroedFiles::Path as i32);
418     tree_view.append_column(&column);
419 
420     let renderer = gtk::CellRendererText::new();
421     let column: gtk::TreeViewColumn = TreeViewColumn::new();
422     column.pack_start(&renderer, true);
423     column.set_title("Modification Date");
424     column.set_resizable(true);
425     column.set_min_width(50);
426     column.add_attribute(&renderer, "text", ColumnsZeroedFiles::Modification as i32);
427     tree_view.append_column(&column);
428 
429     tree_view.set_vexpand(true);
430 }
431 
create_tree_view_same_music(tree_view: &mut gtk::TreeView)432 pub fn create_tree_view_same_music(tree_view: &mut gtk::TreeView) {
433     let model = get_list_store(tree_view);
434 
435     let renderer = gtk::CellRendererToggle::new();
436     renderer.connect_toggled(move |_r, path| {
437         let iter = model.iter(&path).unwrap();
438         let mut fixed = model
439             .value(&iter, ColumnsSameMusic::ActiveSelectButton as i32)
440             .get::<bool>()
441             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
442         fixed = !fixed;
443         model.set_value(&iter, ColumnsSameMusic::ActiveSelectButton as u32, &fixed.to_value());
444     });
445     let column = gtk::TreeViewColumn::new();
446     column.pack_start(&renderer, true);
447     column.set_resizable(false);
448     column.set_fixed_width(30);
449     column.add_attribute(&renderer, "activatable", ColumnsSameMusic::ActivatableSelectButton as i32);
450     column.add_attribute(&renderer, "active", ColumnsSameMusic::ActiveSelectButton as i32);
451     column.add_attribute(&renderer, "cell-background", ColumnsSameMusic::Color as i32);
452     tree_view.append_column(&column);
453 
454     let renderer = gtk::CellRendererText::new();
455     let column: gtk::TreeViewColumn = TreeViewColumn::new();
456     column.pack_start(&renderer, true);
457     column.set_title("Size");
458     column.set_resizable(true);
459     column.set_min_width(50);
460     column.add_attribute(&renderer, "text", ColumnsSameMusic::Size as i32);
461     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
462     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
463     tree_view.append_column(&column);
464 
465     let renderer = gtk::CellRendererText::new();
466     let column: gtk::TreeViewColumn = TreeViewColumn::new();
467     column.pack_start(&renderer, true);
468     column.set_title("File Name");
469     column.set_resizable(true);
470     column.set_min_width(50);
471     column.add_attribute(&renderer, "text", ColumnsSameMusic::Name as i32);
472     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
473     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
474     tree_view.append_column(&column);
475 
476     let renderer = gtk::CellRendererText::new();
477     let column: gtk::TreeViewColumn = TreeViewColumn::new();
478     column.pack_start(&renderer, true);
479     column.set_title("Path");
480     column.set_resizable(true);
481     column.set_min_width(50);
482     column.add_attribute(&renderer, "text", ColumnsSameMusic::Path as i32);
483     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
484     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
485     tree_view.append_column(&column);
486 
487     let renderer = gtk::CellRendererText::new();
488     let column: gtk::TreeViewColumn = TreeViewColumn::new();
489     column.pack_start(&renderer, true);
490     column.set_title("Title");
491     column.set_resizable(true);
492     column.set_min_width(50);
493     column.add_attribute(&renderer, "text", ColumnsSameMusic::Title as i32);
494     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
495     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
496     tree_view.append_column(&column);
497 
498     let renderer = gtk::CellRendererText::new();
499     let column: gtk::TreeViewColumn = TreeViewColumn::new();
500     column.pack_start(&renderer, true);
501     column.set_title("Artist");
502     column.set_resizable(true);
503     column.set_min_width(50);
504     column.add_attribute(&renderer, "text", ColumnsSameMusic::Artist as i32);
505     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
506     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
507     tree_view.append_column(&column);
508 
509     let renderer = gtk::CellRendererText::new();
510     let column: gtk::TreeViewColumn = TreeViewColumn::new();
511     column.pack_start(&renderer, true);
512     column.set_title("Album Title");
513     column.set_resizable(true);
514     column.set_min_width(50);
515     column.add_attribute(&renderer, "text", ColumnsSameMusic::AlbumTitle as i32);
516     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
517     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
518     tree_view.append_column(&column);
519 
520     let renderer = gtk::CellRendererText::new();
521     let column: gtk::TreeViewColumn = TreeViewColumn::new();
522     column.pack_start(&renderer, true);
523     column.set_title("Album Artist");
524     column.set_resizable(true);
525     column.set_min_width(50);
526     column.add_attribute(&renderer, "text", ColumnsSameMusic::AlbumArtist as i32);
527     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
528     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
529     tree_view.append_column(&column);
530 
531     let renderer = gtk::CellRendererText::new();
532     let column: gtk::TreeViewColumn = TreeViewColumn::new();
533     column.pack_start(&renderer, true);
534     column.set_title("Year");
535     column.set_resizable(true);
536     column.set_min_width(50);
537     column.add_attribute(&renderer, "text", ColumnsSameMusic::Year as i32);
538     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
539     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
540     tree_view.append_column(&column);
541 
542     let renderer = gtk::CellRendererText::new();
543     let column: gtk::TreeViewColumn = TreeViewColumn::new();
544     column.pack_start(&renderer, true);
545     column.set_title("Modification Date");
546     column.set_resizable(true);
547     column.set_min_width(50);
548     column.add_attribute(&renderer, "text", ColumnsSameMusic::Modification as i32);
549     column.add_attribute(&renderer, "background", ColumnsSameMusic::Color as i32);
550     column.add_attribute(&renderer, "foreground", ColumnsSameMusic::TextColor as i32);
551     tree_view.append_column(&column);
552 
553     tree_view.set_vexpand(true);
554 }
555 
create_tree_view_invalid_symlinks(tree_view: &mut gtk::TreeView)556 pub fn create_tree_view_invalid_symlinks(tree_view: &mut gtk::TreeView) {
557     let model = get_list_store(tree_view);
558 
559     let renderer = gtk::CellRendererToggle::new();
560     renderer.connect_toggled(move |_r, path| {
561         let iter = model.iter(&path).unwrap();
562         let mut fixed = model
563             .value(&iter, ColumnsInvalidSymlinks::ActiveSelectButton as i32)
564             .get::<bool>()
565             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
566         fixed = !fixed;
567         model.set_value(&iter, ColumnsInvalidSymlinks::ActiveSelectButton as u32, &fixed.to_value());
568     });
569     let column = gtk::TreeViewColumn::new();
570     column.pack_start(&renderer, true);
571     column.set_resizable(false);
572     column.set_fixed_width(30);
573     column.add_attribute(&renderer, "active", ColumnsInvalidSymlinks::ActiveSelectButton as i32);
574     tree_view.append_column(&column);
575 
576     let renderer = gtk::CellRendererText::new();
577     let column: gtk::TreeViewColumn = TreeViewColumn::new();
578     column.pack_start(&renderer, true);
579     column.set_title("Symlink File Name");
580     column.set_resizable(true);
581     column.set_min_width(50);
582     column.add_attribute(&renderer, "text", ColumnsInvalidSymlinks::Name as i32);
583     tree_view.append_column(&column);
584 
585     let renderer = gtk::CellRendererText::new();
586     let column: gtk::TreeViewColumn = TreeViewColumn::new();
587     column.pack_start(&renderer, true);
588     column.set_title("Symlink Folder");
589     column.set_resizable(true);
590     column.set_min_width(50);
591     column.add_attribute(&renderer, "text", ColumnsInvalidSymlinks::Path as i32);
592     tree_view.append_column(&column);
593 
594     let renderer = gtk::CellRendererText::new();
595     let column: gtk::TreeViewColumn = TreeViewColumn::new();
596     column.pack_start(&renderer, true);
597     column.set_title("Destination Path");
598     column.set_resizable(true);
599     column.set_min_width(50);
600     column.add_attribute(&renderer, "text", ColumnsInvalidSymlinks::DestinationPath as i32);
601     tree_view.append_column(&column);
602 
603     let renderer = gtk::CellRendererText::new();
604     let column: gtk::TreeViewColumn = TreeViewColumn::new();
605     column.pack_start(&renderer, true);
606     column.set_title("Type of Error");
607     column.set_resizable(true);
608     column.set_min_width(50);
609     column.add_attribute(&renderer, "text", ColumnsInvalidSymlinks::TypeOfError as i32);
610     tree_view.append_column(&column);
611 
612     let renderer = gtk::CellRendererText::new();
613     let column: gtk::TreeViewColumn = TreeViewColumn::new();
614     column.pack_start(&renderer, true);
615     column.set_title("Modification Date");
616     column.set_resizable(true);
617     column.set_min_width(50);
618     column.add_attribute(&renderer, "text", ColumnsInvalidSymlinks::Modification as i32);
619     tree_view.append_column(&column);
620 
621     tree_view.set_vexpand(true);
622 }
623 
create_tree_view_broken_files(tree_view: &mut gtk::TreeView)624 pub fn create_tree_view_broken_files(tree_view: &mut gtk::TreeView) {
625     let model = get_list_store(tree_view);
626 
627     let renderer = gtk::CellRendererToggle::new();
628     renderer.connect_toggled(move |_r, path| {
629         let iter = model.iter(&path).unwrap();
630         let mut fixed = model
631             .value(&iter, ColumnsBrokenFiles::ActiveSelectButton as i32)
632             .get::<bool>()
633             .unwrap_or_else(|err| panic!("ListStore value missing at path {}: {}", path, err));
634         fixed = !fixed;
635         model.set_value(&iter, ColumnsBrokenFiles::ActiveSelectButton as u32, &fixed.to_value());
636     });
637     let column = gtk::TreeViewColumn::new();
638     column.pack_start(&renderer, true);
639     column.set_resizable(false);
640     column.set_fixed_width(30);
641     column.add_attribute(&renderer, "active", ColumnsBrokenFiles::ActiveSelectButton as i32);
642     tree_view.append_column(&column);
643 
644     let renderer = gtk::CellRendererText::new();
645     let column: gtk::TreeViewColumn = TreeViewColumn::new();
646     column.pack_start(&renderer, true);
647     column.set_title("Name");
648     column.set_resizable(true);
649     column.set_min_width(50);
650     column.add_attribute(&renderer, "text", ColumnsBrokenFiles::Name as i32);
651     tree_view.append_column(&column);
652 
653     let renderer = gtk::CellRendererText::new();
654     let column: gtk::TreeViewColumn = TreeViewColumn::new();
655     column.pack_start(&renderer, true);
656     column.set_title("Path");
657     column.set_resizable(true);
658     column.set_min_width(50);
659     column.add_attribute(&renderer, "text", ColumnsBrokenFiles::Path as i32);
660     tree_view.append_column(&column);
661 
662     let renderer = gtk::CellRendererText::new();
663     let column: gtk::TreeViewColumn = TreeViewColumn::new();
664     column.pack_start(&renderer, true);
665     column.set_title("ErrorType");
666     column.set_resizable(true);
667     column.set_min_width(50);
668     column.add_attribute(&renderer, "text", ColumnsBrokenFiles::ErrorType as i32);
669     tree_view.append_column(&column);
670 
671     let renderer = gtk::CellRendererText::new();
672     let column: gtk::TreeViewColumn = TreeViewColumn::new();
673     column.pack_start(&renderer, true);
674     column.set_title("Modification Date");
675     column.set_resizable(true);
676     column.set_min_width(50);
677     column.add_attribute(&renderer, "text", ColumnsBrokenFiles::Modification as i32);
678     tree_view.append_column(&column);
679 
680     tree_view.set_vexpand(true);
681 }
682