|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
use gtk::prelude::*;
|
|
|
|
|
use gtk::{TreeView, Window};
|
|
|
|
|
use gtk::{ResponseType, TreeView, Window};
|
|
|
|
|
|
|
|
|
|
#[cfg(target_family = "windows")]
|
|
|
|
|
use czkawka_core::common::Common;
|
|
|
|
|
|
|
|
|
|
use crate::gui_data::GuiData;
|
|
|
|
|
use crate::help_functions::{get_list_store, ColumnsDirectory};
|
|
|
|
|
use crate::help_functions::{get_dialog_box_child, get_list_store, ColumnsDirectory};
|
|
|
|
|
|
|
|
|
|
pub fn connect_selection_of_directories(gui_data: &GuiData) {
|
|
|
|
|
// Add manually directory
|
|
|
|
@ -78,11 +78,18 @@ 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 { "Folders to exclude" } else { "Folders to include" };
|
|
|
|
|
let chooser = gtk::FileChooserDialog::with_buttons(Some(folders_to), Some(window_main), gtk::FileChooserAction::SelectFolder, &[("Ok", gtk::ResponseType::Ok), ("Close", gtk::ResponseType::Cancel)]);
|
|
|
|
|
|
|
|
|
|
let chooser = gtk::FileChooserDialog::builder().title(folders_to).action(gtk::FileChooserAction::SelectFolder).build();
|
|
|
|
|
chooser.add_button("Ok", ResponseType::Ok);
|
|
|
|
|
chooser.add_button("Close", ResponseType::Cancel);
|
|
|
|
|
|
|
|
|
|
chooser.set_select_multiple(true);
|
|
|
|
|
chooser.show_all();
|
|
|
|
|
|
|
|
|
|
window_main.set_sensitive(false);
|
|
|
|
|
|
|
|
|
|
let tree_view = tree_view.clone();
|
|
|
|
|
let window_main = window_main.clone();
|
|
|
|
|
chooser.connect_response(move |chooser, response_type| {
|
|
|
|
|
if response_type == gtk::ResponseType::Ok {
|
|
|
|
|
let folder = chooser.filenames();
|
|
|
|
@ -95,21 +102,25 @@ fn add_chosen_directories(window_main: &Window, tree_view: &TreeView, excluded_i
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
chooser.close();
|
|
|
|
|
window_main.set_sensitive(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn add_manually_directories(window_main: &Window, tree_view: &TreeView) {
|
|
|
|
|
let dialog_manual_add_directory = gtk::Dialog::with_buttons(Some("Add directory manually"), Some(window_main), gtk::DialogFlags::MODAL, &[("Ok", gtk::ResponseType::Ok), ("Close", gtk::ResponseType::Cancel)]);
|
|
|
|
|
let dialog_manual_add_directory = gtk::Dialog::builder().title("Add directory manually").build();
|
|
|
|
|
dialog_manual_add_directory.add_button("Ok", ResponseType::Ok);
|
|
|
|
|
dialog_manual_add_directory.add_button("Close", ResponseType::Cancel);
|
|
|
|
|
|
|
|
|
|
window_main.set_sensitive(false);
|
|
|
|
|
|
|
|
|
|
let entry: gtk::Entry = gtk::Entry::new();
|
|
|
|
|
|
|
|
|
|
for widgets in dialog_manual_add_directory.children() {
|
|
|
|
|
// By default GtkBox is child of dialog, so we can easily add other things to it
|
|
|
|
|
widgets.clone().downcast::<gtk::Box>().unwrap().add(&entry);
|
|
|
|
|
}
|
|
|
|
|
get_dialog_box_child(&dialog_manual_add_directory).add(&entry);
|
|
|
|
|
|
|
|
|
|
dialog_manual_add_directory.show_all();
|
|
|
|
|
|
|
|
|
|
let tree_view = tree_view.clone();
|
|
|
|
|
let window_main = window_main.clone();
|
|
|
|
|
dialog_manual_add_directory.connect_response(move |dialog_manual_add_directory, response_type| {
|
|
|
|
|
if response_type == gtk::ResponseType::Ok {
|
|
|
|
|
let text = entry.text().to_string().trim().to_string();
|
|
|
|
@ -123,10 +134,8 @@ fn add_manually_directories(window_main: &Window, tree_view: &TreeView) {
|
|
|
|
|
let values: [(u32, &dyn ToValue); 1] = [(ColumnsDirectory::Path as u32, &text)];
|
|
|
|
|
list_store.set(&list_store.append(), &values);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dialog_manual_add_directory.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dialog_manual_add_directory.close();
|
|
|
|
|
window_main.set_sensitive(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|