6024ef885e
Also loading icon was replaced by a `GtkSpinner` in components downloading page
98 lines
2.6 KiB
Rust
98 lines
2.6 KiB
Rust
use relm4::prelude::*;
|
|
use relm4::component::*;
|
|
|
|
use adw::prelude::*;
|
|
|
|
use crate::i18n::*;
|
|
use super::main::*;
|
|
|
|
pub struct FinishApp;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum FinishAppMsg {
|
|
Restart,
|
|
Exit
|
|
}
|
|
|
|
#[relm4::component(async, pub)]
|
|
impl SimpleAsyncComponent for FinishApp {
|
|
type Init = ();
|
|
type Input = FinishAppMsg;
|
|
type Output = FirstRunAppMsg;
|
|
|
|
view! {
|
|
adw::PreferencesPage {
|
|
set_hexpand: true,
|
|
|
|
add = &adw::PreferencesGroup {
|
|
set_valign: gtk::Align::Center,
|
|
set_vexpand: true,
|
|
|
|
gtk::Label {
|
|
set_label: "Everything's done!",
|
|
add_css_class: "title-1"
|
|
},
|
|
|
|
gtk::Label {
|
|
set_label: "All the basic components were downloaded. Now you can restart the launcher and download the game. Welcome to our club!",
|
|
|
|
set_justify: gtk::Justification::Center,
|
|
set_wrap: true,
|
|
set_margin_top: 32
|
|
}
|
|
},
|
|
|
|
add = &adw::PreferencesGroup {
|
|
set_valign: gtk::Align::Center,
|
|
set_vexpand: true,
|
|
|
|
gtk::Box {
|
|
set_orientation: gtk::Orientation::Horizontal,
|
|
set_halign: gtk::Align::Center,
|
|
set_spacing: 8,
|
|
|
|
gtk::Button {
|
|
set_label: "Restart",
|
|
set_css_classes: &["suggested-action", "pill"],
|
|
|
|
connect_clicked => FinishAppMsg::Restart
|
|
},
|
|
|
|
gtk::Button {
|
|
set_label: "Exit",
|
|
add_css_class: "pill",
|
|
|
|
connect_clicked => FinishAppMsg::Exit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn init(
|
|
_init: Self::Init,
|
|
root: Self::Root,
|
|
_sender: AsyncComponentSender<Self>,
|
|
) -> AsyncComponentParts<Self> {
|
|
let model = Self;
|
|
let widgets = view_output!();
|
|
|
|
AsyncComponentParts { model, widgets }
|
|
}
|
|
|
|
async fn update(&mut self, msg: Self::Input, _sender: AsyncComponentSender<Self>) {
|
|
match msg {
|
|
FinishAppMsg::Restart => {
|
|
std::process::Command::new(std::env::current_exe().unwrap()).spawn().unwrap();
|
|
|
|
// TODO: relm4 has some function for it
|
|
std::process::exit(0);
|
|
}
|
|
|
|
FinishAppMsg::Exit => {
|
|
// TODO: relm4 has some function for it
|
|
std::process::exit(0);
|
|
}
|
|
}
|
|
}
|
|
}
|