Skip to content

Commit fa3dfc1

Browse files
committed
Add select for all modes
1 parent 3e61544 commit fa3dfc1

11 files changed

+663
-380
lines changed

czkawka_core/src/duplicate.rs

-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ impl DuplicateFinder {
213213
}
214214

215215
fn check_files_name(&mut self, stop_receiver: Option<&Receiver<()>>) -> bool {
216-
// TODO maybe add multithreading checking files
217216
let start_time: SystemTime = SystemTime::now();
218217
let mut folders_to_check: Vec<PathBuf> = Vec::with_capacity(1024 * 2); // This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
219218

@@ -351,7 +350,6 @@ impl DuplicateFinder {
351350
/// Read file length and puts it to different boxes(each for different lengths)
352351
/// If in box is only 1 result, then it is removed
353352
fn check_files_size(&mut self, stop_receiver: Option<&Receiver<()>>) -> bool {
354-
// TODO maybe add multithreading checking files
355353
let start_time: SystemTime = SystemTime::now();
356354
let mut folders_to_check: Vec<PathBuf> = Vec::with_capacity(1024 * 2); // This should be small enough too not see to big difference and big enough to store most of paths without needing to resize vector
357355

czkawka_gui/czkawka.glade

+57-8
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ Author: Rafał Mikrut
3232
<!-- interface-name Czkawka -->
3333
<!-- interface-description Czkawka is simple and fast app to find duplicates, empty folders etc. -->
3434
<!-- interface-authors Rafa\305\202 Mikrut -->
35-
<object class="GtkPopover" id="popover_select">
35+
<object class="GtkPopover" id="popover_select_duplicate">
3636
<property name="can_focus">False</property>
3737
<child>
3838
<object class="GtkBox">
3939
<property name="visible">True</property>
4040
<property name="can_focus">False</property>
4141
<property name="orientation">vertical</property>
4242
<child>
43-
<object class="GtkButton" id="buttons_popover_select_all">
43+
<object class="GtkButton" id="buttons_popover_duplicate_select_all">
4444
<property name="label" translatable="yes">Select All</property>
4545
<property name="visible">True</property>
4646
<property name="can_focus">True</property>
@@ -53,7 +53,7 @@ Author: Rafał Mikrut
5353
</packing>
5454
</child>
5555
<child>
56-
<object class="GtkButton" id="buttons_popover_unselect_all">
56+
<object class="GtkButton" id="buttons_popover_duplicate_unselect_all">
5757
<property name="label" translatable="yes">Unselect All</property>
5858
<property name="visible">True</property>
5959
<property name="can_focus">True</property>
@@ -66,7 +66,7 @@ Author: Rafał Mikrut
6666
</packing>
6767
</child>
6868
<child>
69-
<object class="GtkButton" id="buttons_popover_reverse">
69+
<object class="GtkButton" id="buttons_popover_duplicate_reverse">
7070
<property name="label" translatable="yes">Reverse Selection</property>
7171
<property name="visible">True</property>
7272
<property name="can_focus">True</property>
@@ -79,7 +79,7 @@ Author: Rafał Mikrut
7979
</packing>
8080
</child>
8181
<child>
82-
<object class="GtkButton" id="buttons_popover_select_all_except_oldest">
82+
<object class="GtkButton" id="buttons_popover_duplicate_select_all_except_oldest">
8383
<property name="label" translatable="yes">Select all except oldest</property>
8484
<property name="visible">True</property>
8585
<property name="can_focus">True</property>
@@ -92,7 +92,7 @@ Author: Rafał Mikrut
9292
</packing>
9393
</child>
9494
<child>
95-
<object class="GtkButton" id="buttons_popover_select_all_except_newest">
95+
<object class="GtkButton" id="buttons_popover_duplicate_select_all_except_newest">
9696
<property name="label" translatable="yes">Select all except newest</property>
9797
<property name="visible">True</property>
9898
<property name="can_focus">True</property>
@@ -105,7 +105,7 @@ Author: Rafał Mikrut
105105
</packing>
106106
</child>
107107
<child>
108-
<object class="GtkButton" id="buttons_popover_select_one_oldest">
108+
<object class="GtkButton" id="buttons_popover_duplicate_select_one_oldest">
109109
<property name="label" translatable="yes">Select one oldest</property>
110110
<property name="visible">True</property>
111111
<property name="can_focus">True</property>
@@ -118,7 +118,7 @@ Author: Rafał Mikrut
118118
</packing>
119119
</child>
120120
<child>
121-
<object class="GtkButton" id="buttons_popover_select_one_newest">
121+
<object class="GtkButton" id="buttons_popover_duplicate_select_one_newest">
122122
<property name="label" translatable="yes">Select one newest</property>
123123
<property name="visible">True</property>
124124
<property name="can_focus">True</property>
@@ -133,6 +133,55 @@ Author: Rafał Mikrut
133133
</object>
134134
</child>
135135
</object>
136+
<object class="GtkPopover" id="popover_select_simple_list">
137+
<property name="can_focus">False</property>
138+
<child>
139+
<object class="GtkBox">
140+
<property name="visible">True</property>
141+
<property name="can_focus">False</property>
142+
<property name="orientation">vertical</property>
143+
<child>
144+
<object class="GtkButton" id="buttons_popover_simple_list_select_all">
145+
<property name="label" translatable="yes">Select All</property>
146+
<property name="visible">True</property>
147+
<property name="can_focus">True</property>
148+
<property name="receives_default">True</property>
149+
</object>
150+
<packing>
151+
<property name="expand">False</property>
152+
<property name="fill">True</property>
153+
<property name="position">1</property>
154+
</packing>
155+
</child>
156+
<child>
157+
<object class="GtkButton" id="buttons_popover_simple_list_unselect_all">
158+
<property name="label" translatable="yes">Unselect All</property>
159+
<property name="visible">True</property>
160+
<property name="can_focus">True</property>
161+
<property name="receives_default">True</property>
162+
</object>
163+
<packing>
164+
<property name="expand">False</property>
165+
<property name="fill">True</property>
166+
<property name="position">2</property>
167+
</packing>
168+
</child>
169+
<child>
170+
<object class="GtkButton" id="buttons_popover_simple_list_reverse">
171+
<property name="label" translatable="yes">Reverse Selection</property>
172+
<property name="visible">True</property>
173+
<property name="can_focus">True</property>
174+
<property name="receives_default">True</property>
175+
</object>
176+
<packing>
177+
<property name="expand">False</property>
178+
<property name="fill">True</property>
179+
<property name="position">3</property>
180+
</packing>
181+
</child>
182+
</object>
183+
</child>
184+
</object>
136185
<object class="GtkWindow" id="window_main">
137186
<property name="can_focus">False</property>
138187
<property name="default_width">1100</property>

czkawka_gui/src/connect_button_delete.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ fn basic_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, col
225225

226226
text_view_errors.get_buffer().unwrap().set_text(messages.as_str());
227227
selection.unselect_all();
228-
} // TODO, will replace simple remove of things
228+
}
229229

230-
// Remove all ocurences - remove every element which have same path and name as even non selected ones
230+
// Remove all occurrences - remove every element which have same path and name as even non selected ones
231231
//
232-
fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, column_path: i32, column_color: i32, gui_data: &GuiData, remove_all_occurences: bool, header_can_have_one_child: bool) {
232+
fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, column_path: i32, column_color: i32, gui_data: &GuiData, remove_all_occurrences: bool, header_can_have_one_child: bool) {
233233
let text_view_errors = gui_data.text_view_errors.clone();
234234

235235
let tree_view = scrolled_window.get_children().get(0).unwrap().clone().downcast::<gtk::TreeView>().unwrap();
@@ -248,12 +248,12 @@ fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, colu
248248
let mut vec_path_to_delete: Vec<(String, String)> = Vec::new();
249249
let mut map_with_path_to_delete: BTreeMap<String, Vec<String>> = Default::default(); // BTreeMap<Path,Vec<FileName>>
250250

251-
// Save to variable paths of files, and remove it when not removing all ocureences.
251+
// Save to variable paths of files, and remove it when not removing all occurrences.
252252
for tree_path in selection_rows.iter().rev() {
253253
let file_name = tree_model.get_value(&tree_model.get_iter(tree_path).unwrap(), column_file_name).get::<String>().unwrap().unwrap();
254254
let path = tree_model.get_value(&tree_model.get_iter(tree_path).unwrap(), column_path).get::<String>().unwrap().unwrap();
255255

256-
if !remove_all_occurences {
256+
if !remove_all_occurrences {
257257
list_store.remove(&list_store.get_iter(tree_path).unwrap());
258258
}
259259
map_with_path_to_delete.entry(path.clone()).or_insert_with(Vec::new);
@@ -277,7 +277,7 @@ fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, colu
277277
}
278278
}
279279

280-
if remove_all_occurences {
280+
if remove_all_occurrences {
281281
// Must be deleted from end to start, because when deleting entries, TreePath(and also TreeIter) will points to invalid data
282282
for path_to_delete in vec_path_to_delete {
283283
let mut vec_tree_path_to_delete: Vec<gtk::TreePath> = Vec::new();
@@ -286,7 +286,7 @@ fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, colu
286286
Some(t) => t,
287287
None => break,
288288
};
289-
let mut take_child_mode = false; // When original image is searched one, we must remove all occurences of its children
289+
let mut take_child_mode = false; // When original image is searched one, we must remove all occurrences of its children
290290
let mut prepared_for_delete;
291291
loop {
292292
prepared_for_delete = false;

czkawka_gui/src/connect_button_select.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ pub fn connect_button_select(gui_data: &GuiData) {
66
let notebook_main_children_names = gui_data.notebook_main_children_names.clone();
77
let notebook_main = gui_data.notebook_main.clone();
88
let buttons_select_clone = gui_data.buttons_select.clone();
9-
let popover_select = gui_data.popover_select.clone();
9+
let popover_select_duplicate = gui_data.popover_select_duplicate.clone();
10+
let popover_select_simple_list = gui_data.popover_select_simple_list.clone();
1011
let buttons_select = gui_data.buttons_select.clone();
1112
buttons_select_clone.connect_clicked(move |_| match notebook_main_children_names.get(notebook_main.get_current_page().unwrap() as usize).unwrap().as_str() {
12-
"notebook_main_duplicate_finder_label" => {
13-
// Only popup popup
14-
popover_select.set_relative_to(Some(&buttons_select));
15-
popover_select.popup();
13+
"notebook_main_duplicate_finder_label" | "notebook_main_same_music_finder" | "notebook_main_similar_images_finder_label" => {
14+
popover_select_duplicate.set_relative_to(Some(&buttons_select));
15+
popover_select_duplicate.popup();
16+
}
17+
"scrolled_window_main_empty_folder_finder" | "scrolled_window_main_empty_files_finder" | "scrolled_window_main_temporary_files_finder" | "notebook_big_main_file_finder" | "notebook_main_zeroed_files_finder" => {
18+
popover_select_simple_list.set_relative_to(Some(&buttons_select));
19+
popover_select_simple_list.popup();
1620
}
17-
// TODO add for all basic selection popup
1821
e => panic!("Not existent {}", e),
1922
});
2023
}

0 commit comments

Comments
 (0)