2020-12-14 04:35:27 +13:00
|
|
|
// Remove console window in Windows OS
|
|
|
|
#![windows_subsystem = "windows"]
|
2021-07-16 16:51:54 +12:00
|
|
|
#![allow(clippy::collapsible_else_if)]
|
2021-11-25 20:36:49 +13:00
|
|
|
#![allow(clippy::too_many_arguments)]
|
2022-01-11 00:19:28 +13:00
|
|
|
#![allow(clippy::type_complexity)]
|
2020-12-14 04:35:27 +13:00
|
|
|
|
2021-11-28 08:49:20 +13:00
|
|
|
use gtk::prelude::*;
|
|
|
|
|
|
|
|
use czkawka_core::*;
|
|
|
|
|
|
|
|
use crate::compute_results::*;
|
|
|
|
use crate::initialize_gui::*;
|
2021-12-19 11:45:37 +13:00
|
|
|
use crate::language_functions::LANGUAGES_ALL;
|
2021-11-28 08:49:20 +13:00
|
|
|
use crate::saving_loading::*;
|
|
|
|
use crate::tests::validate_notebook_data;
|
2022-01-14 03:58:33 +13:00
|
|
|
use connect_things::connect_about_buttons::*;
|
|
|
|
use connect_things::connect_button_compare::*;
|
|
|
|
use connect_things::connect_button_delete::*;
|
|
|
|
use connect_things::connect_button_hardlink::*;
|
|
|
|
use connect_things::connect_button_move::*;
|
|
|
|
use connect_things::connect_button_save::*;
|
|
|
|
use connect_things::connect_button_search::*;
|
|
|
|
use connect_things::connect_button_select::*;
|
|
|
|
use connect_things::connect_button_stop::*;
|
|
|
|
use connect_things::connect_change_language::*;
|
|
|
|
use connect_things::connect_duplicate_buttons::connect_duplicate_combo_box;
|
|
|
|
use connect_things::connect_header_buttons::*;
|
|
|
|
use connect_things::connect_notebook_tabs::*;
|
|
|
|
use connect_things::connect_popovers::*;
|
|
|
|
use connect_things::connect_progress_window::*;
|
|
|
|
use connect_things::connect_selection_of_directories::*;
|
|
|
|
use connect_things::connect_settings::*;
|
|
|
|
use connect_things::connect_show_hide_ui::*;
|
|
|
|
use connect_things::connect_similar_image_size_change::*;
|
|
|
|
use gui_structs::gui_data::*;
|
2021-11-28 08:49:20 +13:00
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
mod compute_results;
|
2022-01-14 03:58:33 +13:00
|
|
|
mod connect_things;
|
2020-10-16 04:51:47 +13:00
|
|
|
mod create_tree_view;
|
2022-01-14 03:58:33 +13:00
|
|
|
mod gui_structs;
|
2021-12-14 07:13:53 +13:00
|
|
|
mod help_combo_box;
|
2020-09-30 05:44:20 +13:00
|
|
|
mod help_functions;
|
2020-12-08 03:25:44 +13:00
|
|
|
mod initialize_gui;
|
2021-12-12 04:16:14 +13:00
|
|
|
mod language_functions;
|
2022-01-20 10:35:07 +13:00
|
|
|
mod localizer_gui;
|
2021-01-11 00:06:25 +13:00
|
|
|
mod notebook_enums;
|
2021-11-25 20:36:49 +13:00
|
|
|
mod opening_selecting_records;
|
2020-12-08 03:25:44 +13:00
|
|
|
mod saving_loading;
|
2021-02-21 00:24:36 +13:00
|
|
|
mod taskbar_progress;
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
mod taskbar_progress_dummy;
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
mod taskbar_progress_win;
|
2021-11-25 20:36:49 +13:00
|
|
|
mod tests;
|
2020-09-30 05:44:20 +13:00
|
|
|
|
2020-09-02 05:34:39 +12:00
|
|
|
fn main() {
|
2021-12-28 04:30:41 +13:00
|
|
|
let application = gtk::Application::builder().build();
|
2021-12-18 07:44:29 +13:00
|
|
|
application.connect_activate(move |application| {
|
2021-11-28 04:44:30 +13:00
|
|
|
let mut gui_data: GuiData = GuiData::new_with_application(application);
|
2020-09-23 22:17:19 +12:00
|
|
|
|
2021-11-28 04:44:30 +13:00
|
|
|
// Used for getting data from thread
|
|
|
|
let (glib_stop_sender, glib_stop_receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
2020-09-23 22:17:19 +12:00
|
|
|
|
2021-11-28 04:44:30 +13:00
|
|
|
// Futures progress report
|
2021-12-22 06:44:20 +13:00
|
|
|
let (futures_sender_duplicate_files, futures_receiver_duplicate_files): (
|
2022-01-02 09:07:20 +13:00
|
|
|
futures::channel::mpsc::UnboundedSender<common_dir_traversal::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-12-22 06:44:20 +13:00
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_empty_files, futures_receiver_empty_files): (
|
2022-01-02 09:07:20 +13:00
|
|
|
futures::channel::mpsc::UnboundedSender<common_dir_traversal::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-12-22 06:44:20 +13:00
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_empty_folder, futures_receiver_empty_folder): (
|
2022-01-04 06:13:07 +13:00
|
|
|
futures::channel::mpsc::UnboundedSender<common_dir_traversal::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-12-22 06:44:20 +13:00
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_big_file, futures_receiver_big_file): (
|
|
|
|
futures::channel::mpsc::UnboundedSender<big_file::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<big_file::ProgressData>,
|
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_same_music, futures_receiver_same_music): (
|
2022-01-06 04:43:26 +13:00
|
|
|
futures::channel::mpsc::UnboundedSender<common_dir_traversal::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-12-22 06:44:20 +13:00
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_similar_images, futures_receiver_similar_images): (
|
|
|
|
futures::channel::mpsc::UnboundedSender<similar_images::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<similar_images::ProgressData>,
|
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_similar_videos, futures_receiver_similar_videos): (
|
|
|
|
futures::channel::mpsc::UnboundedSender<similar_videos::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<similar_videos::ProgressData>,
|
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_temporary, futures_receiver_temporary): (
|
|
|
|
futures::channel::mpsc::UnboundedSender<temporary::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<temporary::ProgressData>,
|
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_invalid_symlinks, futures_receiver_invalid_symlinks): (
|
2022-01-02 09:07:20 +13:00
|
|
|
futures::channel::mpsc::UnboundedSender<common_dir_traversal::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<common_dir_traversal::ProgressData>,
|
2021-12-22 06:44:20 +13:00
|
|
|
) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_broken_files, futures_receiver_broken_files): (
|
|
|
|
futures::channel::mpsc::UnboundedSender<broken_files::ProgressData>,
|
|
|
|
futures::channel::mpsc::UnboundedReceiver<broken_files::ProgressData>,
|
|
|
|
) = futures::channel::mpsc::unbounded();
|
2020-09-05 07:12:18 +12:00
|
|
|
|
2021-11-28 04:44:30 +13:00
|
|
|
initialize_gui(&mut gui_data);
|
|
|
|
validate_notebook_data(&gui_data); // Must be run after initialization of gui, to check if everything was properly setup
|
2022-01-08 04:45:08 +13:00
|
|
|
reset_configuration(false, &gui_data.upper_notebook, &gui_data.main_notebook, &gui_data.settings, &gui_data.text_view_errors); // Fallback for invalid loading setting project
|
2021-12-19 11:45:37 +13:00
|
|
|
load_system_language(&gui_data); // Check for default system language, must be loaded after initializing GUI and before loading settings from file
|
2021-12-22 06:44:20 +13:00
|
|
|
load_configuration(
|
|
|
|
false,
|
|
|
|
&gui_data.upper_notebook,
|
2022-01-08 04:45:08 +13:00
|
|
|
&gui_data.main_notebook,
|
2021-12-22 06:44:20 +13:00
|
|
|
&gui_data.settings,
|
|
|
|
&gui_data.text_view_errors,
|
|
|
|
&gui_data.scrolled_window_errors,
|
|
|
|
);
|
2020-10-10 22:15:20 +13:00
|
|
|
|
2022-01-14 18:34:43 +13:00
|
|
|
// Needs to run when entire GUI is initialized
|
2021-12-12 04:16:14 +13:00
|
|
|
connect_change_language(&gui_data);
|
|
|
|
|
2021-11-28 04:44:30 +13:00
|
|
|
connect_button_delete(&gui_data);
|
|
|
|
connect_button_save(&gui_data);
|
|
|
|
connect_button_search(
|
|
|
|
&gui_data,
|
|
|
|
glib_stop_sender,
|
|
|
|
futures_sender_duplicate_files,
|
|
|
|
futures_sender_empty_files,
|
|
|
|
futures_sender_empty_folder,
|
|
|
|
futures_sender_big_file,
|
|
|
|
futures_sender_same_music,
|
|
|
|
futures_sender_similar_images,
|
|
|
|
futures_sender_similar_videos,
|
|
|
|
futures_sender_temporary,
|
|
|
|
futures_sender_invalid_symlinks,
|
|
|
|
futures_sender_broken_files,
|
|
|
|
);
|
|
|
|
connect_button_select(&gui_data);
|
|
|
|
connect_button_stop(&gui_data);
|
|
|
|
connect_button_hardlink_symlink(&gui_data);
|
|
|
|
connect_button_move(&gui_data);
|
2022-01-11 00:19:28 +13:00
|
|
|
connect_button_compare(&gui_data);
|
|
|
|
|
2021-12-14 07:13:53 +13:00
|
|
|
connect_duplicate_combo_box(&gui_data);
|
2021-11-28 04:44:30 +13:00
|
|
|
connect_notebook_tabs(&gui_data);
|
|
|
|
connect_selection_of_directories(&gui_data);
|
|
|
|
connect_popovers(&gui_data);
|
|
|
|
connect_compute_results(&gui_data, glib_stop_receiver);
|
|
|
|
connect_progress_window(
|
|
|
|
&gui_data,
|
|
|
|
futures_receiver_duplicate_files,
|
|
|
|
futures_receiver_empty_files,
|
|
|
|
futures_receiver_empty_folder,
|
|
|
|
futures_receiver_big_file,
|
|
|
|
futures_receiver_same_music,
|
|
|
|
futures_receiver_similar_images,
|
|
|
|
futures_receiver_similar_videos,
|
|
|
|
futures_receiver_temporary,
|
|
|
|
futures_receiver_invalid_symlinks,
|
|
|
|
futures_receiver_broken_files,
|
|
|
|
);
|
2021-12-07 02:30:29 +13:00
|
|
|
connect_show_hide_ui(&gui_data);
|
2021-11-28 04:44:30 +13:00
|
|
|
connect_settings(&gui_data);
|
|
|
|
connect_button_about(&gui_data);
|
|
|
|
connect_about_buttons(&gui_data);
|
|
|
|
connect_similar_image_size_change(&gui_data);
|
2020-12-02 22:25:27 +13:00
|
|
|
|
2020-12-08 03:25:44 +13:00
|
|
|
let window_main = gui_data.window_main.clone();
|
2021-02-21 00:24:36 +13:00
|
|
|
let taskbar_state = gui_data.taskbar_state.clone();
|
2020-12-08 03:25:44 +13:00
|
|
|
window_main.connect_delete_event(move |_, _| {
|
2022-01-08 04:45:08 +13:00
|
|
|
save_configuration(false, &gui_data.upper_notebook, &gui_data.main_notebook, &gui_data.settings, &gui_data.text_view_errors); // Save configuration at exit
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow_mut().release();
|
2020-12-08 03:25:44 +13:00
|
|
|
Inhibit(false)
|
|
|
|
});
|
2021-11-28 04:44:30 +13:00
|
|
|
});
|
2020-10-04 22:10:17 +13:00
|
|
|
|
2021-11-28 04:44:30 +13:00
|
|
|
application.run();
|
2020-09-26 06:29:09 +12:00
|
|
|
}
|