fractal/
main.rs

1#![doc(
2    html_logo_url = "https://gitlab.gnome.org/World/fractal/-/raw/main/data/icons/org.gnome.Fractal.svg?inline=false",
3    html_favicon_url = "https://gitlab.gnome.org/World/fractal/-/raw/main/data/icons/org.gnome.Fractal-symbolic.svg?inline=false"
4)]
5
6mod account_chooser_dialog;
7mod account_switcher;
8mod application;
9mod components;
10#[rustfmt::skip]
11mod config;
12mod account_settings;
13mod contrib;
14mod error_page;
15mod i18n;
16mod identity_verification_view;
17mod intent;
18mod login;
19mod prelude;
20mod secret;
21mod session;
22mod session_list;
23mod session_view;
24mod system_settings;
25mod user_facing_error;
26mod utils;
27mod window;
28
29use std::sync::LazyLock;
30
31use gettextrs::*;
32use gtk::{IconTheme, gdk::Display, gio};
33use tracing_subscriber::{EnvFilter, fmt, prelude::*};
34
35use self::{application::*, config::*, i18n::*, utils::OneshotNotifier, window::Window};
36
37/// The default tokio runtime to be used for async tasks
38static RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
39    tokio::runtime::Runtime::new().expect("creating tokio runtime should succeed")
40});
41
42/// The notifier to make sure that only one `GtkMediaFile` is played at a single
43/// time.
44static MEDIA_FILE_NOTIFIER: LazyLock<OneshotNotifier> =
45    LazyLock::new(|| OneshotNotifier::new("MEDIA_FILE_NOTIFIER"));
46
47fn main() {
48    // Initialize logger, debug is carried out via debug!, info!, warn! and error!.
49    // Default to the INFO level for this crate and WARN for everything else.
50    // It can be overridden with the RUST_LOG environment variable.
51    let env_filter =
52        EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("fractal=info,warn"));
53
54    tracing_subscriber::registry()
55        .with(fmt::layer().with_filter(env_filter))
56        .init();
57
58    // Prepare i18n
59    setlocale(LocaleCategory::LcAll, "");
60    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Invalid argument passed to bindtextdomain");
61    textdomain(GETTEXT_PACKAGE).expect("Invalid string passed to textdomain");
62
63    gtk::glib::set_application_name("Fractal");
64
65    gtk::init().expect("Could not start GTK4");
66    gst::init().expect("Could not initialize gst");
67
68    #[cfg(target_os = "linux")]
69    aperture::init(APP_ID);
70
71    let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file");
72    gio::resources_register(&res);
73    let ui_res = gio::Resource::load(UI_RESOURCES_FILE).expect("Could not load UI gresource file");
74    gio::resources_register(&ui_res);
75
76    IconTheme::for_display(&Display::default().unwrap())
77        .add_resource_path("/org/gnome/Fractal/icons");
78
79    let app = Application::new();
80    app.run();
81}