1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Abstraction for directory selection.
//!
//! This module encapsulates the logic of the `gtk4::FileDialog` for selecting folders.
//! It ensures that the selection process is asynchronous and that the UI
//! does not block during this time.
/**
* folder_chooser.rs
*
* (C) Copyright 2026 AtlantisOS Project
* by @NachtsternBuild
*
* License: GNU GENERAL PUBLIC LICENSE Version 3
*/
use *;
use ;
use PathBuf;
use crategettext;
/// Type alias for functions that process a selected directory path.
pub type FolderProcessorFunc = fn;
/// Internal handler for the result of the directory selection.
///
/// This function evaluates the asynchronous result, extracts the system path,
/// and passes it to the provided [FolderProcessorFunc].
/// Opens a dialog for selecting a directory.
///
/// Unlike the file selection dialog, this dialog allows only the selection
/// of folders. It is displayed modally over the window of the button that called it.
///
/// # Arguments
/// * `button` - The trigger for the dialog; used to determine the parent window.
/// * `process_func` - The callback that is called with the [PathBuf] after a successful selection.
///
/// # Functionality
/// Internally uses `FileDialog::select_folder`. The result is processed asynchronously,
/// so that the application can continue to respond to user interactions.
///
/// # Usage:
///
/// ```rust
/// let folder_btn = Button::with_label("Folder?:");
/// fn handle_folder(path: PathBuf) {
/// println!("path: {:?}", path);
/// }
/// // connect button
/// folder_btn.connect_clicked(move |btn| {
/// show_folder_chooser(btn, handle_folder);
/// });
/// ```