Skip to main content

hyprshell_config_edit_lib/
start.rs

1use crate::APPLICATION_EDIT_ID;
2use crate::components::root::{Root, RootInit};
3use relm4::RelmApp;
4use relm4::adw::gdk::Display;
5use relm4::adw::gtk::{
6    CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION, style_context_add_provider_for_display,
7};
8use std::path::PathBuf;
9
10/// # Panics
11/// if no display was found
12pub fn start(config_file: PathBuf, css_file: PathBuf, system_data_dir: PathBuf, generate: bool) {
13    let relm = RelmApp::new(&format!(
14        "{}{}",
15        APPLICATION_EDIT_ID,
16        if cfg!(debug_assertions) { "-test" } else { "" }
17    ))
18    .with_args(vec![]);
19
20    let provider_app = CssProvider::new();
21    provider_app.load_from_string(include_str!("styles.css"));
22    style_context_add_provider_for_display(
23        &Display::default().expect("Could not connect to a display."),
24        &provider_app,
25        STYLE_PROVIDER_PRIORITY_APPLICATION,
26    );
27
28    relm.run::<Root>(RootInit {
29        config_file: config_file.into_boxed_path(),
30        system_data_dir: system_data_dir.into_boxed_path(),
31        css_file: css_file.into_boxed_path(),
32        generate,
33    });
34}