pikman-update-manager/src/main.rs

55 lines
1.5 KiB
Rust
Raw Normal View History

2024-06-26 23:30:40 +02:00
mod apt_package_row;
2024-06-30 23:23:36 +02:00
mod apt_update_page;
mod build_ui;
mod config;
2024-06-26 01:16:38 +02:00
2024-06-30 23:23:36 +02:00
use crate::config::APP_ID;
2024-06-26 01:16:38 +02:00
use adw::prelude::*;
use adw::*;
2024-06-30 23:23:36 +02:00
use build_ui::build_ui;
2024-06-26 01:16:38 +02:00
use gdk::Display;
use gtk::*;
use std::boxed::Box;
2024-06-30 23:23:36 +02:00
use std::env;
2024-06-26 01:16:38 +02:00
// Init translations for current crate.
#[macro_use]
extern crate rust_i18n;
i18n!("locales", fallback = "en_US");
/// main function
fn main() {
let current_locale = match env::var_os("LANG") {
2024-06-30 23:23:36 +02:00
Some(v) => v
.into_string()
.unwrap()
.chars()
2024-06-29 00:03:47 +02:00
.take_while(|&ch| ch != '.')
.collect::<String>(),
2024-06-26 01:16:38 +02:00
None => panic!("$LANG is not set"),
};
2024-06-29 00:03:47 +02:00
rust_i18n::set_locale(&current_locale);
2024-06-30 23:23:36 +02:00
let application = adw::Application::new(Some(APP_ID), Default::default());
2024-06-26 01:16:38 +02: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);
});
//if get_current_username().unwrap() == "pikaos" {
// application.run();
//} else {
// println!("Error: This program can only be run via pikaos user");
// std::process::exit(1)
//}
application.run();
2024-06-30 23:23:36 +02:00
}