2024-01-30 23:33:07 +03:00
|
|
|
// GTK crates
|
2024-02-09 22:04:15 +03:00
|
|
|
mod config;
|
|
|
|
|
2024-02-20 18:42:53 +03:00
|
|
|
use std::env;
|
2024-02-09 00:49:42 +03:00
|
|
|
use adw::prelude::*;
|
|
|
|
use adw::*;
|
|
|
|
use gdk::Display;
|
2024-01-30 23:33:07 +03:00
|
|
|
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
|
|
|
|
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
|
|
|
|
use gtk::*;
|
|
|
|
|
2024-02-20 18:42:53 +03:00
|
|
|
use std::boxed::Box;
|
2024-02-18 15:11:52 +03:00
|
|
|
use users::*;
|
2024-02-20 18:42:53 +03:00
|
|
|
use config::{APP_ID};
|
2024-02-09 22:04:15 +03:00
|
|
|
|
2024-01-30 23:33:07 +03:00
|
|
|
// application crates
|
|
|
|
mod build_ui;
|
|
|
|
use crate::build_ui::build_ui;
|
2024-01-31 21:48:55 +03:00
|
|
|
/// first setup crates
|
|
|
|
mod first_setup;
|
2024-01-30 23:33:07 +03:00
|
|
|
|
2024-02-20 18:42:53 +03:00
|
|
|
// Init translations for current crate.
|
|
|
|
#[macro_use]
|
|
|
|
extern crate rust_i18n;
|
|
|
|
i18n!("locales", fallback = "en_US");
|
|
|
|
|
2024-01-30 23:33:07 +03:00
|
|
|
/// main function
|
|
|
|
fn main() {
|
2024-02-20 18:42:53 +03:00
|
|
|
let current_locale = match env::var_os("LANG") {
|
|
|
|
Some(v) => v.into_string().unwrap(),
|
|
|
|
None => panic!("$LANG is not set"),
|
|
|
|
};
|
|
|
|
rust_i18n::set_locale(current_locale.strip_suffix(".UTF-8").unwrap());
|
2024-02-09 00:49:42 +03:00
|
|
|
let application = adw::Application::new(
|
2024-02-09 22:04:15 +03:00
|
|
|
Some(APP_ID),
|
2024-02-09 00:49:42 +03:00
|
|
|
Default::default(),
|
|
|
|
);
|
2024-01-30 23:33:07 +03:00
|
|
|
application.connect_startup(|app| {
|
|
|
|
// The CSS "magic" happens here.
|
|
|
|
let provider = CssProvider::new();
|
|
|
|
provider.load_from_string(include_str!("style.css"));
|
|
|
|
// We give the CssProvided to the default screen so the CSS rules we added
|
|
|
|
// can be applied to our window.
|
|
|
|
gtk::style_context_add_provider_for_display(
|
|
|
|
&Display::default().expect("Could not connect to a display."),
|
|
|
|
&provider,
|
|
|
|
STYLE_PROVIDER_PRIORITY_APPLICATION,
|
|
|
|
);
|
|
|
|
app.connect_activate(build_ui);
|
|
|
|
});
|
2024-02-09 00:49:42 +03:00
|
|
|
|
2024-02-24 00:35:07 +03:00
|
|
|
if get_current_username().unwrap() != "pikaos" {
|
2024-02-18 15:11:52 +03:00
|
|
|
application.run();
|
|
|
|
} else {
|
2024-02-24 00:35:07 +03:00
|
|
|
println!("Error: This program can only be run via an installed system user");
|
2024-02-18 15:11:52 +03:00
|
|
|
std::process::exit(1)
|
|
|
|
}
|
|
|
|
|
2024-01-30 23:33:07 +03:00
|
|
|
}
|