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)]
|
2020-12-14 04:35:27 +13:00
|
|
|
|
2021-01-25 00:01:02 +13:00
|
|
|
mod connect_about_buttons;
|
2020-11-01 02:23:31 +13:00
|
|
|
mod connect_button_delete;
|
2021-02-25 01:53:46 +13:00
|
|
|
mod connect_button_hardlink;
|
2021-11-20 20:32:28 +13:00
|
|
|
mod connect_button_move;
|
2020-11-01 02:23:31 +13:00
|
|
|
mod connect_button_save;
|
|
|
|
mod connect_button_search;
|
|
|
|
mod connect_button_select;
|
|
|
|
mod connect_button_stop;
|
2020-12-20 02:39:42 +13:00
|
|
|
mod connect_button_symlink;
|
2020-11-01 02:23:31 +13:00
|
|
|
mod connect_compute_results;
|
2021-01-25 00:01:02 +13:00
|
|
|
mod connect_header_buttons;
|
2020-12-13 12:21:43 +13:00
|
|
|
mod connect_hide_text_view_errors;
|
2020-11-01 02:23:31 +13:00
|
|
|
mod connect_notebook_tabs;
|
2020-11-09 22:09:22 +13:00
|
|
|
mod connect_popovers;
|
2020-12-02 22:25:27 +13:00
|
|
|
mod connect_progress_window;
|
2020-12-08 03:25:44 +13:00
|
|
|
mod connect_selection_of_directories;
|
|
|
|
mod connect_settings;
|
2021-11-19 18:35:26 +13:00
|
|
|
mod connect_similar_image_size_change;
|
2020-10-16 04:51:47 +13:00
|
|
|
mod create_tree_view;
|
2020-10-15 21:42:27 +13:00
|
|
|
mod double_click_opening;
|
2021-01-25 00:01:02 +13:00
|
|
|
mod gui_about;
|
2021-01-11 08:12:08 +13:00
|
|
|
mod gui_bottom_buttons;
|
2020-11-01 02:23:31 +13:00
|
|
|
mod gui_data;
|
2021-01-25 00:01:02 +13:00
|
|
|
mod gui_header;
|
2021-01-11 01:45:05 +13:00
|
|
|
mod gui_main_notebook;
|
2021-01-11 08:12:08 +13:00
|
|
|
mod gui_popovers;
|
|
|
|
mod gui_progress_dialog;
|
2021-02-23 21:40:19 +13:00
|
|
|
mod gui_settings;
|
2021-01-11 08:12:08 +13:00
|
|
|
mod gui_upper_notepad;
|
2020-09-30 05:44:20 +13:00
|
|
|
mod help_functions;
|
2020-12-08 03:25:44 +13:00
|
|
|
mod initialize_gui;
|
2021-01-11 00:06:25 +13:00
|
|
|
mod notebook_enums;
|
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;
|
2020-09-30 05:44:20 +13:00
|
|
|
|
2020-09-23 22:17:19 +12:00
|
|
|
use czkawka_core::*;
|
2020-10-15 21:42:27 +13:00
|
|
|
|
2021-01-25 00:01:02 +13:00
|
|
|
use crate::connect_about_buttons::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::connect_button_delete::*;
|
2021-02-25 01:53:46 +13:00
|
|
|
use crate::connect_button_hardlink::*;
|
2021-11-20 20:32:28 +13:00
|
|
|
use crate::connect_button_move::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::connect_button_save::*;
|
|
|
|
use crate::connect_button_search::*;
|
|
|
|
use crate::connect_button_select::*;
|
|
|
|
use crate::connect_button_stop::*;
|
2020-12-20 02:39:42 +13:00
|
|
|
use crate::connect_button_symlink::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::connect_compute_results::*;
|
2021-01-25 00:01:02 +13:00
|
|
|
use crate::connect_header_buttons::*;
|
2020-12-13 12:21:43 +13:00
|
|
|
use crate::connect_hide_text_view_errors::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::connect_notebook_tabs::*;
|
2020-11-09 22:09:22 +13:00
|
|
|
use crate::connect_popovers::*;
|
2020-12-02 22:25:27 +13:00
|
|
|
use crate::connect_progress_window::*;
|
2020-12-08 03:25:44 +13:00
|
|
|
use crate::connect_selection_of_directories::*;
|
|
|
|
use crate::connect_settings::*;
|
2021-11-19 18:35:26 +13:00
|
|
|
use crate::connect_similar_image_size_change::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::gui_data::*;
|
2020-12-08 03:25:44 +13:00
|
|
|
use crate::initialize_gui::*;
|
2020-12-13 12:21:43 +13:00
|
|
|
use crate::saving_loading::*;
|
2020-09-02 05:34:39 +12:00
|
|
|
use gtk::prelude::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
use std::{env, process};
|
2020-10-15 05:41:37 +13:00
|
|
|
|
2020-09-02 05:34:39 +12:00
|
|
|
fn main() {
|
2020-10-04 22:10:17 +13:00
|
|
|
let mut exit_program_after_initialization: bool = false;
|
2020-09-24 21:58:59 +12:00
|
|
|
// Printing version
|
2020-09-23 22:17:19 +12:00
|
|
|
{
|
|
|
|
let all_arguments: Vec<String> = env::args().skip(1).collect(); // Not need to check program name
|
|
|
|
|
|
|
|
for i in all_arguments {
|
2020-10-04 22:10:17 +13:00
|
|
|
if i == "-v" || i == "--version" {
|
2020-10-02 03:54:26 +13:00
|
|
|
println!("Czkawka GUI {}", CZKAWKA_VERSION);
|
2020-09-23 22:17:19 +12:00
|
|
|
process::exit(0);
|
|
|
|
}
|
2020-10-04 22:10:17 +13:00
|
|
|
if i == "-q" || i == "--quit" {
|
|
|
|
exit_program_after_initialization = true;
|
|
|
|
}
|
2020-09-23 22:17:19 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-05 07:12:18 +12:00
|
|
|
gtk::init().expect("Failed to initialize GTK.");
|
|
|
|
|
2021-01-11 01:45:05 +13:00
|
|
|
let mut gui_data: GuiData = GuiData::new();
|
2020-10-10 22:15:20 +13:00
|
|
|
|
|
|
|
// Used for getting data from thread
|
2020-12-02 22:25:27 +13:00
|
|
|
let (glib_stop_sender, glib_stop_receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
|
|
|
|
|
|
|
|
// Futures progress report
|
2021-04-14 18:23:59 +12:00
|
|
|
let (futures_sender_duplicate_files, futures_receiver_duplicate_files): (futures::channel::mpsc::UnboundedSender<duplicate::ProgressData>, futures::channel::mpsc::UnboundedReceiver<duplicate::ProgressData>) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_empty_files, futures_receiver_empty_files): (futures::channel::mpsc::UnboundedSender<empty_files::ProgressData>, futures::channel::mpsc::UnboundedReceiver<empty_files::ProgressData>) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_empty_folder, futures_receiver_empty_folder): (futures::channel::mpsc::UnboundedSender<empty_folder::ProgressData>, futures::channel::mpsc::UnboundedReceiver<empty_folder::ProgressData>) = 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): (futures::channel::mpsc::UnboundedSender<same_music::ProgressData>, futures::channel::mpsc::UnboundedReceiver<same_music::ProgressData>) = 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_temporary, futures_receiver_temporary): (futures::channel::mpsc::UnboundedSender<temporary::ProgressData>, futures::channel::mpsc::UnboundedReceiver<temporary::ProgressData>) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_zeroed, futures_receiver_zeroed): (futures::channel::mpsc::UnboundedSender<zeroed::ProgressData>, futures::channel::mpsc::UnboundedReceiver<zeroed::ProgressData>) = futures::channel::mpsc::unbounded();
|
|
|
|
let (futures_sender_invalid_symlinks, futures_receiver_invalid_symlinks): (futures::channel::mpsc::UnboundedSender<invalid_symlinks::ProgressData>, futures::channel::mpsc::UnboundedReceiver<invalid_symlinks::ProgressData>) =
|
|
|
|
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-10-08 09:22:39 +13:00
|
|
|
|
2021-01-11 01:45:05 +13:00
|
|
|
initialize_gui(&mut gui_data);
|
2020-12-08 03:25:44 +13:00
|
|
|
reset_configuration(&gui_data, false); // Fallback for invalid loading setting project
|
|
|
|
load_configuration(&gui_data, false);
|
|
|
|
|
2020-11-01 02:23:31 +13:00
|
|
|
connect_button_delete(&gui_data);
|
|
|
|
connect_button_save(&gui_data);
|
2020-12-02 22:25:27 +13:00
|
|
|
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_temporary,
|
|
|
|
futures_sender_zeroed,
|
2020-12-22 04:09:39 +13:00
|
|
|
futures_sender_invalid_symlinks,
|
2021-01-13 08:06:12 +13:00
|
|
|
futures_sender_broken_files,
|
2020-12-02 22:25:27 +13:00
|
|
|
);
|
2020-11-01 02:23:31 +13:00
|
|
|
connect_button_select(&gui_data);
|
|
|
|
connect_button_stop(&gui_data);
|
2020-12-20 02:39:42 +13:00
|
|
|
connect_button_symlink(&gui_data);
|
2021-02-25 01:53:46 +13:00
|
|
|
connect_button_hardlink(&gui_data);
|
2021-11-20 20:32:28 +13:00
|
|
|
connect_button_move(&gui_data);
|
2020-11-01 02:23:31 +13:00
|
|
|
connect_notebook_tabs(&gui_data);
|
2020-12-08 03:25:44 +13:00
|
|
|
connect_selection_of_directories(&gui_data);
|
2020-11-09 22:09:22 +13:00
|
|
|
connect_popovers(&gui_data);
|
2020-12-02 22:25:27 +13:00
|
|
|
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_temporary,
|
|
|
|
futures_receiver_zeroed,
|
2020-12-22 04:09:39 +13:00
|
|
|
futures_receiver_invalid_symlinks,
|
2021-01-13 08:06:12 +13:00
|
|
|
futures_receiver_broken_files,
|
2020-12-02 22:25:27 +13:00
|
|
|
);
|
2020-12-13 12:21:43 +13:00
|
|
|
connect_hide_text_view_errors(&gui_data);
|
2020-12-08 03:25:44 +13:00
|
|
|
connect_settings(&gui_data);
|
2021-01-25 00:01:02 +13:00
|
|
|
connect_button_about(&gui_data);
|
|
|
|
connect_about_buttons(&gui_data);
|
2021-11-19 18:35:26 +13:00
|
|
|
connect_similar_image_size_change(&gui_data);
|
2020-10-08 09:22:39 +13:00
|
|
|
|
2020-09-30 05:44:20 +13:00
|
|
|
// Quit the program when X in main window was clicked
|
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 |_, _| {
|
|
|
|
save_configuration(&gui_data, false); // Save configuration at exit
|
|
|
|
gtk::main_quit();
|
2021-02-21 00:24:36 +13:00
|
|
|
taskbar_state.borrow_mut().release();
|
2020-12-08 03:25:44 +13:00
|
|
|
Inhibit(false)
|
|
|
|
});
|
|
|
|
}
|
2020-09-30 05:44:20 +13:00
|
|
|
|
|
|
|
// We start the gtk main loop.
|
|
|
|
gtk::main();
|
2020-10-04 22:10:17 +13:00
|
|
|
|
|
|
|
// Quiting if quit flag was provided
|
|
|
|
if exit_program_after_initialization {
|
|
|
|
gtk::main_quit();
|
|
|
|
}
|
2020-09-26 06:29:09 +12:00
|
|
|
}
|