2023-05-07 18:54:05 +00:00
|
|
|
use std::path::PathBuf;
|
2021-11-27 19:49:20 +00:00
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::thread;
|
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
use crossbeam_channel::{Receiver, Sender};
|
2023-10-10 18:54:41 +00:00
|
|
|
use fun_time::fun_time;
|
2023-12-03 11:06:42 +00:00
|
|
|
use glib::Sender as glibSender;
|
2022-05-22 08:59:09 +00:00
|
|
|
use gtk4::prelude::*;
|
2023-05-07 18:54:05 +00:00
|
|
|
use gtk4::Grid;
|
2020-10-31 13:23:31 +00:00
|
|
|
|
2022-04-22 19:46:33 +00:00
|
|
|
use czkawka_core::bad_extensions::BadExtensions;
|
2020-10-31 13:23:31 +00:00
|
|
|
use czkawka_core::big_file::BigFile;
|
2022-06-10 16:58:53 +00:00
|
|
|
use czkawka_core::broken_files::{BrokenFiles, CheckedTypes};
|
2023-12-03 11:06:42 +00:00
|
|
|
use czkawka_core::common::DEFAULT_THREAD_SIZE;
|
2023-05-07 18:54:05 +00:00
|
|
|
use czkawka_core::common_dir_traversal::{CheckingMethod, ProgressData};
|
2023-10-05 06:06:47 +00:00
|
|
|
use czkawka_core::common_tool::CommonData;
|
2021-12-13 18:13:53 +00:00
|
|
|
use czkawka_core::duplicate::DuplicateFinder;
|
2020-10-31 13:23:31 +00:00
|
|
|
use czkawka_core::empty_files::EmptyFiles;
|
|
|
|
use czkawka_core::empty_folder::EmptyFolder;
|
2020-12-21 15:09:39 +00:00
|
|
|
use czkawka_core::invalid_symlinks::InvalidSymlinks;
|
2020-11-02 20:56:07 +00:00
|
|
|
use czkawka_core::same_music::{MusicSimilarity, SameMusic};
|
2020-11-07 15:26:40 +00:00
|
|
|
use czkawka_core::similar_images::SimilarImages;
|
2021-11-23 10:10:24 +00:00
|
|
|
use czkawka_core::similar_videos::SimilarVideos;
|
2020-10-31 13:23:31 +00:00
|
|
|
use czkawka_core::temporary::Temporary;
|
|
|
|
|
2022-01-13 14:58:33 +00:00
|
|
|
use crate::gui_structs::gui_data::GuiData;
|
2021-12-21 17:44:20 +00:00
|
|
|
use crate::help_combo_box::{
|
2023-05-07 18:54:05 +00:00
|
|
|
AUDIO_TYPE_CHECK_METHOD_COMBO_BOX, BIG_FILES_CHECK_METHOD_COMBO_BOX, DUPLICATES_CHECK_METHOD_COMBO_BOX, DUPLICATES_HASH_TYPE_COMBO_BOX, IMAGES_HASH_SIZE_COMBO_BOX,
|
|
|
|
IMAGES_HASH_TYPE_COMBO_BOX, IMAGES_RESIZE_ALGORITHM_COMBO_BOX,
|
2021-12-21 17:44:20 +00:00
|
|
|
};
|
2021-11-27 19:49:20 +00:00
|
|
|
use crate::help_functions::*;
|
|
|
|
use crate::notebook_enums::*;
|
2021-02-20 11:24:36 +00:00
|
|
|
use crate::taskbar_progress::tbp_flags::TBPF_NOPROGRESS;
|
2022-01-19 21:35:07 +00:00
|
|
|
use crate::{flg, DEFAULT_MAXIMAL_FILE_SIZE, DEFAULT_MINIMAL_CACHE_SIZE, DEFAULT_MINIMAL_FILE_SIZE};
|
2021-02-20 11:24:36 +00:00
|
|
|
|
2020-12-02 09:25:27 +00:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2023-12-03 11:06:42 +00:00
|
|
|
pub fn connect_button_search(gui_data: &GuiData, glib_stop_sender: glibSender<Message>, progress_sender: Sender<ProgressData>) {
|
2021-01-10 19:12:08 +00:00
|
|
|
let buttons_array = gui_data.bottom_buttons.buttons_array.clone();
|
2021-12-03 19:27:59 +00:00
|
|
|
let buttons_search_clone = gui_data.bottom_buttons.buttons_search.clone();
|
2021-01-25 17:23:42 +00:00
|
|
|
let grid_progress_stages = gui_data.progress_window.grid_progress_stages.clone();
|
2021-12-03 19:27:59 +00:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let notebook_main = gui_data.main_notebook.notebook_main.clone();
|
|
|
|
let notebook_upper = gui_data.upper_notebook.notebook_upper.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let stop_receiver = gui_data.stop_receiver.clone();
|
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
|
|
|
let text_view_errors = gui_data.text_view_errors.clone();
|
|
|
|
let tree_view_included_directories = gui_data.upper_notebook.tree_view_included_directories.clone();
|
|
|
|
let window_progress = gui_data.progress_window.window_progress.clone();
|
|
|
|
let entry_info = gui_data.entry_info.clone();
|
|
|
|
let button_settings = gui_data.header.button_settings.clone();
|
|
|
|
let button_app_info = gui_data.header.button_app_info.clone();
|
2020-11-02 20:56:07 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let gui_data = gui_data.clone();
|
2020-10-31 13:23:31 +00:00
|
|
|
buttons_search_clone.connect_clicked(move |_| {
|
2023-05-07 18:54:05 +00:00
|
|
|
let loaded_common_items = LoadedCommonItems::load_items(&gui_data);
|
|
|
|
|
2022-07-31 06:45:19 +00:00
|
|
|
// Check if user selected all referenced folders
|
|
|
|
let list_store_included_directories = get_list_store(&tree_view_included_directories);
|
|
|
|
if check_if_list_store_column_have_all_same_values(&list_store_included_directories, ColumnsIncludedDirectory::ReferenceButton as i32, true) {
|
|
|
|
entry_info.set_text(&flg!("selected_all_reference_folders"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let show_dialog = Arc::new(AtomicBool::new(true));
|
|
|
|
|
|
|
|
window_progress.set_title(Some(&flg!("window_progress_title")));
|
|
|
|
|
|
|
|
hide_all_buttons(&buttons_array);
|
|
|
|
|
|
|
|
notebook_main.set_sensitive(false);
|
|
|
|
notebook_upper.set_sensitive(false);
|
|
|
|
button_settings.set_sensitive(false);
|
|
|
|
button_app_info.set_sensitive(false);
|
|
|
|
|
|
|
|
entry_info.set_text(&flg!("searching_for_data"));
|
|
|
|
|
|
|
|
// Resets progress bars
|
|
|
|
progress_bar_all_stages.set_fraction(0 as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0 as f64);
|
|
|
|
|
|
|
|
reset_text_view(&text_view_errors);
|
|
|
|
|
|
|
|
let glib_stop_sender = glib_stop_sender.clone();
|
|
|
|
let stop_receiver = stop_receiver.clone();
|
|
|
|
// Consume any stale stop messages.
|
2023-10-05 06:06:47 +00:00
|
|
|
stop_receiver.try_iter().for_each(|()| ());
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
label_stage.show();
|
|
|
|
|
|
|
|
match to_notebook_main_enum(notebook_main.current_page().unwrap()) {
|
|
|
|
NotebookMainEnum::Duplicate => duplicate_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::EmptyFiles => empty_files_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::EmptyDirectories => empty_directories_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::BigFiles => big_files_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::Temporary => temporary_files_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::SimilarImages => similar_image_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::SimilarVideos => similar_video_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::SameMusic => same_music_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
&show_dialog,
|
|
|
|
),
|
|
|
|
NotebookMainEnum::Symlinks => bad_symlinks_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
NotebookMainEnum::BrokenFiles => broken_files_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
&show_dialog,
|
|
|
|
),
|
|
|
|
NotebookMainEnum::BadExtensions => bad_extensions_search(
|
|
|
|
&gui_data,
|
|
|
|
loaded_common_items,
|
|
|
|
stop_receiver,
|
|
|
|
glib_stop_sender,
|
|
|
|
&grid_progress_stages,
|
2023-05-10 19:27:41 +00:00
|
|
|
progress_sender.clone(),
|
2023-05-07 18:54:05 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
window_progress.set_default_size(1, 1);
|
|
|
|
|
|
|
|
// Show progress dialog
|
|
|
|
if show_dialog.load(Ordering::Relaxed) {
|
|
|
|
window_progress.show();
|
|
|
|
taskbar_state.borrow().show();
|
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_NOPROGRESS);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LoadedCommonItems {
|
|
|
|
included_directories: Vec<PathBuf>,
|
|
|
|
excluded_directories: Vec<PathBuf>,
|
|
|
|
reference_directories: Vec<PathBuf>,
|
|
|
|
recursive_search: bool,
|
|
|
|
excluded_items: Vec<String>,
|
|
|
|
allowed_extensions: String,
|
2024-01-20 12:47:44 +00:00
|
|
|
excluded_extensions: String,
|
2023-05-07 18:54:05 +00:00
|
|
|
hide_hard_links: bool,
|
|
|
|
use_cache: bool,
|
|
|
|
save_also_as_json: bool,
|
|
|
|
minimal_cache_file_size: u64,
|
|
|
|
minimal_file_size: u64,
|
|
|
|
maximal_file_size: u64,
|
|
|
|
ignore_other_filesystems: bool,
|
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
impl LoadedCommonItems {
|
|
|
|
fn load_items(gui_data: &GuiData) -> Self {
|
|
|
|
let check_button_settings_one_filesystem = gui_data.settings.check_button_settings_one_filesystem.clone();
|
|
|
|
let check_button_recursive = gui_data.upper_notebook.check_button_recursive.clone();
|
|
|
|
let check_button_settings_hide_hard_links = gui_data.settings.check_button_settings_hide_hard_links.clone();
|
|
|
|
let check_button_settings_use_cache = gui_data.settings.check_button_settings_use_cache.clone();
|
|
|
|
let entry_allowed_extensions = gui_data.upper_notebook.entry_allowed_extensions.clone();
|
2024-01-20 12:47:44 +00:00
|
|
|
let entry_excluded_extensions = gui_data.upper_notebook.entry_excluded_extensions.clone();
|
2023-05-07 18:54:05 +00:00
|
|
|
let entry_excluded_items = gui_data.upper_notebook.entry_excluded_items.clone();
|
|
|
|
let entry_general_maximal_size = gui_data.upper_notebook.entry_general_maximal_size.clone();
|
|
|
|
let entry_general_minimal_size = gui_data.upper_notebook.entry_general_minimal_size.clone();
|
|
|
|
let entry_settings_cache_file_minimal_size = gui_data.settings.entry_settings_cache_file_minimal_size.clone();
|
|
|
|
let tree_view_excluded_directories = gui_data.upper_notebook.tree_view_excluded_directories.clone();
|
|
|
|
let tree_view_included_directories = gui_data.upper_notebook.tree_view_included_directories.clone();
|
|
|
|
let check_button_settings_save_also_json = gui_data.settings.check_button_settings_save_also_json.clone();
|
|
|
|
|
2023-01-28 17:54:02 +00:00
|
|
|
let included_directories = get_path_buf_from_vector_of_strings(&get_string_from_list_store(&tree_view_included_directories, ColumnsIncludedDirectory::Path as i32, None));
|
|
|
|
let excluded_directories = get_path_buf_from_vector_of_strings(&get_string_from_list_store(&tree_view_excluded_directories, ColumnsExcludedDirectory::Path as i32, None));
|
|
|
|
let reference_directories = get_path_buf_from_vector_of_strings(&get_string_from_list_store(
|
2021-12-24 08:18:55 +00:00
|
|
|
&tree_view_included_directories,
|
|
|
|
ColumnsIncludedDirectory::Path as i32,
|
|
|
|
Some(ColumnsIncludedDirectory::ReferenceButton as i32),
|
|
|
|
));
|
2021-06-25 16:07:13 +00:00
|
|
|
let recursive_search = check_button_recursive.is_active();
|
2023-01-28 17:54:02 +00:00
|
|
|
let excluded_items = entry_excluded_items
|
|
|
|
.text()
|
|
|
|
.as_str()
|
|
|
|
.to_string()
|
|
|
|
.split(',')
|
|
|
|
.map(std::string::ToString::to_string)
|
|
|
|
.collect::<Vec<String>>();
|
2021-06-25 16:07:13 +00:00
|
|
|
let allowed_extensions = entry_allowed_extensions.text().as_str().to_string();
|
2024-01-20 12:47:44 +00:00
|
|
|
let excluded_extensions = entry_excluded_extensions.text().as_str().to_string();
|
2021-06-25 16:07:13 +00:00
|
|
|
let hide_hard_links = check_button_settings_hide_hard_links.is_active();
|
|
|
|
let use_cache = check_button_settings_use_cache.is_active();
|
2022-01-05 21:47:27 +00:00
|
|
|
let save_also_as_json = check_button_settings_save_also_json.is_active();
|
2022-01-07 15:45:08 +00:00
|
|
|
let minimal_cache_file_size = entry_settings_cache_file_minimal_size
|
|
|
|
.text()
|
|
|
|
.as_str()
|
|
|
|
.parse::<u64>()
|
|
|
|
.unwrap_or_else(|_| DEFAULT_MINIMAL_CACHE_SIZE.parse::<u64>().unwrap());
|
2020-10-31 13:23:31 +00:00
|
|
|
|
2022-01-07 15:45:08 +00:00
|
|
|
let minimal_file_size = entry_general_minimal_size
|
|
|
|
.text()
|
|
|
|
.as_str()
|
|
|
|
.parse::<u64>()
|
|
|
|
.unwrap_or_else(|_| DEFAULT_MINIMAL_FILE_SIZE.parse::<u64>().unwrap());
|
|
|
|
let maximal_file_size = entry_general_maximal_size
|
|
|
|
.text()
|
|
|
|
.as_str()
|
|
|
|
.parse::<u64>()
|
|
|
|
.unwrap_or_else(|_| DEFAULT_MAXIMAL_FILE_SIZE.parse::<u64>().unwrap());
|
2022-07-19 17:09:52 +00:00
|
|
|
let ignore_other_filesystems = check_button_settings_one_filesystem.is_active();
|
2020-12-22 19:04:16 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
LoadedCommonItems {
|
|
|
|
included_directories,
|
|
|
|
excluded_directories,
|
|
|
|
reference_directories,
|
|
|
|
recursive_search,
|
|
|
|
excluded_items,
|
|
|
|
allowed_extensions,
|
2024-01-20 12:47:44 +00:00
|
|
|
excluded_extensions,
|
2023-05-07 18:54:05 +00:00
|
|
|
hide_hard_links,
|
|
|
|
use_cache,
|
|
|
|
save_also_as_json,
|
|
|
|
minimal_cache_file_size,
|
|
|
|
minimal_file_size,
|
|
|
|
maximal_file_size,
|
|
|
|
ignore_other_filesystems,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn duplicate_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
2022-05-22 08:59:09 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let combo_box_duplicate_check_method = gui_data.main_notebook.combo_box_duplicate_check_method.clone();
|
|
|
|
let combo_box_duplicate_hash_type = gui_data.main_notebook.combo_box_duplicate_hash_type.clone();
|
|
|
|
let check_button_duplicates_use_prehash_cache = gui_data.settings.check_button_duplicates_use_prehash_cache.clone();
|
|
|
|
let check_button_duplicate_case_sensitive_name: gtk4::CheckButton = gui_data.main_notebook.check_button_duplicate_case_sensitive_name.clone();
|
|
|
|
let check_button_settings_duplicates_delete_outdated_cache = gui_data.settings.check_button_settings_duplicates_delete_outdated_cache.clone();
|
|
|
|
let entry_settings_prehash_cache_file_minimal_size = gui_data.settings.entry_settings_prehash_cache_file_minimal_size.clone();
|
|
|
|
let image_preview_duplicates = gui_data.main_notebook.image_preview_duplicates.clone();
|
|
|
|
let tree_view_duplicate_finder = gui_data.main_notebook.tree_view_duplicate_finder.clone();
|
2020-10-31 13:23:31 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
image_preview_duplicates.hide();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_duplicate_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
let check_method_index = combo_box_duplicate_check_method.active().unwrap() as usize;
|
|
|
|
let check_method = DUPLICATES_CHECK_METHOD_COMBO_BOX[check_method_index].check_method;
|
|
|
|
|
|
|
|
let hash_type_index = combo_box_duplicate_hash_type.active().unwrap() as usize;
|
|
|
|
let hash_type = DUPLICATES_HASH_TYPE_COMBO_BOX[hash_type_index].hash_type;
|
|
|
|
|
|
|
|
let use_prehash_cache = check_button_duplicates_use_prehash_cache.is_active();
|
|
|
|
let minimal_prehash_cache_file_size = entry_settings_prehash_cache_file_minimal_size.text().as_str().parse::<u64>().unwrap_or(0);
|
|
|
|
|
|
|
|
let case_sensitive_name_comparison = check_button_duplicate_case_sensitive_name.is_active();
|
|
|
|
|
|
|
|
let delete_outdated_cache = check_button_settings_duplicates_delete_outdated_cache.is_active();
|
|
|
|
|
|
|
|
// Find duplicates
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = DuplicateFinder::new();
|
|
|
|
|
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_minimal_cache_file_size(loaded_common_items.minimal_cache_file_size);
|
|
|
|
item.set_minimal_prehash_cache_file_size(minimal_prehash_cache_file_size);
|
|
|
|
item.set_check_method(check_method);
|
|
|
|
item.set_hash_type(hash_type);
|
|
|
|
item.set_ignore_hard_links(loaded_common_items.hide_hard_links);
|
|
|
|
item.set_use_prehash_cache(use_prehash_cache);
|
|
|
|
item.set_delete_outdated_cache(delete_outdated_cache);
|
|
|
|
item.set_case_sensitive_name_comparison(case_sensitive_name_comparison);
|
|
|
|
item.find_duplicates(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::Duplicates(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2020-10-31 13:23:31 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn empty_files_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.hide();
|
2020-10-31 13:23:31 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let tree_view_empty_files_finder = gui_data.main_notebook.tree_view_empty_files_finder.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_empty_files_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
// Find empty files
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = EmptyFiles::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.find_empty_files(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::EmptyFiles(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2020-12-02 09:25:27 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn empty_directories_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.hide();
|
2020-12-21 15:09:39 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let tree_view_empty_folder_finder = gui_data.main_notebook.tree_view_empty_folder_finder.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_empty_folder_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = EmptyFolder::new();
|
2024-01-19 21:56:58 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.find_empty_folders(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::EmptyFolders(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn big_files_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.hide();
|
2021-01-12 10:51:54 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let combo_box_big_files_mode = gui_data.main_notebook.combo_box_big_files_mode.clone();
|
|
|
|
let entry_big_files_number = gui_data.main_notebook.entry_big_files_number.clone();
|
|
|
|
let tree_view_big_files_finder = gui_data.main_notebook.tree_view_big_files_finder.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_big_files_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
let big_files_mode_index = combo_box_big_files_mode.active().unwrap() as usize;
|
|
|
|
let big_files_mode = BIG_FILES_CHECK_METHOD_COMBO_BOX[big_files_mode_index].check_method;
|
|
|
|
|
|
|
|
let numbers_of_files_to_check = entry_big_files_number.text().as_str().parse::<usize>().unwrap_or(50);
|
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = BigFile::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_number_of_files_to_check(numbers_of_files_to_check);
|
|
|
|
item.set_search_mode(big_files_mode);
|
|
|
|
item.find_big_files(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::BigFiles(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn temporary_files_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.hide();
|
2020-12-02 09:25:27 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
let tree_view_temporary_files_finder = gui_data.main_notebook.tree_view_temporary_files_finder.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_temporary_files_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = Temporary::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.find_temporary_files(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::Temporary(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn same_music_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
show_dialog: &Arc<AtomicBool>,
|
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
|
|
|
|
|
|
|
let check_button_music_artist: gtk4::CheckButton = gui_data.main_notebook.check_button_music_artist.clone();
|
|
|
|
let check_button_music_title: gtk4::CheckButton = gui_data.main_notebook.check_button_music_title.clone();
|
|
|
|
let check_button_music_year: gtk4::CheckButton = gui_data.main_notebook.check_button_music_year.clone();
|
|
|
|
let check_button_music_genre: gtk4::CheckButton = gui_data.main_notebook.check_button_music_genre.clone();
|
|
|
|
let check_button_music_length: gtk4::CheckButton = gui_data.main_notebook.check_button_music_length.clone();
|
|
|
|
let check_button_music_bitrate: gtk4::CheckButton = gui_data.main_notebook.check_button_music_bitrate.clone();
|
|
|
|
let tree_view_same_music_finder = gui_data.main_notebook.tree_view_same_music_finder.clone();
|
|
|
|
let combo_box_audio_check_type = gui_data.main_notebook.combo_box_audio_check_type.clone();
|
|
|
|
let check_button_music_approximate_comparison = gui_data.main_notebook.check_button_music_approximate_comparison.clone();
|
|
|
|
let scale_seconds_same_music = gui_data.main_notebook.scale_seconds_same_music.clone();
|
|
|
|
let scale_similarity_same_music = gui_data.main_notebook.scale_similarity_same_music.clone();
|
|
|
|
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_same_music_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
let approximate_comparison = check_button_music_approximate_comparison.is_active();
|
|
|
|
|
|
|
|
let mut music_similarity: MusicSimilarity = MusicSimilarity::NONE;
|
|
|
|
|
|
|
|
if check_button_music_title.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::TRACK_TITLE;
|
|
|
|
}
|
|
|
|
if check_button_music_artist.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::TRACK_ARTIST;
|
|
|
|
}
|
|
|
|
if check_button_music_year.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::YEAR;
|
|
|
|
}
|
|
|
|
if check_button_music_bitrate.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::BITRATE;
|
|
|
|
}
|
|
|
|
if check_button_music_genre.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::GENRE;
|
|
|
|
}
|
|
|
|
if check_button_music_length.is_active() {
|
|
|
|
music_similarity |= MusicSimilarity::LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
let check_method_index = combo_box_audio_check_type.active().unwrap() as usize;
|
|
|
|
let check_method = AUDIO_TYPE_CHECK_METHOD_COMBO_BOX[check_method_index].check_method;
|
|
|
|
|
|
|
|
let maximum_difference = scale_similarity_same_music.value();
|
|
|
|
let minimum_segment_duration = scale_seconds_same_music.value() as f32;
|
|
|
|
|
|
|
|
if music_similarity != MusicSimilarity::NONE || check_method == CheckingMethod::AudioContent {
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = SameMusic::new();
|
|
|
|
|
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_music_similarity(music_similarity);
|
|
|
|
item.set_maximum_difference(maximum_difference);
|
|
|
|
item.set_minimum_segment_duration(minimum_segment_duration);
|
|
|
|
item.set_check_type(check_method);
|
|
|
|
item.set_approximate_comparison(approximate_comparison);
|
|
|
|
item.find_same_music(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::SameMusic(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
} else {
|
|
|
|
let shared_buttons = gui_data.shared_buttons.clone();
|
|
|
|
let buttons_array = gui_data.bottom_buttons.buttons_array.clone();
|
|
|
|
let buttons_names = gui_data.bottom_buttons.buttons_names;
|
|
|
|
let entry_info = gui_data.entry_info.clone();
|
|
|
|
let notebook_main = gui_data.main_notebook.notebook_main.clone();
|
|
|
|
let notebook_upper = gui_data.upper_notebook.notebook_upper.clone();
|
|
|
|
let button_settings = gui_data.header.button_settings.clone();
|
|
|
|
let button_app_info = gui_data.header.button_app_info.clone();
|
|
|
|
|
|
|
|
set_buttons(
|
|
|
|
&mut *shared_buttons.borrow_mut().get_mut(&NotebookMainEnum::SameMusic).unwrap(),
|
|
|
|
&buttons_array,
|
|
|
|
&buttons_names,
|
|
|
|
);
|
|
|
|
entry_info.set_text(&flg!("search_not_choosing_any_music"));
|
|
|
|
show_dialog.store(false, Ordering::Relaxed);
|
|
|
|
|
|
|
|
notebook_main.set_sensitive(true);
|
|
|
|
notebook_upper.set_sensitive(true);
|
|
|
|
button_settings.set_sensitive(true);
|
|
|
|
button_app_info.set_sensitive(true);
|
|
|
|
}
|
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn broken_files_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
show_dialog: &Arc<AtomicBool>,
|
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
|
|
|
|
|
|
|
let check_button_broken_files_archive: gtk4::CheckButton = gui_data.main_notebook.check_button_broken_files_archive.clone();
|
|
|
|
let check_button_broken_files_pdf: gtk4::CheckButton = gui_data.main_notebook.check_button_broken_files_pdf.clone();
|
|
|
|
let check_button_broken_files_audio: gtk4::CheckButton = gui_data.main_notebook.check_button_broken_files_audio.clone();
|
|
|
|
let check_button_broken_files_image: gtk4::CheckButton = gui_data.main_notebook.check_button_broken_files_image.clone();
|
|
|
|
let tree_view_broken_files = gui_data.main_notebook.tree_view_broken_files.clone();
|
|
|
|
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_broken_files);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
let mut checked_types: CheckedTypes = CheckedTypes::NONE;
|
|
|
|
|
|
|
|
if check_button_broken_files_audio.is_active() {
|
|
|
|
checked_types |= CheckedTypes::AUDIO;
|
|
|
|
}
|
|
|
|
if check_button_broken_files_pdf.is_active() {
|
|
|
|
checked_types |= CheckedTypes::PDF;
|
|
|
|
}
|
|
|
|
if check_button_broken_files_image.is_active() {
|
|
|
|
checked_types |= CheckedTypes::IMAGE;
|
|
|
|
}
|
|
|
|
if check_button_broken_files_archive.is_active() {
|
|
|
|
checked_types |= CheckedTypes::ARCHIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if checked_types != CheckedTypes::NONE {
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = BrokenFiles::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_checked_types(checked_types);
|
|
|
|
item.find_broken_files(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::BrokenFiles(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
} else {
|
|
|
|
let shared_buttons = gui_data.shared_buttons.clone();
|
|
|
|
let buttons_array = gui_data.bottom_buttons.buttons_array.clone();
|
|
|
|
let buttons_names = gui_data.bottom_buttons.buttons_names;
|
|
|
|
let entry_info = gui_data.entry_info.clone();
|
|
|
|
let notebook_main = gui_data.main_notebook.notebook_main.clone();
|
|
|
|
let notebook_upper = gui_data.upper_notebook.notebook_upper.clone();
|
|
|
|
let button_settings = gui_data.header.button_settings.clone();
|
|
|
|
let button_app_info = gui_data.header.button_app_info.clone();
|
|
|
|
|
|
|
|
set_buttons(
|
|
|
|
&mut *shared_buttons.borrow_mut().get_mut(&NotebookMainEnum::BrokenFiles).unwrap(),
|
|
|
|
&buttons_array,
|
|
|
|
&buttons_names,
|
|
|
|
);
|
|
|
|
entry_info.set_text(&flg!("search_not_choosing_any_broken_files"));
|
|
|
|
show_dialog.store(false, Ordering::Relaxed);
|
|
|
|
|
|
|
|
notebook_main.set_sensitive(true);
|
|
|
|
notebook_upper.set_sensitive(true);
|
|
|
|
button_settings.set_sensitive(true);
|
|
|
|
button_app_info.set_sensitive(true);
|
|
|
|
}
|
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn similar_image_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
|
|
|
|
|
|
|
let combo_box_image_hash_size = gui_data.main_notebook.combo_box_image_hash_size.clone();
|
|
|
|
let combo_box_image_hash_algorithm = gui_data.main_notebook.combo_box_image_hash_algorithm.clone();
|
|
|
|
let combo_box_image_resize_algorithm = gui_data.main_notebook.combo_box_image_resize_algorithm.clone();
|
|
|
|
let check_button_image_ignore_same_size = gui_data.main_notebook.check_button_image_ignore_same_size.clone();
|
|
|
|
let check_button_settings_similar_images_delete_outdated_cache = gui_data.settings.check_button_settings_similar_images_delete_outdated_cache.clone();
|
|
|
|
let image_preview_similar_images = gui_data.main_notebook.image_preview_similar_images.clone();
|
|
|
|
let scale_similarity_similar_images = gui_data.main_notebook.scale_similarity_similar_images.clone();
|
|
|
|
let tree_view_similar_images_finder = gui_data.main_notebook.tree_view_similar_images_finder.clone();
|
|
|
|
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_similar_images_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
image_preview_similar_images.hide();
|
|
|
|
|
|
|
|
let hash_size_index = combo_box_image_hash_size.active().unwrap() as usize;
|
|
|
|
let hash_size = IMAGES_HASH_SIZE_COMBO_BOX[hash_size_index] as u8;
|
|
|
|
|
|
|
|
let image_filter_index = combo_box_image_resize_algorithm.active().unwrap() as usize;
|
|
|
|
let image_filter = IMAGES_RESIZE_ALGORITHM_COMBO_BOX[image_filter_index].filter;
|
|
|
|
|
|
|
|
let hash_alg_index = combo_box_image_hash_algorithm.active().unwrap() as usize;
|
|
|
|
let hash_alg = IMAGES_HASH_TYPE_COMBO_BOX[hash_alg_index].hash_alg;
|
|
|
|
|
|
|
|
let ignore_same_size = check_button_image_ignore_same_size.is_active();
|
|
|
|
|
|
|
|
let similarity = scale_similarity_similar_images.value() as u32;
|
|
|
|
|
|
|
|
let delete_outdated_cache = check_button_settings_similar_images_delete_outdated_cache.is_active();
|
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = SimilarImages::new();
|
|
|
|
|
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_similarity(similarity);
|
|
|
|
item.set_hash_alg(hash_alg);
|
|
|
|
item.set_hash_size(hash_size);
|
|
|
|
item.set_image_filter(image_filter);
|
|
|
|
item.set_delete_outdated_cache(delete_outdated_cache);
|
|
|
|
item.set_exclude_images_with_same_size(ignore_same_size);
|
|
|
|
item.find_similar_images(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::SimilarImages(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn similar_video_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
|
|
|
|
|
|
|
let check_button_video_ignore_same_size = gui_data.main_notebook.check_button_video_ignore_same_size.clone();
|
|
|
|
let check_button_settings_similar_videos_delete_outdated_cache = gui_data.settings.check_button_settings_similar_videos_delete_outdated_cache.clone();
|
|
|
|
let scale_similarity_similar_videos = gui_data.main_notebook.scale_similarity_similar_videos.clone();
|
|
|
|
let tree_view_similar_videos_finder = gui_data.main_notebook.tree_view_similar_videos_finder.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_similar_videos_finder);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
|
|
|
let tolerance = scale_similarity_similar_videos.value() as i32;
|
|
|
|
|
|
|
|
let delete_outdated_cache = check_button_settings_similar_videos_delete_outdated_cache.is_active();
|
|
|
|
|
|
|
|
let ignore_same_size = check_button_video_ignore_same_size.is_active();
|
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = SimilarVideos::new();
|
|
|
|
|
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.set_tolerance(tolerance);
|
|
|
|
item.set_delete_outdated_cache(delete_outdated_cache);
|
|
|
|
item.set_exclude_videos_with_same_size(ignore_same_size);
|
|
|
|
item.find_similar_videos(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::SimilarVideos(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn bad_symlinks_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.hide();
|
|
|
|
|
|
|
|
let tree_view_invalid_symlinks = gui_data.main_notebook.tree_view_invalid_symlinks.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_invalid_symlinks);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = InvalidSymlinks::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.find_invalid_links(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::InvalidSymlinks(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2023-05-07 18:54:05 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2023-05-07 18:54:05 +00:00
|
|
|
fn bad_extensions_search(
|
|
|
|
gui_data: &GuiData,
|
|
|
|
loaded_common_items: LoadedCommonItems,
|
|
|
|
stop_receiver: Receiver<()>,
|
2023-12-03 11:06:42 +00:00
|
|
|
glib_stop_sender: glibSender<Message>,
|
2023-05-07 18:54:05 +00:00
|
|
|
grid_progress_stages: &Grid,
|
2023-12-03 11:06:42 +00:00
|
|
|
progress_data_sender: Sender<ProgressData>,
|
2023-05-07 18:54:05 +00:00
|
|
|
) {
|
|
|
|
grid_progress_stages.show();
|
|
|
|
|
|
|
|
let tree_view_bad_extensions = gui_data.main_notebook.tree_view_bad_extensions.clone();
|
2023-10-05 06:06:47 +00:00
|
|
|
clean_tree_view(&tree_view_bad_extensions);
|
2023-05-07 18:54:05 +00:00
|
|
|
|
2023-12-03 11:06:42 +00:00
|
|
|
thread::Builder::new()
|
|
|
|
.stack_size(DEFAULT_THREAD_SIZE)
|
|
|
|
.spawn(move || {
|
2024-01-20 12:47:44 +00:00
|
|
|
let mut item = BadExtensions::new();
|
2023-12-03 11:06:42 +00:00
|
|
|
|
2024-01-20 12:47:44 +00:00
|
|
|
set_common_settings(&mut item, &loaded_common_items);
|
|
|
|
item.find_bad_extensions_files(Some(&stop_receiver), Some(&progress_data_sender));
|
|
|
|
glib_stop_sender.send(Message::BadExtensions(item)).unwrap();
|
2023-12-03 11:06:42 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2020-10-31 13:23:31 +00:00
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
|
2024-01-19 21:56:58 +00:00
|
|
|
fn set_common_settings<T>(component: &mut T, loaded_common_items: &LoadedCommonItems)
|
|
|
|
where
|
|
|
|
T: CommonData,
|
|
|
|
{
|
|
|
|
component.set_included_directory(loaded_common_items.included_directories.clone());
|
|
|
|
component.set_excluded_directory(loaded_common_items.excluded_directories.clone());
|
|
|
|
component.set_reference_directory(loaded_common_items.reference_directories.clone());
|
|
|
|
component.set_recursive_search(loaded_common_items.recursive_search);
|
|
|
|
component.set_allowed_extensions(loaded_common_items.allowed_extensions.clone());
|
2024-01-20 12:47:44 +00:00
|
|
|
component.set_excluded_extensions(loaded_common_items.excluded_extensions.clone());
|
2024-01-19 21:56:58 +00:00
|
|
|
component.set_excluded_items(loaded_common_items.excluded_items.clone());
|
|
|
|
component.set_exclude_other_filesystems(loaded_common_items.ignore_other_filesystems);
|
|
|
|
component.set_use_cache(loaded_common_items.use_cache);
|
|
|
|
component.set_save_also_as_json(loaded_common_items.save_also_as_json);
|
|
|
|
component.set_minimal_file_size(loaded_common_items.minimal_file_size);
|
|
|
|
component.set_maximal_file_size(loaded_common_items.maximal_file_size);
|
|
|
|
}
|
|
|
|
|
2023-10-14 15:48:57 +00:00
|
|
|
#[fun_time(message = "clean_tree_view", level = "debug")]
|
2023-10-05 06:06:47 +00:00
|
|
|
fn clean_tree_view(tree_view: >k4::TreeView) {
|
|
|
|
let list_store = get_list_store(tree_view);
|
2023-12-03 12:11:09 +00:00
|
|
|
let mut all_iters = Vec::new();
|
|
|
|
let first_iter = list_store.iter_first();
|
|
|
|
if let Some(first_iter) = first_iter {
|
|
|
|
loop {
|
|
|
|
all_iters.push(first_iter);
|
|
|
|
if !list_store.iter_next(&first_iter) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
all_iters.reverse();
|
|
|
|
for iter in all_iters {
|
|
|
|
list_store.remove(&iter);
|
|
|
|
}
|
2023-10-05 06:06:47 +00:00
|
|
|
}
|