Skip to content

Commit

Permalink
Detlaff
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Dec 17, 2021
1 parent 767566a commit e660665
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 15 deletions.
9 changes: 8 additions & 1 deletion czkawka_gui/src/connect_button_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ fn move_things(tree_view: &gtk::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<PathBuf> = 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 {
Expand Down
7 changes: 7 additions & 0 deletions czkawka_gui/src/connect_button_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// });
}
26 changes: 16 additions & 10 deletions czkawka_gui/src/connect_selection_of_directories.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<PathBuf> = 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();
});
}

Expand Down
8 changes: 8 additions & 0 deletions czkawka_gui/src/gui_bottom_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ impl GuiBottomButtons {
get_custom_label_from_label_with_image(&self.buttons_hardlink.clone().upcast::<Bin>()).set_text(&fl!("bottom_hardlink_button"));
get_custom_label_from_label_with_image(&self.buttons_move.clone().upcast::<Bin>()).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")));
Expand Down
5 changes: 5 additions & 0 deletions czkawka_gui/src/gui_progress_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions czkawka_gui/src/help_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,15 @@ pub fn get_custom_label_from_label_with_image(button: &gtk::Bin) -> gtk::Label {
}
panic!("Button doesn't have proper custom label child");
}
// pub fn get_custom_label_from_label_with_image<P: IsA<gtk::Widget>>(button: &P) -> gtk::Label {
// let internal_box = button.widget().unwrap().downcast::<gtk::Box>().unwrap();
// for child in internal_box.children() {
// if let Ok(t) = child.downcast::<gtk::Label>() {
// return t;
// }
// }
// panic!("Button doesn't have proper custom label child");
// }

// GTK 4
// pub fn get_all_children<P: IsA<gtk::Widget>>(wid: &P) -> Vec<gtk::Widget> {
Expand Down
5 changes: 2 additions & 3 deletions czkawka_gui/src/initialize_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e660665

Please sign in to comment.