Skip to content

Commit

Permalink
Add select for all modes
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Nov 9, 2020
1 parent 3e61544 commit fa3dfc1
Show file tree
Hide file tree
Showing 11 changed files with 663 additions and 380 deletions.
2 changes: 0 additions & 2 deletions czkawka_core/src/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ impl DuplicateFinder {
}

fn check_files_name(&mut self, stop_receiver: Option<&Receiver<()>>) -> bool {
// TODO maybe add multithreading checking files
let start_time: SystemTime = SystemTime::now();
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

Expand Down Expand Up @@ -351,7 +350,6 @@ impl DuplicateFinder {
/// Read file length and puts it to different boxes(each for different lengths)
/// If in box is only 1 result, then it is removed
fn check_files_size(&mut self, stop_receiver: Option<&Receiver<()>>) -> bool {
// TODO maybe add multithreading checking files
let start_time: SystemTime = SystemTime::now();
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

Expand Down
65 changes: 57 additions & 8 deletions czkawka_gui/czkawka.glade
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Author: Rafał Mikrut
<!-- interface-name Czkawka -->
<!-- interface-description Czkawka is simple and fast app to find duplicates, empty folders etc. -->
<!-- interface-authors Rafa\305\202 Mikrut -->
<object class="GtkPopover" id="popover_select">
<object class="GtkPopover" id="popover_select_duplicate">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="buttons_popover_select_all">
<object class="GtkButton" id="buttons_popover_duplicate_select_all">
<property name="label" translatable="yes">Select All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -53,7 +53,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_unselect_all">
<object class="GtkButton" id="buttons_popover_duplicate_unselect_all">
<property name="label" translatable="yes">Unselect All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -66,7 +66,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_reverse">
<object class="GtkButton" id="buttons_popover_duplicate_reverse">
<property name="label" translatable="yes">Reverse Selection</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -79,7 +79,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_select_all_except_oldest">
<object class="GtkButton" id="buttons_popover_duplicate_select_all_except_oldest">
<property name="label" translatable="yes">Select all except oldest</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -92,7 +92,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_select_all_except_newest">
<object class="GtkButton" id="buttons_popover_duplicate_select_all_except_newest">
<property name="label" translatable="yes">Select all except newest</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -105,7 +105,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_select_one_oldest">
<object class="GtkButton" id="buttons_popover_duplicate_select_one_oldest">
<property name="label" translatable="yes">Select one oldest</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -118,7 +118,7 @@ Author: Rafał Mikrut
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_select_one_newest">
<object class="GtkButton" id="buttons_popover_duplicate_select_one_newest">
<property name="label" translatable="yes">Select one newest</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -133,6 +133,55 @@ Author: Rafał Mikrut
</object>
</child>
</object>
<object class="GtkPopover" id="popover_select_simple_list">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton" id="buttons_popover_simple_list_select_all">
<property name="label" translatable="yes">Select All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_simple_list_unselect_all">
<property name="label" translatable="yes">Unselect All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="buttons_popover_simple_list_reverse">
<property name="label" translatable="yes">Reverse Selection</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="window_main">
<property name="can_focus">False</property>
<property name="default_width">1100</property>
Expand Down
14 changes: 7 additions & 7 deletions czkawka_gui/src/connect_button_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ fn basic_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, col

text_view_errors.get_buffer().unwrap().set_text(messages.as_str());
selection.unselect_all();
} // TODO, will replace simple remove of things
}

// Remove all ocurences - remove every element which have same path and name as even non selected ones
// Remove all occurrences - remove every element which have same path and name as even non selected ones
//
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) {
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) {
let text_view_errors = gui_data.text_view_errors.clone();

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

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

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

if remove_all_occurences {
if remove_all_occurrences {
// Must be deleted from end to start, because when deleting entries, TreePath(and also TreeIter) will points to invalid data
for path_to_delete in vec_path_to_delete {
let mut vec_tree_path_to_delete: Vec<gtk::TreePath> = Vec::new();
Expand All @@ -286,7 +286,7 @@ fn tree_remove(scrolled_window: gtk::ScrolledWindow, column_file_name: i32, colu
Some(t) => t,
None => break,
};
let mut take_child_mode = false; // When original image is searched one, we must remove all occurences of its children
let mut take_child_mode = false; // When original image is searched one, we must remove all occurrences of its children
let mut prepared_for_delete;
loop {
prepared_for_delete = false;
Expand Down
15 changes: 9 additions & 6 deletions czkawka_gui/src/connect_button_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ pub fn connect_button_select(gui_data: &GuiData) {
let notebook_main_children_names = gui_data.notebook_main_children_names.clone();
let notebook_main = gui_data.notebook_main.clone();
let buttons_select_clone = gui_data.buttons_select.clone();
let popover_select = gui_data.popover_select.clone();
let popover_select_duplicate = gui_data.popover_select_duplicate.clone();
let popover_select_simple_list = gui_data.popover_select_simple_list.clone();
let buttons_select = gui_data.buttons_select.clone();
buttons_select_clone.connect_clicked(move |_| match notebook_main_children_names.get(notebook_main.get_current_page().unwrap() as usize).unwrap().as_str() {
"notebook_main_duplicate_finder_label" => {
// Only popup popup
popover_select.set_relative_to(Some(&buttons_select));
popover_select.popup();
"notebook_main_duplicate_finder_label" | "notebook_main_same_music_finder" | "notebook_main_similar_images_finder_label" => {
popover_select_duplicate.set_relative_to(Some(&buttons_select));
popover_select_duplicate.popup();
}
"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" => {
popover_select_simple_list.set_relative_to(Some(&buttons_select));
popover_select_simple_list.popup();
}
// TODO add for all basic selection popup
e => panic!("Not existent {}", e),
});
}
Loading

0 comments on commit fa3dfc1

Please sign in to comment.