2021-11-28 08:49:20 +13:00
|
|
|
use futures::StreamExt;
|
|
|
|
use gtk::prelude::*;
|
2020-12-02 22:25:27 +13:00
|
|
|
|
2022-01-06 04:43:26 +13:00
|
|
|
use czkawka_core::{big_file, broken_files, common_dir_traversal, similar_images, similar_videos, temporary};
|
2020-12-02 22:25:27 +13:00
|
|
|
|
2022-01-20 10:35:07 +13:00
|
|
|
use crate::flg;
|
2022-01-14 03:58:33 +13:00
|
|
|
use crate::gui_structs::gui_data::GuiData;
|
2022-01-20 10:35:07 +13:00
|
|
|
use crate::localizer_core::generate_translation_hashmap;
|
2021-11-28 08:49:20 +13:00
|
|
|
use crate::taskbar_progress::tbp_flags::TBPF_INDETERMINATE;
|
2020-12-02 22:25:27 +13:00
|
|
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
pub fn connect_progress_window(
|
|
|
|
gui_data: &GuiData,
|
2022-01-02 09:07:20 +13:00
|
|
|
mut futures_receiver_duplicate_files: futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
|
|
|
mut futures_receiver_empty_files: futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2022-01-04 06:13:07 +13:00
|
|
|
mut futures_receiver_empty_folder: futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-04-14 18:23:59 +12:00
|
|
|
mut futures_receiver_big_files: futures::channel::mpsc::UnboundedReceiver<big_file::ProgressData>,
|
2022-01-06 04:43:26 +13:00
|
|
|
mut futures_receiver_same_music: futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-04-14 18:23:59 +12:00
|
|
|
mut futures_receiver_similar_images: futures::channel::mpsc::UnboundedReceiver<similar_images::ProgressData>,
|
2021-11-23 23:10:24 +13:00
|
|
|
mut futures_receiver_similar_videos: futures::channel::mpsc::UnboundedReceiver<similar_videos::ProgressData>,
|
2021-04-14 18:23:59 +12:00
|
|
|
mut futures_receiver_temporary: futures::channel::mpsc::UnboundedReceiver<temporary::ProgressData>,
|
2022-01-02 09:07:20 +13:00
|
|
|
mut futures_receiver_invalid_symlinks: futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-04-14 18:23:59 +12:00
|
|
|
mut futures_receiver_broken_files: futures::channel::mpsc::UnboundedReceiver<broken_files::ProgressData>,
|
2020-12-02 22:25:27 +13:00
|
|
|
) {
|
|
|
|
let main_context = glib::MainContext::default();
|
2021-06-26 04:07:13 +12:00
|
|
|
let _guard = main_context.acquire().unwrap();
|
2020-12-02 22:25:27 +13:00
|
|
|
|
|
|
|
{
|
|
|
|
// Duplicate Files
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
|
|
|
let grid_progress_stages = gui_data.progress_window.grid_progress_stages.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_duplicate_files.next().await {
|
|
|
|
match item.checking_method {
|
2022-01-02 09:07:20 +13:00
|
|
|
common_dir_traversal::CheckingMethod::Hash => {
|
2020-12-02 22:25:27 +13:00
|
|
|
label_stage.show();
|
|
|
|
match item.current_stage {
|
|
|
|
// Checking Size
|
|
|
|
0 => {
|
|
|
|
progress_bar_current_stage.hide();
|
|
|
|
// progress_bar_all_stages.hide();
|
|
|
|
progress_bar_all_stages.set_fraction(0 as f64);
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_size",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
// Hash - first 1KB file
|
|
|
|
1 => {
|
|
|
|
progress_bar_current_stage.show();
|
|
|
|
// progress_bar_all_stages.show();
|
2022-01-02 09:07:20 +13:00
|
|
|
if item.entries_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64 + (item.entries_checked) as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.entries_checked) as f64 / item.entries_to_check as f64);
|
|
|
|
taskbar_state.borrow().set_progress_value(
|
|
|
|
(item.entries_to_check + item.entries_checked) as u64,
|
|
|
|
item.entries_to_check as u64 * (item.max_stage + 1) as u64,
|
|
|
|
);
|
2020-12-08 03:28:03 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(1, 1 + item.max_stage as u64);
|
2020-12-08 03:28:03 +13:00
|
|
|
}
|
2021-12-20 02:45:10 +13:00
|
|
|
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_analyzed_partial_hash",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_checked", item.entries_checked.to_string()), ("all_files", item.entries_to_check.to_string())])
|
2021-12-20 02:45:10 +13:00
|
|
|
));
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
2021-12-12 04:16:14 +13:00
|
|
|
// Hash - normal hash
|
2020-12-02 22:25:27 +13:00
|
|
|
2 => {
|
2022-01-02 09:07:20 +13:00
|
|
|
if item.entries_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((2f64 + (item.entries_checked) as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.entries_checked) as f64 / item.entries_to_check as f64);
|
2021-12-22 06:44:20 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(
|
2022-01-02 09:07:20 +13:00
|
|
|
(2 * item.entries_to_check + item.entries_checked) as u64,
|
|
|
|
item.entries_to_check as u64 * (item.max_stage + 1) as u64,
|
2021-12-22 06:44:20 +13:00
|
|
|
);
|
2020-12-08 03:28:03 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((2f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(2, 1 + item.max_stage as u64);
|
2020-12-08 03:28:03 +13:00
|
|
|
}
|
2021-02-04 08:23:19 +13:00
|
|
|
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_analyzed_full_hash",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_checked", item.entries_checked.to_string()), ("all_files", item.entries_to_check.to_string())])
|
2021-12-20 02:45:10 +13:00
|
|
|
));
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!("Not available current_stage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-02 09:07:20 +13:00
|
|
|
common_dir_traversal::CheckingMethod::Name => {
|
2020-12-02 22:25:27 +13:00
|
|
|
label_stage.show();
|
|
|
|
grid_progress_stages.hide();
|
|
|
|
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_name",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
2022-01-02 09:07:20 +13:00
|
|
|
common_dir_traversal::CheckingMethod::Size => {
|
2020-12-02 22:25:27 +13:00
|
|
|
label_stage.show();
|
|
|
|
grid_progress_stages.hide();
|
|
|
|
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_size",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
2022-01-02 09:07:20 +13:00
|
|
|
common_dir_traversal::CheckingMethod::None => {
|
2020-12-02 22:25:27 +13:00
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Empty Files
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_empty_files.next().await {
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Empty Folder
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_empty_folder.next().await {
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_empty_folders",
|
2022-01-04 06:13:07 +13:00
|
|
|
generate_translation_hashmap(vec![("folder_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Big Files
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_big_files.next().await {
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
|
|
|
generate_translation_hashmap(vec![("file_number", item.files_checked.to_string())])
|
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Same Music
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_same_music.next().await {
|
|
|
|
match item.current_stage {
|
|
|
|
0 => {
|
|
|
|
progress_bar_current_stage.hide();
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
2022-01-06 04:43:26 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
1 => {
|
|
|
|
progress_bar_current_stage.show();
|
2022-01-06 04:43:26 +13:00
|
|
|
if item.entries_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64 + (item.entries_checked) as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.entries_checked) as f64 / item.entries_to_check as f64);
|
|
|
|
taskbar_state.borrow().set_progress_value(
|
|
|
|
(item.entries_to_check + item.entries_checked) as u64,
|
|
|
|
item.entries_to_check as u64 * (item.max_stage + 1) as u64,
|
|
|
|
);
|
2020-12-08 03:28:03 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(1, (item.max_stage + 1) as u64);
|
2020-12-08 03:28:03 +13:00
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_scanning_music_tags",
|
2022-01-06 04:43:26 +13:00
|
|
|
generate_translation_hashmap(vec![("file_checked", item.entries_checked.to_string()), ("all_files", item.entries_to_check.to_string())])
|
2021-12-20 02:45:10 +13:00
|
|
|
));
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
2 => {
|
2022-01-06 04:43:26 +13:00
|
|
|
if item.entries_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((2f64 + (item.entries_checked) as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.entries_checked) as f64 / item.entries_to_check as f64);
|
2021-12-22 06:44:20 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(
|
2022-01-06 04:43:26 +13:00
|
|
|
(2 * item.entries_to_check + item.entries_checked) as u64,
|
|
|
|
item.entries_to_check as u64 * (item.max_stage + 1) as u64,
|
2021-12-22 06:44:20 +13:00
|
|
|
);
|
2020-12-08 03:28:03 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((2f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(2, (item.max_stage + 1) as u64);
|
2020-12-08 03:28:03 +13:00
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_scanning_music_tags_end",
|
2022-01-06 04:43:26 +13:00
|
|
|
generate_translation_hashmap(vec![("file_checked", item.entries_checked.to_string()), ("all_files", item.entries_to_check.to_string())])
|
2021-12-20 02:45:10 +13:00
|
|
|
));
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// Similar Images
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_similar_images.next().await {
|
|
|
|
match item.current_stage {
|
|
|
|
0 => {
|
|
|
|
progress_bar_current_stage.hide();
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
|
|
|
generate_translation_hashmap(vec![("file_number", item.images_checked.to_string())])
|
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
1 => {
|
|
|
|
progress_bar_current_stage.show();
|
2020-12-08 03:28:03 +13:00
|
|
|
if item.images_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64 + (item.images_checked) as f64 / item.images_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.images_checked) as f64 / item.images_to_check as f64);
|
2021-12-22 06:44:20 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(
|
|
|
|
(item.images_to_check + item.images_checked) as u64,
|
|
|
|
item.images_to_check as u64 * (item.max_stage + 1) as u64,
|
|
|
|
);
|
2020-12-08 03:28:03 +13:00
|
|
|
} else {
|
2021-12-26 10:23:18 +13:00
|
|
|
progress_bar_all_stages.set_fraction((item.current_stage as f64) / (item.max_stage + 1) as f64);
|
2020-12-08 03:28:03 +13:00
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(1, (item.max_stage + 1) as u64);
|
2020-12-08 03:28:03 +13:00
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_scanning_image",
|
|
|
|
generate_translation_hashmap(vec![("file_checked", item.images_checked.to_string()), ("all_files", item.images_to_check.to_string())])
|
|
|
|
));
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
2021-12-26 10:23:18 +13:00
|
|
|
2 => {
|
|
|
|
progress_bar_current_stage.show();
|
|
|
|
if item.images_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((2f64 + (item.images_checked) as f64 / item.images_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.images_checked) as f64 / item.images_to_check as f64);
|
|
|
|
taskbar_state.borrow().set_progress_value(
|
|
|
|
(item.images_to_check + item.images_checked) as u64,
|
|
|
|
item.images_to_check as u64 * (item.max_stage + 1) as u64,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((item.current_stage as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
|
|
|
taskbar_state.borrow().set_progress_value(2, (item.max_stage + 1) as u64);
|
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-26 10:23:18 +13:00
|
|
|
"progress_comparing_image_hashes",
|
|
|
|
generate_translation_hashmap(vec![("file_checked", item.images_checked.to_string()), ("all_files", item.images_to_check.to_string())])
|
|
|
|
));
|
|
|
|
}
|
2020-12-02 22:25:27 +13:00
|
|
|
_ => {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
2021-11-23 23:10:24 +13:00
|
|
|
{
|
|
|
|
// Similar Videos
|
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_similar_videos.next().await {
|
|
|
|
match item.current_stage {
|
|
|
|
0 => {
|
|
|
|
progress_bar_current_stage.hide();
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
|
|
|
generate_translation_hashmap(vec![("file_number", item.videos_checked.to_string())])
|
|
|
|
));
|
2021-11-23 23:10:24 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
|
|
|
}
|
|
|
|
1 => {
|
|
|
|
progress_bar_current_stage.show();
|
|
|
|
if item.videos_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64 + (item.videos_checked) as f64 / item.videos_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.videos_checked) as f64 / item.videos_to_check as f64);
|
2021-12-22 06:44:20 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(
|
|
|
|
(item.videos_to_check + item.videos_checked) as u64,
|
|
|
|
item.videos_to_check as u64 * (item.max_stage + 1) as u64,
|
|
|
|
);
|
2021-11-23 23:10:24 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
|
|
|
taskbar_state.borrow().set_progress_value(1, (item.max_stage + 1) as u64);
|
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_scanning_video",
|
|
|
|
generate_translation_hashmap(vec![("file_checked", item.videos_checked.to_string()), ("all_files", item.videos_to_check.to_string())])
|
|
|
|
));
|
2021-11-23 23:10:24 +13:00
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
2020-12-02 22:25:27 +13:00
|
|
|
{
|
|
|
|
// Temporary
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-02 22:25:27 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_temporary.next().await {
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
|
|
|
generate_translation_hashmap(vec![("file_number", item.files_checked.to_string())])
|
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
2020-12-22 04:09:39 +13:00
|
|
|
{
|
|
|
|
// Invalid Symlinks
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-22 04:09:39 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_invalid_symlinks.next().await {
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
2022-01-02 09:07:20 +13:00
|
|
|
generate_translation_hashmap(vec![("file_number", item.entries_checked.to_string())])
|
2021-12-22 06:44:20 +13:00
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2020-12-22 04:09:39 +13:00
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
2021-01-13 08:06:12 +13:00
|
|
|
{
|
|
|
|
// Broken Files
|
2021-01-26 06:23:42 +13:00
|
|
|
let label_stage = gui_data.progress_window.label_stage.clone();
|
|
|
|
let progress_bar_current_stage = gui_data.progress_window.progress_bar_current_stage.clone();
|
|
|
|
let progress_bar_all_stages = gui_data.progress_window.progress_bar_all_stages.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2021-01-13 08:06:12 +13:00
|
|
|
let future = async move {
|
|
|
|
while let Some(item) = futures_receiver_broken_files.next().await {
|
|
|
|
match item.current_stage {
|
|
|
|
0 => {
|
|
|
|
progress_bar_current_stage.hide();
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-22 06:44:20 +13:00
|
|
|
"progress_scanning_general_file",
|
|
|
|
generate_translation_hashmap(vec![("file_number", item.files_checked.to_string())])
|
|
|
|
));
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_state(TBPF_INDETERMINATE);
|
2021-01-13 08:06:12 +13:00
|
|
|
}
|
|
|
|
1 => {
|
|
|
|
progress_bar_current_stage.show();
|
|
|
|
if item.files_to_check != 0 {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64 + (item.files_checked) as f64 / item.files_to_check as f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction((item.files_checked) as f64 / item.files_to_check as f64);
|
2021-12-22 06:44:20 +13:00
|
|
|
taskbar_state
|
|
|
|
.borrow()
|
|
|
|
.set_progress_value((item.files_to_check + item.files_checked) as u64, item.files_to_check as u64 * (item.max_stage + 1) as u64);
|
2021-01-13 08:06:12 +13:00
|
|
|
} else {
|
|
|
|
progress_bar_all_stages.set_fraction((1f64) / (item.max_stage + 1) as f64);
|
|
|
|
progress_bar_current_stage.set_fraction(0f64);
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow().set_progress_value(1, (item.max_stage + 1) as u64);
|
2021-01-13 08:06:12 +13:00
|
|
|
}
|
2022-01-20 10:35:07 +13:00
|
|
|
label_stage.set_text(&flg!(
|
2021-12-20 02:45:10 +13:00
|
|
|
"progress_scanning_broken_files",
|
|
|
|
generate_translation_hashmap(vec![("file_checked", item.files_checked.to_string()), ("all_files", item.files_to_check.to_string())])
|
|
|
|
));
|
2021-01-13 08:06:12 +13:00
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main_context.spawn_local(future);
|
|
|
|
}
|
2020-12-02 22:25:27 +13:00
|
|
|
}
|