1 use crate::gui_data::*;
2 use crate::help_functions::*;
3 use directories_next::ProjectDirs;
4 use gtk::prelude::*;
5 use std::fs::File;
6 use std::io::Write;
7 use std::path::Path;
8 use std::{env, fs};
9 
10 // TODO add more settings, maybe to different dialog window
11 
12 const SAVE_FILE_NAME: &str = "czkawka_gui_config.txt";
13 
save_configuration(gui_data: &GuiData, manual_execution: bool)14 pub fn save_configuration(gui_data: &GuiData, manual_execution: bool) {
15     let check_button_settings_save_at_exit = gui_data.settings.check_button_settings_save_at_exit.clone();
16     let text_view_errors = gui_data.text_view_errors.clone();
17 
18     reset_text_view(&text_view_errors);
19 
20     if !manual_execution && !check_button_settings_save_at_exit.is_active() {
21         // When check button is deselected, not save configuration at exit
22         return;
23     }
24     if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") {
25         // Lin: /home/username/.config/czkawka
26         // Win: C:\Users\Username\AppData\Roaming\Qarmin\Czkawka\config
27         // Mac: /Users/Username/Library/Application Support/pl.Qarmin.Czkawka
28 
29         let config_dir = proj_dirs.config_dir();
30         if config_dir.exists() {
31             if !config_dir.is_dir() {
32                 add_text_to_text_view(&text_view_errors, format!("Cannot create save file inside {} because this isn't a folder.", config_dir.display()).as_str());
33                 return;
34             }
35         } else if let Err(e) = fs::create_dir_all(config_dir) {
36             add_text_to_text_view(&text_view_errors, format!("Failed configuration to create configuration folder {}, reason {}", config_dir.display(), e).as_str());
37             return;
38         }
39         let mut data_to_save: Vec<String> = Vec::with_capacity(16);
40 
41         //// Included Directories
42         data_to_save.push("--included_directories:".to_string());
43         let tree_view_included_directories = gui_data.upper_notebook.tree_view_included_directories.clone();
44         let list_store = get_list_store(&tree_view_included_directories);
45         if let Some(iter) = list_store.iter_first() {
46             loop {
47                 data_to_save.push(list_store.value(&iter, ColumnsDirectory::Path as i32).get::<String>().unwrap());
48                 if !list_store.iter_next(&iter) {
49                     break;
50                 }
51             }
52         }
53 
54         //// Excluded Directories
55         data_to_save.push("--excluded_directories:".to_string());
56         let tree_view_excluded_directories = gui_data.upper_notebook.tree_view_excluded_directories.clone();
57         let list_store = get_list_store(&tree_view_excluded_directories);
58         if let Some(iter) = list_store.iter_first() {
59             loop {
60                 data_to_save.push(list_store.value(&iter, ColumnsDirectory::Path as i32).get::<String>().unwrap());
61                 if !list_store.iter_next(&iter) {
62                     break;
63                 }
64             }
65         }
66 
67         {
68             //// Excluded Items
69             data_to_save.push("--excluded_items:".to_string());
70             let entry_excluded_items = gui_data.upper_notebook.entry_excluded_items.clone();
71             for item in entry_excluded_items.text().split(',') {
72                 if item.trim().is_empty() {
73                     continue;
74                 }
75                 data_to_save.push(item.to_string());
76             }
77 
78             //// Allowed extensions
79             data_to_save.push("--allowed_extensions:".to_string());
80             let entry_allowed_extensions = gui_data.upper_notebook.entry_allowed_extensions.clone();
81             for extension in entry_allowed_extensions.text().split(',') {
82                 if extension.trim().is_empty() {
83                     continue;
84                 }
85                 data_to_save.push(extension.to_string());
86             }
87 
88             //// Save at exit
89             data_to_save.push("--save_at_exit:".to_string());
90             let check_button_settings_save_at_exit = gui_data.settings.check_button_settings_save_at_exit.clone();
91             data_to_save.push(check_button_settings_save_at_exit.is_active().to_string());
92 
93             //// Load at start
94             data_to_save.push("--load_at_start:".to_string());
95             let check_button_settings_load_at_start = gui_data.settings.check_button_settings_load_at_start.clone();
96             data_to_save.push(check_button_settings_load_at_start.is_active().to_string());
97 
98             //// Confirm deletion of files
99             data_to_save.push("--confirm_deletion:".to_string());
100             let check_button_settings_confirm_deletion = gui_data.settings.check_button_settings_confirm_deletion.clone();
101             data_to_save.push(check_button_settings_confirm_deletion.is_active().to_string());
102 
103             //// Confirm deletion of all files in group
104             data_to_save.push("--confirm_group_deletion:".to_string());
105             let check_button_settings_confirm_group_deletion = gui_data.settings.check_button_settings_confirm_group_deletion.clone();
106             data_to_save.push(check_button_settings_confirm_group_deletion.is_active().to_string());
107 
108             //// Show image previews in similar images
109             data_to_save.push("--show_previews_similar_images:".to_string());
110             let check_button_settings_show_preview_similar_images = gui_data.settings.check_button_settings_show_preview_similar_images.clone();
111             data_to_save.push(check_button_settings_show_preview_similar_images.is_active().to_string());
112 
113             //// Show image previews in duplicates
114             data_to_save.push("--show_previews_duplicates:".to_string());
115             let check_button_settings_show_preview_duplicates = gui_data.settings.check_button_settings_show_preview_duplicates.clone();
116             data_to_save.push(check_button_settings_show_preview_duplicates.is_active().to_string());
117 
118             //// Show bottom text panel with errors
119             data_to_save.push("--bottom_text_panel:".to_string());
120             let check_button_settings_show_text_view = gui_data.settings.check_button_settings_show_text_view.clone();
121             data_to_save.push(check_button_settings_show_text_view.is_active().to_string());
122 
123             //// Hide/Show hard linked files, with same inodes
124             data_to_save.push("--hide_hard_links:".to_string());
125             let check_button_settings_hide_hard_links = gui_data.settings.check_button_settings_hide_hard_links.clone();
126             data_to_save.push(check_button_settings_hide_hard_links.is_active().to_string());
127 
128             //// Use cache system
129             data_to_save.push("--use_cache:".to_string());
130             let check_button_settings_use_cache = gui_data.settings.check_button_settings_use_cache.clone();
131             data_to_save.push(check_button_settings_use_cache.is_active().to_string());
132 
133             //// Delete to trash
134             data_to_save.push("--use_trash:".to_string());
135             let check_button_settings_use_trash = gui_data.settings.check_button_settings_use_trash.clone();
136             data_to_save.push(check_button_settings_use_trash.is_active().to_string());
137 
138             //// minimal cache file size
139             data_to_save.push("--cache_minimal_file_size:".to_string());
140             let entry_settings_cache_file_minimal_size = gui_data.settings.entry_settings_cache_file_minimal_size.clone();
141             data_to_save.push(entry_settings_cache_file_minimal_size.text().as_str().parse::<u64>().unwrap_or(2 * 1024 * 1024).to_string());
142         }
143 
144         // Creating/Opening config file
145 
146         let config_file = config_dir.join(Path::new(SAVE_FILE_NAME));
147 
148         let mut config_file_handler = match File::create(&config_file) {
149             Ok(t) => t,
150             Err(e) => {
151                 add_text_to_text_view(&text_view_errors, format!("Failed to create config file {}, reason {}", config_dir.display(), e).as_str());
152                 return;
153             }
154         };
155 
156         let mut data_saved: bool = false;
157         for data in data_to_save {
158             match writeln!(config_file_handler, "{}", data) {
159                 Ok(_inspected) => {
160                     data_saved = true;
161                 }
162                 Err(_inspected) => {
163                     data_saved = false;
164                     break;
165                 }
166             }
167         }
168         if data_saved {
169             add_text_to_text_view(&text_view_errors, format!("Saved configuration to file {}", config_file.display()).as_str());
170         } else {
171             add_text_to_text_view(&text_view_errors, format!("Failed to save configuration data to file {}", config_file.display()).as_str());
172         }
173     } else {
174         add_text_to_text_view(&text_view_errors, "Failed to get home directory, so can't save file.");
175     }
176 }
177 
178 enum TypeOfLoadedData {
179     None,
180     IncludedDirectories,
181     ExcludedDirectories,
182     ExcludedItems,
183     AllowedExtensions,
184     LoadingAtStart,
185     SavingAtExit,
186     ConfirmDeletion,
187     ConfirmGroupDeletion,
188     ShowPreviewSimilarImages,
189     ShowPreviewDuplicates,
190     BottomTextPanel,
191     HideHardLinks,
192     UseCache,
193     UseTrash,
194     CacheMinimalSize,
195 }
196 
load_configuration(gui_data: &GuiData, manual_execution: bool)197 pub fn load_configuration(gui_data: &GuiData, manual_execution: bool) {
198     let text_view_errors = gui_data.text_view_errors.clone();
199 
200     reset_text_view(&text_view_errors);
201 
202     if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") {
203         // Lin: /home/username/.config/czkawka
204         // Win: C:\Users\Username\AppData\Roaming\Qarmin\Czkawka\config
205         // Mac: /Users/Username/Library/Application Support/pl.Qarmin.Czkawka
206 
207         let config_dir = proj_dirs.config_dir();
208         let config_file = config_dir.join(Path::new(SAVE_FILE_NAME));
209         if !config_file.exists() || !config_file.is_file() {
210             if manual_execution {
211                 // Don't show errors when there is no configuration file when starting app
212                 add_text_to_text_view(&text_view_errors, format!("Cannot load configuration from file {:?}.", config_file.display()).as_str());
213             }
214             return;
215         }
216 
217         // Loading Data
218         let loaded_data: String = match fs::read_to_string(&config_file) {
219             Ok(t) => t,
220             Err(e) => {
221                 add_text_to_text_view(&text_view_errors, format!("Failed to read data from file {:?}, reason {}", config_file, e).as_str());
222                 return;
223             }
224         };
225 
226         // Parsing Data - this are default values
227 
228         let mut included_directories: Vec<String> = Vec::new();
229         let mut excluded_directories: Vec<String> = Vec::new();
230         let mut excluded_items: Vec<String> = Vec::new();
231         let mut allowed_extensions: Vec<String> = Vec::new();
232         let mut loading_at_start: bool = true;
233         let mut saving_at_exit: bool = true;
234         let mut confirm_deletion: bool = true;
235         let mut confirm_group_deletion: bool = true;
236         let mut show_previews_similar_images: bool = true;
237         let mut show_previews_duplicates: bool = true;
238         let mut bottom_text_panel: bool = true;
239         let mut hide_hard_links: bool = true;
240         let mut use_cache: bool = true;
241         let mut use_trash: bool = false;
242         let mut cache_minimal_size: u64 = 2 * 1024 * 1024;
243 
244         let mut current_type = TypeOfLoadedData::None;
245         for (line_number, line) in loaded_data.replace("\r\n", "\n").split('\n').enumerate() {
246             let line: String = line.trim().to_string();
247             if line.is_empty() {
248                 continue; // Empty line, so we just skip it
249             }
250             if line.starts_with("--included_directories") {
251                 current_type = TypeOfLoadedData::IncludedDirectories;
252             } else if line.starts_with("--excluded_directories") {
253                 current_type = TypeOfLoadedData::ExcludedDirectories;
254             } else if line.starts_with("--excluded_items") {
255                 current_type = TypeOfLoadedData::ExcludedItems;
256             } else if line.starts_with("--allowed_extensions") {
257                 current_type = TypeOfLoadedData::AllowedExtensions;
258             } else if line.starts_with("--load_at_start") {
259                 current_type = TypeOfLoadedData::LoadingAtStart;
260             } else if line.starts_with("--save_at_exit") {
261                 current_type = TypeOfLoadedData::SavingAtExit;
262             } else if line.starts_with("--confirm_deletion") {
263                 current_type = TypeOfLoadedData::ConfirmDeletion;
264             } else if line.starts_with("--confirm_group_deletion") {
265                 current_type = TypeOfLoadedData::ConfirmGroupDeletion;
266             } else if line.starts_with("--show_previews_similar_images") {
267                 current_type = TypeOfLoadedData::ShowPreviewSimilarImages;
268             } else if line.starts_with("--show_previews_duplicates") {
269                 current_type = TypeOfLoadedData::ShowPreviewDuplicates;
270             } else if line.starts_with("--bottom_text_panel") {
271                 current_type = TypeOfLoadedData::BottomTextPanel;
272             } else if line.starts_with("--hide_hard_links") {
273                 current_type = TypeOfLoadedData::HideHardLinks;
274             } else if line.starts_with("--use_cache") {
275                 current_type = TypeOfLoadedData::UseCache;
276             } else if line.starts_with("--use_trash") {
277                 current_type = TypeOfLoadedData::UseTrash;
278             } else if line.starts_with("--cache_minimal_file_size") {
279                 current_type = TypeOfLoadedData::CacheMinimalSize;
280             } else if line.starts_with("--") {
281                 current_type = TypeOfLoadedData::None;
282                 add_text_to_text_view(
283                     &text_view_errors,
284                     format!("Found invalid header in line {} \"{}\" when loading file {:?} (save file may be from different Czkawka version)", line_number, line, config_file).as_str(),
285                 );
286             } else {
287                 match current_type {
288                     TypeOfLoadedData::None => {
289                         add_text_to_text_view(
290                             &text_view_errors,
291                             format!("Found orphan data in line {} \"{}\" when loading file {:?} (save file may be from different Czkawka version)", line_number, line, config_file).as_str(),
292                         );
293                     }
294                     TypeOfLoadedData::IncludedDirectories => {
295                         included_directories.push(line);
296                     }
297                     TypeOfLoadedData::ExcludedDirectories => {
298                         excluded_directories.push(line);
299                     }
300                     TypeOfLoadedData::ExcludedItems => {
301                         excluded_items.push(line);
302                     }
303                     TypeOfLoadedData::AllowedExtensions => {
304                         allowed_extensions.push(line);
305                     }
306                     TypeOfLoadedData::LoadingAtStart => {
307                         let line = line.to_lowercase();
308                         if line == "1" || line == "true" {
309                             loading_at_start = true;
310                         } else if line == "0" || line == "false" {
311                             loading_at_start = false;
312                         } else {
313                             add_text_to_text_view(
314                                 &text_view_errors,
315                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
316                             );
317                         }
318                     }
319                     TypeOfLoadedData::SavingAtExit => {
320                         let line = line.to_lowercase();
321                         if line == "1" || line == "true" {
322                             saving_at_exit = true;
323                         } else if line == "0" || line == "false" {
324                             saving_at_exit = false;
325                         } else {
326                             add_text_to_text_view(
327                                 &text_view_errors,
328                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
329                             );
330                         }
331                     }
332                     TypeOfLoadedData::ConfirmDeletion => {
333                         let line = line.to_lowercase();
334                         if line == "1" || line == "true" {
335                             confirm_deletion = true;
336                         } else if line == "0" || line == "false" {
337                             confirm_deletion = false;
338                         } else {
339                             add_text_to_text_view(
340                                 &text_view_errors,
341                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
342                             );
343                         }
344                     }
345                     TypeOfLoadedData::ConfirmGroupDeletion => {
346                         let line = line.to_lowercase();
347                         if line == "1" || line == "true" {
348                             confirm_group_deletion = true;
349                         } else if line == "0" || line == "false" {
350                             confirm_group_deletion = false;
351                         } else {
352                             add_text_to_text_view(
353                                 &text_view_errors,
354                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
355                             );
356                         }
357                     }
358                     TypeOfLoadedData::ShowPreviewSimilarImages => {
359                         let line = line.to_lowercase();
360                         if line == "1" || line == "true" {
361                             show_previews_similar_images = true;
362                         } else if line == "0" || line == "false" {
363                             show_previews_similar_images = false;
364                         } else {
365                             add_text_to_text_view(
366                                 &text_view_errors,
367                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
368                             );
369                         }
370                     }
371                     TypeOfLoadedData::ShowPreviewDuplicates => {
372                         let line = line.to_lowercase();
373                         if line == "1" || line == "true" {
374                             show_previews_duplicates = true;
375                         } else if line == "0" || line == "false" {
376                             show_previews_duplicates = false;
377                         } else {
378                             add_text_to_text_view(
379                                 &text_view_errors,
380                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
381                             );
382                         }
383                     }
384                     TypeOfLoadedData::BottomTextPanel => {
385                         let line = line.to_lowercase();
386                         if line == "1" || line == "true" {
387                             bottom_text_panel = true;
388                         } else if line == "0" || line == "false" {
389                             bottom_text_panel = false;
390                         } else {
391                             add_text_to_text_view(
392                                 &text_view_errors,
393                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
394                             );
395                         }
396                     }
397                     TypeOfLoadedData::HideHardLinks => {
398                         let line = line.to_lowercase();
399                         if line == "1" || line == "true" {
400                             hide_hard_links = true;
401                         } else if line == "0" || line == "false" {
402                             hide_hard_links = false;
403                         } else {
404                             add_text_to_text_view(
405                                 &text_view_errors,
406                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
407                             );
408                         }
409                     }
410                     TypeOfLoadedData::UseCache => {
411                         let line = line.to_lowercase();
412                         if line == "1" || line == "true" {
413                             use_cache = true;
414                         } else if line == "0" || line == "false" {
415                             use_cache = false;
416                         } else {
417                             add_text_to_text_view(
418                                 &text_view_errors,
419                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
420                             );
421                         }
422                     }
423                     TypeOfLoadedData::UseTrash => {
424                         let line = line.to_lowercase();
425                         if line == "1" || line == "true" {
426                             use_trash = true;
427                         } else if line == "0" || line == "false" {
428                             use_trash = false;
429                         } else {
430                             add_text_to_text_view(
431                                 &text_view_errors,
432                                 format!("Found invalid data in line {} \"{}\" isn't proper value(0/1/true/false) when loading file {:?}", line_number, line, config_file).as_str(),
433                             );
434                         }
435                     }
436                     TypeOfLoadedData::CacheMinimalSize => {
437                         if let Ok(number) = line.parse::<u64>() {
438                             cache_minimal_size = number;
439                         } else {
440                             add_text_to_text_view(
441                                 &text_view_errors,
442                                 format!("Found invalid data in line {} \"{}\" isn't proper value(u64) when loading file {:?}", line_number, line, config_file).as_str(),
443                             );
444                         }
445                     }
446                 }
447             }
448         }
449 
450         // Setting data
451         if manual_execution || loading_at_start {
452             //// Included Directories
453             let tree_view_included_directories = gui_data.upper_notebook.tree_view_included_directories.clone();
454             let list_store = get_list_store(&tree_view_included_directories);
455             list_store.clear();
456 
457             for directory in included_directories {
458                 let values: [(u32, &dyn ToValue); 1] = [(0, &directory)];
459                 list_store.set(&list_store.append(), &values);
460             }
461 
462             //// Exclude Directories
463             let tree_view_excluded_directories = gui_data.upper_notebook.tree_view_excluded_directories.clone();
464             let list_store = get_list_store(&tree_view_excluded_directories);
465             list_store.clear();
466 
467             for directory in excluded_directories {
468                 let values: [(u32, &dyn ToValue); 1] = [(0, &directory)];
469                 list_store.set(&list_store.append(), &values);
470             }
471 
472             //// Excluded Items
473             let entry_excluded_items = gui_data.upper_notebook.entry_excluded_items.clone();
474             entry_excluded_items.set_text(excluded_items.iter().map(|e| e.to_string() + ",").collect::<String>().as_str());
475 
476             //// Allowed extensions
477             let entry_allowed_extensions = gui_data.upper_notebook.entry_allowed_extensions.clone();
478             entry_allowed_extensions.set_text(allowed_extensions.iter().map(|e| e.to_string() + ",").collect::<String>().as_str());
479 
480             //// Buttons
481             gui_data.settings.check_button_settings_load_at_start.set_active(loading_at_start);
482             gui_data.settings.check_button_settings_save_at_exit.set_active(saving_at_exit);
483             gui_data.settings.check_button_settings_confirm_deletion.set_active(confirm_deletion);
484             gui_data.settings.check_button_settings_confirm_group_deletion.set_active(confirm_group_deletion);
485             gui_data.settings.check_button_settings_show_preview_similar_images.set_active(show_previews_similar_images);
486             gui_data.settings.check_button_settings_show_preview_duplicates.set_active(show_previews_duplicates);
487 
488             gui_data.settings.check_button_settings_show_text_view.set_active(bottom_text_panel);
489             if !bottom_text_panel {
490                 gui_data.scrolled_window_errors.hide();
491             } else {
492                 gui_data.scrolled_window_errors.show();
493             }
494             gui_data.settings.check_button_settings_hide_hard_links.set_active(hide_hard_links);
495             gui_data.settings.check_button_settings_use_cache.set_active(use_cache);
496             gui_data.settings.check_button_settings_use_trash.set_active(use_trash);
497             gui_data.settings.entry_settings_cache_file_minimal_size.set_text(cache_minimal_size.to_string().as_str());
498         } else {
499             gui_data.settings.check_button_settings_load_at_start.set_active(false);
500         }
501 
502         if manual_execution {
503             add_text_to_text_view(&text_view_errors, format!("Properly loaded configuration from file {:?}", config_file).as_str());
504         }
505     } else {
506         add_text_to_text_view(&text_view_errors, "Failed to get home directory, so can't load file.");
507     }
508 }
509 
reset_configuration(gui_data: &GuiData, manual_clearing: bool)510 pub fn reset_configuration(gui_data: &GuiData, manual_clearing: bool) {
511     // TODO Maybe add popup dialog to confirm resetting
512     let text_view_errors = gui_data.text_view_errors.clone();
513 
514     reset_text_view(&text_view_errors);
515 
516     // Resetting included directories
517     {
518         let tree_view_included_directories = gui_data.upper_notebook.tree_view_included_directories.clone();
519         let list_store = get_list_store(&tree_view_included_directories);
520         list_store.clear();
521 
522         let current_dir: String = match env::current_dir() {
523             Ok(t) => t.to_str().unwrap().to_string(),
524             Err(_inspected) => {
525                 if cfg!(target_family = "unix") {
526                     add_text_to_text_view(&text_view_errors, "Failed to read current directory, setting /home instead");
527                     "/home".to_string()
528                 } else if cfg!(target_family = "windows") {
529                     add_text_to_text_view(&text_view_errors, "Failed to read current directory, setting C:\\ instead");
530                     "C:\\".to_string()
531                 } else {
532                     "".to_string()
533                 }
534             }
535         };
536 
537         let values: [(u32, &dyn ToValue); 1] = [(0, &current_dir)];
538         list_store.set(&list_store.append(), &values);
539     }
540     // Resetting excluded directories
541     {
542         let tree_view_excluded_directories = gui_data.upper_notebook.tree_view_excluded_directories.clone();
543         let list_store = get_list_store(&tree_view_excluded_directories);
544         list_store.clear();
545         if cfg!(target_family = "unix") {
546             for i in ["/proc", "/dev", "/sys", "/run", "/snap"].iter() {
547                 let values: [(u32, &dyn ToValue); 1] = [(0, &i)];
548                 list_store.set(&list_store.append(), &values);
549             }
550         }
551     }
552     // Resetting excluded items
553     {
554         let entry_excluded_items = gui_data.upper_notebook.entry_excluded_items.clone();
555         if cfg!(target_family = "unix") {
556             entry_excluded_items.set_text("*/.git/*,*/node_modules/*,*/lost+found/*,*/Trash/*,*/.Trash-*/*,*/snap/*,/home/*/.cache/*");
557         }
558         if cfg!(target_family = "windows") {
559             entry_excluded_items.set_text("*\\.git\\*,*\\node_modules\\*,*\\lost+found\\*,*:\\windows\\*");
560         }
561     }
562     // Resetting allowed extensions
563     {
564         let entry_allowed_extensions = gui_data.upper_notebook.entry_allowed_extensions.clone();
565         entry_allowed_extensions.set_text("");
566     }
567 
568     // Set settings
569     {
570         gui_data.settings.check_button_settings_save_at_exit.set_active(true);
571         gui_data.settings.check_button_settings_load_at_start.set_active(true);
572         gui_data.settings.check_button_settings_confirm_deletion.set_active(true);
573         gui_data.settings.check_button_settings_confirm_group_deletion.set_active(true);
574         gui_data.settings.check_button_settings_show_preview_similar_images.set_active(true);
575         gui_data.settings.check_button_settings_show_preview_duplicates.set_active(true);
576         gui_data.settings.check_button_settings_show_text_view.set_active(true);
577         gui_data.settings.check_button_settings_hide_hard_links.set_active(true);
578         gui_data.settings.check_button_settings_use_cache.set_active(true);
579         gui_data.settings.check_button_settings_use_trash.set_active(false);
580         gui_data.settings.entry_settings_cache_file_minimal_size.set_text("2097152");
581     }
582     if manual_clearing {
583         add_text_to_text_view(&text_view_errors, "Current configuration was cleared.");
584     }
585 }
586