diff --git a/czkawka_core/src/duplicate.rs b/czkawka_core/src/duplicate.rs index 462c5de..bd2b807 100644 --- a/czkawka_core/src/duplicate.rs +++ b/czkawka_core/src/duplicate.rs @@ -1312,7 +1312,6 @@ fn delete_files(vector: &[FileEntry], delete_method: &DeleteMethod, warnings: &m } fn save_hashes_to_file(hashmap: &HashMap, text_messages: &mut Messages, type_of_hash: &HashType) { - println!("Trying to save {} files", hashmap.len()); if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") { let cache_dir = PathBuf::from(proj_dirs.cache_dir()); if cache_dir.exists() { diff --git a/czkawka_gui/czkawka.glade b/czkawka_gui/czkawka.glade index 2146784..b268d55 100644 --- a/czkawka_gui/czkawka.glade +++ b/czkawka_gui/czkawka.glade @@ -32,6 +32,122 @@ Author: Rafał Mikrut + + False + center + dialog + Czkawka + 2.3.2 + 2020 - 2021 Rafał Mikrut(qarmin) + +This program is free to use and will always be. + + Rafał Mikrut(qarmin) + data/icons/com.github.qarmin.czkawka.svg + mit-x11 + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + True + False + vertical + 10 + + + True + False + + + True + False + + + Repository + True + True + True + + + False + True + 0 + + + + + Instruction + True + True + True + + + False + True + 1 + + + + + False + True + 0 + + + + + Donation + True + True + True + + + False + True + end + 1 + + + + + False + True + 1 + + + + + False + True + 2 + + + + + + + + False dialog @@ -2442,6 +2558,7 @@ Author: Rafał Mikrut True True False + True @@ -2455,7 +2572,59 @@ Author: Rafał Mikrut - + + True + False + True + + + True + False + 5 + + + True + True + True + + + True + False + settings-app-symbolic + + + + + False + True + 0 + + + + + True + True + True + + + True + False + dialog-information + + + + + False + True + 1 + + + + + end + + + diff --git a/czkawka_gui/src/connect_about_buttons.rs b/czkawka_gui/src/connect_about_buttons.rs new file mode 100644 index 0000000..9f74a06 --- /dev/null +++ b/czkawka_gui/src/connect_about_buttons.rs @@ -0,0 +1,30 @@ +extern crate gtk; +use crate::gui_data::GuiData; +use gtk::prelude::*; + +const SPONSOR_SITE: &str = "https://github.com/sponsors/qarmin"; +const REPOSITORY_SITE: &str = "https://github.com/qarmin/czkawka"; +const INSTRUCTION_SITE: &str = "https://github.com/qarmin/czkawka/blob/master/instructions/Instruction.md"; + +pub fn connect_about_buttons(gui_data: &GuiData) { + let button_donation = gui_data.about.button_donation.clone(); + button_donation.connect_clicked(move |_| { + if open::that(SPONSOR_SITE).is_err() { + println!("Failed to open sponsor site: {}", SPONSOR_SITE) + }; + }); + + let button_instruction = gui_data.about.button_instruction.clone(); + button_instruction.connect_clicked(move |_| { + if open::that(INSTRUCTION_SITE).is_err() { + println!("Failed to open instruction site: {}", INSTRUCTION_SITE) + }; + }); + + let button_repository = gui_data.about.button_repository.clone(); + button_repository.connect_clicked(move |_| { + if open::that(REPOSITORY_SITE).is_err() { + println!("Failed to open repository site: {}", REPOSITORY_SITE) + }; + }); +} diff --git a/czkawka_gui/src/connect_header_buttons.rs b/czkawka_gui/src/connect_header_buttons.rs new file mode 100644 index 0000000..b142494 --- /dev/null +++ b/czkawka_gui/src/connect_header_buttons.rs @@ -0,0 +1,18 @@ +extern crate gtk; +use crate::gui_data::GuiData; +use gtk::prelude::*; +use gtk::{ResponseType, WindowPosition}; + +pub fn connect_button_about(gui_data: &GuiData) { + let about_dialog = gui_data.about.about_dialog.clone(); + let button_app_info = gui_data.header.button_app_info.clone(); + button_app_info.connect_clicked(move |_| { + about_dialog.set_position(WindowPosition::Center); // Not working + + about_dialog.show(); + let response = about_dialog.run(); + if response != ResponseType::None { + about_dialog.hide(); + } + }); +} diff --git a/czkawka_gui/src/gui_about.rs b/czkawka_gui/src/gui_about.rs new file mode 100644 index 0000000..ad72d8f --- /dev/null +++ b/czkawka_gui/src/gui_about.rs @@ -0,0 +1,27 @@ +use gtk::prelude::*; + +#[derive(Clone)] +pub struct GUIAbout { + pub about_dialog: gtk::AboutDialog, + + pub button_repository: gtk::Button, + pub button_donation: gtk::Button, + pub button_instruction: gtk::Button, +} + +impl GUIAbout { + pub fn create_from_builder(builder: >k::Builder) -> Self { + let about_dialog: gtk::AboutDialog = builder.get_object("about_dialog").unwrap(); + + let button_repository: gtk::Button = builder.get_object("button_repository").unwrap(); + let button_donation: gtk::Button = builder.get_object("button_donation").unwrap(); + let button_instruction: gtk::Button = builder.get_object("button_instruction").unwrap(); + + Self { + about_dialog, + button_repository, + button_donation, + button_instruction, + } + } +} diff --git a/czkawka_gui/src/gui_data.rs b/czkawka_gui/src/gui_data.rs index 365acce..29351ca 100644 --- a/czkawka_gui/src/gui_data.rs +++ b/czkawka_gui/src/gui_data.rs @@ -1,6 +1,9 @@ extern crate gtk; +use crate::gui_about::GUIAbout; use crate::gui_bottom_buttons::GUIBottomButtons; +use crate::gui_header::GUIHeader; use crate::gui_main_notebook::GUIMainNotebook; +use crate::gui_options::GUIOptions; use crate::gui_popovers::GUIPopovers; use crate::gui_progress_dialog::GUIProgressDialog; use crate::gui_upper_notepad::GUIUpperNotebook; @@ -36,6 +39,9 @@ pub struct GuiData { pub popovers: GUIPopovers, pub bottom_buttons: GUIBottomButtons, pub progress_dialog: GUIProgressDialog, + pub about: GUIAbout, + pub options: GUIOptions, + pub header: GUIHeader, // Buttons state pub shared_buttons: Rc>>>, @@ -83,6 +89,9 @@ impl GuiData { let popovers = GUIPopovers::create_from_builder(&builder); let bottom_buttons = GUIBottomButtons::create_from_builder(&builder); let progress_dialog = GUIProgressDialog::create_from_builder(&builder); + let options = GUIOptions::create_from_builder(&builder); + let about = GUIAbout::create_from_builder(&builder); + let header = GUIHeader::create_from_builder(&builder); //////////////////////////////////////////////////////////////////////////////////////////////// @@ -134,6 +143,7 @@ impl GuiData { //// Bottom let text_view_errors: gtk::TextView = builder.get_object("text_view_errors").unwrap(); let scrolled_window_errors: gtk::ScrolledWindow = builder.get_object("scrolled_window_errors").unwrap(); + scrolled_window_errors.show_all(); // Not sure why needed, but without it text view errors sometimes hide itself // Used for sending stop signal to thread let (stop_sender, stop_receiver): (crossbeam_channel::Sender<()>, crossbeam_channel::Receiver<()>) = unbounded(); @@ -147,6 +157,9 @@ impl GuiData { popovers, bottom_buttons, progress_dialog, + about, + options, + header, shared_buttons, shared_upper_notebooks, shared_duplication_state, diff --git a/czkawka_gui/src/gui_header.rs b/czkawka_gui/src/gui_header.rs new file mode 100644 index 0000000..1ca6310 --- /dev/null +++ b/czkawka_gui/src/gui_header.rs @@ -0,0 +1,15 @@ +use gtk::prelude::*; + +#[derive(Clone)] +pub struct GUIHeader { + pub button_settings: gtk::Button, + pub button_app_info: gtk::Button, +} + +impl GUIHeader { + pub fn create_from_builder(builder: >k::Builder) -> Self { + let button_settings: gtk::Button = builder.get_object("button_settings").unwrap(); + let button_app_info: gtk::Button = builder.get_object("button_app_info").unwrap(); + Self { button_settings, button_app_info } + } +} diff --git a/czkawka_gui/src/gui_options.rs b/czkawka_gui/src/gui_options.rs new file mode 100644 index 0000000..661e27f --- /dev/null +++ b/czkawka_gui/src/gui_options.rs @@ -0,0 +1,10 @@ +#[derive(Clone)] +pub struct GUIOptions {} + +impl GUIOptions { + pub fn create_from_builder(_builder: >k::Builder) -> Self { + // let notebook_main: gtk::Notebook = builder.get_object("notebook_main").unwrap(); + + Self {} + } +} diff --git a/czkawka_gui/src/initialize_gui.rs b/czkawka_gui/src/initialize_gui.rs index bc6c803..b2d7ed7 100644 --- a/czkawka_gui/src/initialize_gui.rs +++ b/czkawka_gui/src/initialize_gui.rs @@ -13,13 +13,28 @@ use std::fs; use std::path::Path; pub fn initialize_gui(gui_data: &mut GuiData) { - //// Setup default look(duplicate finder) + //// Initialize button { let buttons_search = gui_data.bottom_buttons.buttons_search.clone(); let buttons_save = gui_data.bottom_buttons.buttons_save.clone(); let buttons_delete = gui_data.bottom_buttons.buttons_delete.clone(); let buttons_select = gui_data.bottom_buttons.buttons_select.clone(); let buttons_symlink = gui_data.bottom_buttons.buttons_symlink.clone(); + + // Disable and show buttons - only search button should be visible + buttons_search.show(); + buttons_save.hide(); + buttons_delete.hide(); + buttons_select.hide(); + buttons_symlink.hide(); + + // TODO Add Option window + let button_settings = gui_data.header.button_settings.clone(); + button_settings.hide(); + } + + //// Initialize main scrolled view with notebook + { let scrolled_window_duplicate_finder = gui_data.main_notebook.scrolled_window_duplicate_finder.clone(); let scrolled_window_empty_folder_finder = gui_data.main_notebook.scrolled_window_empty_folder_finder.clone(); let scrolled_window_empty_files_finder = gui_data.main_notebook.scrolled_window_empty_files_finder.clone(); @@ -30,20 +45,11 @@ pub fn initialize_gui(gui_data: &mut GuiData) { let scrolled_window_invalid_symlinks = gui_data.main_notebook.scrolled_window_invalid_symlinks.clone(); let scrolled_window_zeroed_files_finder = gui_data.main_notebook.scrolled_window_zeroed_files_finder.clone(); let scrolled_window_broken_files = gui_data.main_notebook.scrolled_window_broken_files.clone(); - let scrolled_window_included_directories = gui_data.upper_notebook.scrolled_window_included_directories.clone(); - let scrolled_window_excluded_directories = gui_data.upper_notebook.scrolled_window_excluded_directories.clone(); let image_preview_similar_images = gui_data.main_notebook.image_preview_similar_images.clone(); let check_button_settings_show_preview_similar_images = gui_data.upper_notebook.check_button_settings_show_preview_similar_images.clone(); let text_view_errors = gui_data.text_view_errors.clone(); - // Disable and show buttons - buttons_search.show(); - buttons_save.hide(); - buttons_delete.hide(); - buttons_select.hide(); - buttons_symlink.hide(); - // Set Main Scrolled Window Treeviews { // Duplicate Files @@ -379,6 +385,12 @@ pub fn initialize_gui(gui_data: &mut GuiData) { }); } } + } + + //// Initialize upper notebook + { + let scrolled_window_included_directories = gui_data.upper_notebook.scrolled_window_included_directories.clone(); + let scrolled_window_excluded_directories = gui_data.upper_notebook.scrolled_window_excluded_directories.clone(); // Set Included Directory { diff --git a/czkawka_gui/src/main.rs b/czkawka_gui/src/main.rs index edff8ea..f1a3081 100644 --- a/czkawka_gui/src/main.rs +++ b/czkawka_gui/src/main.rs @@ -1,6 +1,7 @@ // Remove console window in Windows OS #![windows_subsystem = "windows"] +mod connect_about_buttons; mod connect_button_delete; mod connect_button_save; mod connect_button_search; @@ -8,6 +9,7 @@ mod connect_button_select; mod connect_button_stop; mod connect_button_symlink; mod connect_compute_results; +mod connect_header_buttons; mod connect_hide_text_view_errors; mod connect_notebook_tabs; mod connect_popovers; @@ -16,9 +18,12 @@ mod connect_selection_of_directories; mod connect_settings; mod create_tree_view; mod double_click_opening; +mod gui_about; mod gui_bottom_buttons; mod gui_data; +mod gui_header; mod gui_main_notebook; +mod gui_options; mod gui_popovers; mod gui_progress_dialog; mod gui_upper_notepad; @@ -30,6 +35,7 @@ mod saving_loading; use czkawka_core::*; extern crate gtk; +use crate::connect_about_buttons::*; use crate::connect_button_delete::*; use crate::connect_button_save::*; use crate::connect_button_search::*; @@ -37,6 +43,7 @@ use crate::connect_button_select::*; use crate::connect_button_stop::*; use crate::connect_button_symlink::*; use crate::connect_compute_results::*; +use crate::connect_header_buttons::*; use crate::connect_hide_text_view_errors::*; use crate::connect_notebook_tabs::*; use crate::connect_popovers::*; @@ -127,6 +134,8 @@ fn main() { ); connect_hide_text_view_errors(&gui_data); connect_settings(&gui_data); + connect_button_about(&gui_data); + connect_about_buttons(&gui_data); // Quit the program when X in main window was clicked {