1
0
Fork 0
mirror of synced 2024-06-18 02:15:30 +12:00

Show error when all directories are reference folders

This commit is contained in:
Rafał Mikrut 2022-07-30 21:45:11 +02:00
parent 9a1e49f424
commit 96dbcc3bae
4 changed files with 69 additions and 1 deletions

View file

@ -1,3 +1,10 @@
## Version 5.0.1 - .08.2022r
- Fixed problem with removing ending slash with empty disk window path
- Added to CLI bad extensions mode
- Fixed default sorting method in CLI where finding biggest files
- Added tests to CI
- Show error message when all directories are set as reference folders
## Version 5.0.0 - 28.07.2022r
- GUI ported to use GTK 4 - [#466](https://github.com/qarmin/czkawka/pull/466)
- Use multithreading and improved algorithm to compare image hashes - [#762](https://github.com/qarmin/czkawka/pull/762)

View file

@ -463,6 +463,7 @@ invalid_symlink_infinite_recursion = Infinite recursion
invalid_symlink_non_existent_destination = Non-existent destination file
# Other
selected_all_reference_folders = Cannot start search, when all directories are set as reference folders
searching_for_data = Searching data, it may take a while, please wait...
text_view_messages = MESSAGES
text_view_warnings = WARNINGS

View file

@ -117,6 +117,13 @@ pub fn connect_button_search(
let check_button_settings_save_also_json = gui_data.settings.check_button_settings_save_also_json.clone();
buttons_search_clone.connect_clicked(move |_| {
// Check if user selected all referenced folders
let list_store_included_directories = get_list_store(&tree_view_included_directories);
if check_if_list_store_column_have_all_same_values(&list_store_included_directories, ColumnsIncludedDirectory::ReferenceButton as i32, true) {
entry_info.set_text(&flg!("selected_all_reference_folders"));
return;
}
let included_directories = get_path_buf_from_vector_of_strings(get_string_from_list_store(&tree_view_included_directories, ColumnsIncludedDirectory::Path as i32, None));
let excluded_directories = get_path_buf_from_vector_of_strings(get_string_from_list_store(&tree_view_excluded_directories, ColumnsExcludedDirectory::Path as i32, None));
let reference_directories = get_path_buf_from_vector_of_strings(get_string_from_list_store(

View file

@ -743,6 +743,24 @@ pub fn check_if_value_is_in_list_store(list_store: &ListStore, column: i32, valu
false
}
pub fn check_if_list_store_column_have_all_same_values(list_store: &ListStore, column: i32, value: bool) -> bool {
if let Some(iter) = list_store.iter_first() {
loop {
let list_store_value: bool = list_store.get::<bool>(&iter, column as i32);
if value != list_store_value {
return false;
}
if !list_store.iter_next(&iter) {
break;
}
}
return true;
}
false
}
#[cfg(test)]
mod test {
use gtk4::prelude::*;
@ -750,9 +768,44 @@ mod test {
use image::DynamicImage;
use crate::help_functions::{
change_dimension_to_krotka, check_if_value_is_in_list_store, get_all_boxes_from_widget, get_all_direct_children, get_max_file_name, get_pixbuf_from_dynamic_image,
change_dimension_to_krotka, check_if_list_store_column_have_all_same_values, check_if_value_is_in_list_store, get_all_boxes_from_widget, get_all_direct_children,
get_max_file_name, get_pixbuf_from_dynamic_image,
};
#[gtk4::test]
fn test_check_if_list_store_column_have_all_same_values() {
let columns_types: &[glib::types::Type] = &[glib::types::Type::BOOL];
let list_store = gtk4::ListStore::new(columns_types);
list_store.clear();
let values_to_add: &[(u32, &dyn ToValue)] = &[(0, &true), (0, &true), (0, &false)];
for i in values_to_add {
list_store.set(&list_store.append(), &[*i]);
}
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, true));
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, false));
list_store.clear();
let values_to_add: &[(u32, &dyn ToValue)] = &[(0, &true), (0, &true), (0, &true)];
for i in values_to_add {
list_store.set(&list_store.append(), &[*i]);
}
assert!(check_if_list_store_column_have_all_same_values(&list_store, 0, true));
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, false));
list_store.clear();
let values_to_add: &[(u32, &dyn ToValue)] = &[(0, &false)];
for i in values_to_add {
list_store.set(&list_store.append(), &[*i]);
}
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, true));
assert!(check_if_list_store_column_have_all_same_values(&list_store, 0, false));
list_store.clear();
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, true));
assert!(!check_if_list_store_column_have_all_same_values(&list_store, 0, false));
}
#[gtk4::test]
fn test_check_if_value_is_in_list_store() {
let columns_types: &[glib::types::Type] = &[glib::types::Type::STRING];