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 contrib;
13mod error_page;
14mod i18n;
15mod identity_verification_view;
16mod intent;
17mod login;
18mod prelude;
19mod secret;
20mod session;
21mod session_list;
22mod system_settings;
23mod user_facing_error;
24mod utils;
25mod window;
26
27use std::sync::LazyLock;
28
29use gettextrs::*;
30use gtk::{gdk::Display, gio, IconTheme};
31use tracing_subscriber::{fmt, prelude::*, EnvFilter};
32
33use self::{application::*, config::*, i18n::*, window::Window};
34
35/// The default tokio runtime to be used for async tasks
36pub static RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
37    tokio::runtime::Runtime::new().expect("creating tokio runtime should succeed")
38});
39
40fn main() {
41    // Initialize logger, debug is carried out via debug!, info!, warn! and error!.
42    // Default to the INFO level for this crate and WARN for everything else.
43    // It can be overridden with the RUST_LOG environment variable.
44    let env_filter =
45        EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("fractal=info,warn"));
46
47    tracing_subscriber::registry()
48        .with(fmt::layer().with_filter(env_filter))
49        .init();
50
51    // Prepare i18n
52    setlocale(LocaleCategory::LcAll, "");
53    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Invalid argument passed to bindtextdomain");
54    textdomain(GETTEXT_PACKAGE).expect("Invalid string passed to textdomain");
55
56    gtk::glib::set_application_name("Fractal");
57
58    gtk::init().expect("Could not start GTK4");
59    gst::init().expect("Could not initialize gst");
60
61    #[cfg(target_os = "linux")]
62    aperture::init(APP_ID);
63
64    let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file");
65    gio::resources_register(&res);
66    let ui_res = gio::Resource::load(UI_RESOURCES_FILE).expect("Could not load UI gresource file");
67    gio::resources_register(&ui_res);
68
69    IconTheme::for_display(&Display::default().unwrap())
70        .add_resource_path("/org/gnome/Fractal/icons");
71
72    let app = Application::new();
73    app.run();
74}