diff --git a/czkawka_gui/src/connect_button_move.rs b/czkawka_gui/src/connect_button_move.rs index 78d0dec7c..471554ebc 100644 --- a/czkawka_gui/src/connect_button_move.rs +++ b/czkawka_gui/src/connect_button_move.rs @@ -75,7 +75,14 @@ fn move_things(tree_view: >k::TreeView, column_file_name: i32, column_path: i3 let tree_view = tree_view.clone(); chooser.connect_response(move |file_chooser, response_type| { if response_type == gtk::ResponseType::Ok { - let folders = file_chooser.filenames(); + let g_files = file_chooser.files(); + let mut folders: Vec = Vec::new(); + for file in g_files { + if let Some(path_buf) = file.path() { + folders.push(path_buf); + } + } + if folders.len() != 1 { add_text_to_text_view(&text_view_errors, format!("{} {:?}", &fl!("move_files_choose_more_than_1_path"), folders).as_str()); } else { diff --git a/czkawka_gui/src/connect_button_stop.rs b/czkawka_gui/src/connect_button_stop.rs index 411e4c739..4bc16b32c 100644 --- a/czkawka_gui/src/connect_button_stop.rs +++ b/czkawka_gui/src/connect_button_stop.rs @@ -19,4 +19,11 @@ pub fn connect_button_stop(gui_data: &GuiData) { stop_sender.send(()).unwrap(); gtk::Inhibit(false) }); + + // let gc_button_stop_in_dialog = gui_data.progress_window.gc_button_stop_in_dialog.clone(); + // let stop_sender = gui_data.stop_sender.clone(); + // gc_button_stop_in_dialog.connect_button_release_event(move |_, _e| { + // stop_sender.send(()).unwrap(); + // gtk::Inhibit(false) + // }); } diff --git a/czkawka_gui/src/connect_selection_of_directories.rs b/czkawka_gui/src/connect_selection_of_directories.rs index e8fe2c6a2..6dfb64257 100644 --- a/czkawka_gui/src/connect_selection_of_directories.rs +++ b/czkawka_gui/src/connect_selection_of_directories.rs @@ -1,5 +1,6 @@ use gtk::prelude::*; use gtk::{ResponseType, TreeView, Window}; +use std::path::PathBuf; #[cfg(target_family = "windows")] use czkawka_core::common::Common; @@ -80,26 +81,31 @@ pub fn connect_selection_of_directories(gui_data: &GuiData) { fn add_chosen_directories(window_main: &Window, tree_view: &TreeView, excluded_items: bool) { let folders_to = if excluded_items { fl!("exclude_folders_dialog_title") } else { fl!("include_folders_dialog_title") }; - let chooser = gtk::FileChooserDialog::builder().title(&folders_to).action(gtk::FileChooserAction::SelectFolder).transient_for(window_main).modal(true).build(); - chooser.add_button(&fl!("general_ok_button"), ResponseType::Ok); - chooser.add_button(&fl!("general_close_button"), ResponseType::Cancel); + let file_chooser = gtk::FileChooserDialog::builder().title(&folders_to).action(gtk::FileChooserAction::SelectFolder).transient_for(window_main).modal(true).build(); + file_chooser.add_button(&fl!("general_ok_button"), ResponseType::Ok); + file_chooser.add_button(&fl!("general_close_button"), ResponseType::Cancel); - chooser.set_select_multiple(true); - chooser.show_all(); + file_chooser.set_select_multiple(true); + file_chooser.show_all(); let tree_view = tree_view.clone(); - chooser.connect_response(move |chooser, response_type| { + file_chooser.connect_response(move |file_chooser, response_type| { if response_type == gtk::ResponseType::Ok { - let folder = chooser.filenames(); - + let g_files = file_chooser.files(); + let mut folders: Vec = Vec::new(); + for file in g_files { + if let Some(path_buf) = file.path() { + folders.push(path_buf); + } + } let list_store = get_list_store(&tree_view); - for file_entry in &folder { + for file_entry in &folders { let values: [(u32, &dyn ToValue); 1] = [(ColumnsDirectory::Path as u32, &file_entry.to_string_lossy().to_string())]; list_store.set(&list_store.append(), &values); } } - chooser.close(); + file_chooser.close(); }); } diff --git a/czkawka_gui/src/gui_bottom_buttons.rs b/czkawka_gui/src/gui_bottom_buttons.rs index fa18021e1..c38e06cfb 100644 --- a/czkawka_gui/src/gui_bottom_buttons.rs +++ b/czkawka_gui/src/gui_bottom_buttons.rs @@ -75,6 +75,14 @@ impl GuiBottomButtons { get_custom_label_from_label_with_image(&self.buttons_hardlink.clone().upcast::()).set_text(&fl!("bottom_hardlink_button")); get_custom_label_from_label_with_image(&self.buttons_move.clone().upcast::()).set_text(&fl!("bottom_move_button")); + // get_custom_label_from_label_with_image(&self.buttons_search.clone()).set_text(&fl!("bottom_search_button")); + // get_custom_label_from_label_with_image(&self.buttons_select.clone()).set_text(&fl!("bottom_select_button")); + // get_custom_label_from_label_with_image(&self.buttons_delete.clone()).set_text(&fl!("bottom_delete_button")); + // get_custom_label_from_label_with_image(&self.buttons_save.clone()).set_text(&fl!("bottom_save_button")); + // get_custom_label_from_label_with_image(&self.buttons_symlink.clone()).set_text(&fl!("bottom_symlink_button")); + // get_custom_label_from_label_with_image(&self.buttons_hardlink.clone()).set_text(&fl!("bottom_hardlink_button")); + // get_custom_label_from_label_with_image(&self.buttons_move.clone()).set_text(&fl!("bottom_move_button")); + self.buttons_search.set_tooltip_text(Some(&fl!("bottom_search_button_tooltip"))); self.buttons_select.set_tooltip_text(Some(&fl!("bottom_select_button_tooltip"))); self.buttons_delete.set_tooltip_text(Some(&fl!("bottom_delete_button_tooltip"))); diff --git a/czkawka_gui/src/gui_progress_dialog.rs b/czkawka_gui/src/gui_progress_dialog.rs index a79ebf3dc..ee9ee73c5 100644 --- a/czkawka_gui/src/gui_progress_dialog.rs +++ b/czkawka_gui/src/gui_progress_dialog.rs @@ -18,6 +18,7 @@ pub struct GuiProgressDialog { pub button_stop_in_dialog: gtk::Button, pub evk_button_stop_in_dialog: gtk::EventControllerKey, + // pub gc_button_stop_in_dialog: gtk4::GestureClick, } impl GuiProgressDialog { @@ -40,6 +41,10 @@ impl GuiProgressDialog { let button_stop_in_dialog: gtk::Button = builder.object("button_stop_in_dialog").unwrap(); let evk_button_stop_in_dialog = EventControllerKey::new(&button_stop_in_dialog); + // let evk_button_stop_in_dialog = EventControllerKey::new(); + // button_stop_in_dialog.add_controller(&evk_button_stop_in_dialog); + // let gc_button_stop_in_dialog = gtk4::GestureClick::new(); + // button_stop_in_dialog.add_controller(&gc_button_stop_in_dialog); Self { window_progress, diff --git a/czkawka_gui/src/help_functions.rs b/czkawka_gui/src/help_functions.rs index 02b4e3386..7f71bc3b1 100644 --- a/czkawka_gui/src/help_functions.rs +++ b/czkawka_gui/src/help_functions.rs @@ -551,6 +551,15 @@ pub fn get_custom_label_from_label_with_image(button: >k::Bin) -> gtk::Label { } panic!("Button doesn't have proper custom label child"); } +// pub fn get_custom_label_from_label_with_image>(button: &P) -> gtk::Label { +// let internal_box = button.widget().unwrap().downcast::().unwrap(); +// for child in internal_box.children() { +// if let Ok(t) = child.downcast::() { +// return t; +// } +// } +// panic!("Button doesn't have proper custom label child"); +// } // GTK 4 // pub fn get_all_children>(wid: &P) -> Vec { diff --git a/czkawka_gui/src/initialize_gui.rs b/czkawka_gui/src/initialize_gui.rs index 63ee64e7d..71d1b1c35 100644 --- a/czkawka_gui/src/initialize_gui.rs +++ b/czkawka_gui/src/initialize_gui.rs @@ -466,10 +466,9 @@ pub fn initialize_gui(gui_data: &mut GuiData) { } fn connect_event_mouse(gui_data: &GuiData) { - let text_view_errors = gui_data.text_view_errors.clone(); - // Duplicate { + let text_view_errors = gui_data.text_view_errors.clone(); let check_button_settings_show_preview = gui_data.settings.check_button_settings_show_preview_duplicates.clone(); let image_preview = gui_data.main_notebook.image_preview_duplicates.clone(); let preview_path = gui_data.preview_path.clone(); @@ -510,13 +509,13 @@ fn connect_event_mouse(gui_data: &GuiData) { } // Similar Images { + let text_view_errors = gui_data.text_view_errors.clone(); let tree_view = gui_data.main_notebook.tree_view_similar_images_finder.clone(); let check_button_settings_show_preview = gui_data.settings.check_button_settings_show_preview_similar_images.clone(); let preview_path = gui_data.preview_path.clone(); let image_preview = gui_data.main_notebook.image_preview_similar_images.clone(); tree_view.connect_button_press_event(opening_double_click_function); - let text_view_errors = gui_data.text_view_errors.clone(); tree_view.connect_button_release_event(move |tree_view, _event| { let nb_object = &NOTEBOOKS_INFOS[NotebookMainEnum::SimilarImages as usize]; let preview_path = preview_path.clone(); diff --git a/czkawka_gui/src/main.rs b/czkawka_gui/src/main.rs index 82e70f9bd..40601f7e5 100644 --- a/czkawka_gui/src/main.rs +++ b/czkawka_gui/src/main.rs @@ -76,7 +76,7 @@ mod tests; fn main() { let application = gtk::Application::builder().application_id("pl.qarmin.czkawka").build(); - application.connect_activate(|application| { + application.connect_activate(move |application| { let mut gui_data: GuiData = GuiData::new_with_application(application); // Used for getting data from thread