2021-11-28 08:49:20 +13:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use gtk::prelude::*;
|
|
|
|
|
2020-11-01 02:23:31 +13:00
|
|
|
use crate::gui_data::GuiData;
|
2021-11-25 20:36:49 +13:00
|
|
|
use crate::gui_popovers::GuiPopovers;
|
|
|
|
use crate::help_functions::PopoverTypes;
|
2021-01-11 00:06:25 +13:00
|
|
|
use crate::notebook_enums::*;
|
2020-11-01 02:23:31 +13:00
|
|
|
|
|
|
|
pub fn connect_button_select(gui_data: &GuiData) {
|
2021-11-25 20:36:49 +13:00
|
|
|
let mut hashmap: HashMap<NotebookMainEnum, Vec<PopoverTypes>> = Default::default();
|
2020-12-26 22:35:43 +13:00
|
|
|
{
|
2021-12-02 08:09:04 +13:00
|
|
|
hashmap.insert(NotebookMainEnum::SimilarImages, vec![PopoverTypes::All, PopoverTypes::Size, PopoverTypes::Reverse, PopoverTypes::Custom, PopoverTypes::Date]);
|
|
|
|
hashmap.insert(NotebookMainEnum::SimilarVideos, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom, PopoverTypes::Date, PopoverTypes::Size]);
|
2021-11-25 20:36:49 +13:00
|
|
|
hashmap.insert(NotebookMainEnum::Duplicate, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom, PopoverTypes::Date]);
|
2021-12-02 08:09:04 +13:00
|
|
|
hashmap.insert(NotebookMainEnum::SameMusic, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom, PopoverTypes::Date, PopoverTypes::Size]);
|
2020-12-26 22:35:43 +13:00
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
hashmap.insert(NotebookMainEnum::EmptyFiles, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
|
|
|
hashmap.insert(NotebookMainEnum::EmptyDirectories, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
|
|
|
hashmap.insert(NotebookMainEnum::BigFiles, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
|
|
|
hashmap.insert(NotebookMainEnum::Symlinks, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
|
|
|
hashmap.insert(NotebookMainEnum::Temporary, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
|
|
|
hashmap.insert(NotebookMainEnum::BrokenFiles, vec![PopoverTypes::All, PopoverTypes::Reverse, PopoverTypes::Custom]);
|
2020-12-26 22:35:43 +13:00
|
|
|
}
|
2021-11-25 20:36:49 +13:00
|
|
|
assert_eq!(hashmap.len(), NUMBER_OF_NOTEBOOK_MAIN_TABS);
|
2020-12-26 22:35:43 +13:00
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
let popovers = gui_data.popovers.clone();
|
2021-01-11 08:12:08 +13:00
|
|
|
let notebook_main = gui_data.main_notebook.notebook_main.clone();
|
|
|
|
let popover_select = gui_data.popovers.popover_select.clone();
|
|
|
|
let buttons_select = gui_data.bottom_buttons.buttons_select.clone();
|
2020-12-26 22:35:43 +13:00
|
|
|
|
2021-12-01 23:09:47 +13:00
|
|
|
buttons_select.connect_clicked(move |_| {
|
2021-11-25 20:36:49 +13:00
|
|
|
show_required_popovers(&popovers, &to_notebook_main_enum(notebook_main.current_page().unwrap()), &hashmap);
|
2020-12-26 22:35:43 +13:00
|
|
|
popover_select.popup();
|
2020-11-01 02:23:31 +13:00
|
|
|
});
|
|
|
|
}
|
2020-12-26 22:35:43 +13:00
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
fn show_required_popovers(popovers: &GuiPopovers, current_mode: &NotebookMainEnum, hashmap: &HashMap<NotebookMainEnum, Vec<PopoverTypes>>) {
|
|
|
|
let buttons_popover_select_all = popovers.buttons_popover_select_all.clone();
|
|
|
|
let buttons_popover_unselect_all = popovers.buttons_popover_unselect_all.clone();
|
|
|
|
let buttons_popover_reverse = popovers.buttons_popover_reverse.clone();
|
|
|
|
let buttons_popover_select_all_except_oldest = popovers.buttons_popover_select_all_except_oldest.clone();
|
|
|
|
let buttons_popover_select_all_except_newest = popovers.buttons_popover_select_all_except_newest.clone();
|
|
|
|
let buttons_popover_select_one_oldest = popovers.buttons_popover_select_one_oldest.clone();
|
|
|
|
let buttons_popover_select_one_newest = popovers.buttons_popover_select_one_newest.clone();
|
|
|
|
let buttons_popover_select_custom = popovers.buttons_popover_select_custom.clone();
|
|
|
|
let buttons_popover_unselect_custom = popovers.buttons_popover_unselect_custom.clone();
|
|
|
|
let buttons_popover_select_all_images_except_biggest = popovers.buttons_popover_select_all_images_except_biggest.clone();
|
|
|
|
let buttons_popover_select_all_images_except_smallest = popovers.buttons_popover_select_all_images_except_smallest.clone();
|
2020-12-26 22:35:43 +13:00
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
let separator_select_custom = popovers.separator_select_custom.clone();
|
|
|
|
let separator_select_date = popovers.separator_select_date.clone();
|
|
|
|
let separator_select_image_size = popovers.separator_select_image_size.clone();
|
|
|
|
let separator_select_reverse = popovers.separator_select_reverse.clone();
|
2020-12-26 22:35:43 +13:00
|
|
|
|
|
|
|
let vec = hashmap.get(current_mode).unwrap();
|
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
if vec.contains(&PopoverTypes::All) {
|
2020-12-26 22:35:43 +13:00
|
|
|
buttons_popover_select_all.show();
|
|
|
|
buttons_popover_unselect_all.show();
|
|
|
|
} else {
|
|
|
|
buttons_popover_select_all.hide();
|
|
|
|
buttons_popover_unselect_all.hide();
|
|
|
|
}
|
|
|
|
|
2021-12-02 08:09:04 +13:00
|
|
|
if vec.contains(&PopoverTypes::Size) {
|
2020-12-26 22:35:43 +13:00
|
|
|
buttons_popover_select_all_images_except_biggest.show();
|
|
|
|
buttons_popover_select_all_images_except_smallest.show();
|
|
|
|
separator_select_image_size.show();
|
|
|
|
} else {
|
|
|
|
buttons_popover_select_all_images_except_biggest.hide();
|
|
|
|
buttons_popover_select_all_images_except_smallest.hide();
|
|
|
|
separator_select_image_size.hide();
|
|
|
|
}
|
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
if vec.contains(&PopoverTypes::Reverse) {
|
2020-12-26 22:35:43 +13:00
|
|
|
buttons_popover_reverse.show();
|
|
|
|
separator_select_reverse.show();
|
|
|
|
} else {
|
|
|
|
buttons_popover_reverse.hide();
|
|
|
|
separator_select_reverse.hide();
|
|
|
|
}
|
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
if vec.contains(&PopoverTypes::Custom) {
|
2020-12-26 22:35:43 +13:00
|
|
|
buttons_popover_select_custom.show();
|
|
|
|
buttons_popover_unselect_custom.show();
|
|
|
|
separator_select_custom.show();
|
|
|
|
} else {
|
|
|
|
buttons_popover_select_custom.hide();
|
|
|
|
buttons_popover_unselect_custom.hide();
|
|
|
|
separator_select_custom.hide();
|
|
|
|
}
|
|
|
|
|
2021-11-25 20:36:49 +13:00
|
|
|
if vec.contains(&PopoverTypes::Date) {
|
2020-12-26 22:35:43 +13:00
|
|
|
buttons_popover_select_all_except_oldest.show();
|
|
|
|
buttons_popover_select_all_except_newest.show();
|
|
|
|
buttons_popover_select_one_oldest.show();
|
|
|
|
buttons_popover_select_one_newest.show();
|
|
|
|
separator_select_date.show();
|
|
|
|
} else {
|
|
|
|
buttons_popover_select_all_except_oldest.hide();
|
|
|
|
buttons_popover_select_all_except_newest.hide();
|
|
|
|
buttons_popover_select_one_oldest.hide();
|
|
|
|
buttons_popover_select_one_newest.hide();
|
|
|
|
separator_select_date.hide();
|
|
|
|
}
|
|
|
|
}
|