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
//! Abstraction for file selection.
//!
//! This module simplifies working with `gtk4::FileDialog` by encapsulating the
//! asynchronous logic and providing a simple interface for file paths.
/**
* file_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 file path.
pub type FileProcessorFunc = fn;
/// Internal handler that evaluates the asynchronous result of the dialog.
///
/// Extracts the path from the `gio::File` instance and passes it to the
/// provided processing function.
/// Opens a native file selection dialog.
///
/// The function automatically determines the parent window of the passed button
/// to anchor the dialog correctly (modally).
///
/// # Arguments
/// * `button` - The button that triggered the dialog (used to determine the main window).
/// * `process_func` - A function or function pointer that is called as soon as a file has been selected.
///
/// # Functionality
/// The dialog is launched asynchronously. The program continues to run during the selection,
/// and the result is processed internally before being passed to `process_func`.
///
/// # Usage:
///
/// ```rust
/// let btn1 = Button::with_label("File?:");
/// // define callback
/// fn something(pfad: PathBuf) {
/// println!("File: {:?}", pfad);
/// }
/// // connect signal
/// btn1.connect_clicked(move |b| {
/// show_file_chooser(b, something);
/// });
/// ```