2023-02-23 19:16:49 +00:00
|
|
|
use relm4::prelude::*;
|
|
|
|
use relm4::component::*;
|
|
|
|
|
|
|
|
use adw::prelude::*;
|
|
|
|
|
|
|
|
use anime_launcher_sdk::is_available;
|
|
|
|
|
2023-02-25 14:06:43 +00:00
|
|
|
use crate::i18n::*;
|
2023-02-23 19:16:49 +00:00
|
|
|
use super::main::FirstRunAppMsg;
|
|
|
|
|
|
|
|
pub struct TosWarningApp;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub enum TosWarningAppMsg {
|
|
|
|
Continue,
|
|
|
|
Exit
|
|
|
|
}
|
|
|
|
|
|
|
|
#[relm4::component(async, pub)]
|
|
|
|
impl SimpleAsyncComponent for TosWarningApp {
|
|
|
|
type Init = ();
|
|
|
|
type Input = TosWarningAppMsg;
|
|
|
|
type Output = FirstRunAppMsg;
|
|
|
|
|
|
|
|
view! {
|
|
|
|
adw::PreferencesPage {
|
|
|
|
set_hexpand: true,
|
|
|
|
|
|
|
|
add = &adw::PreferencesGroup {
|
2023-02-24 11:31:10 +00:00
|
|
|
set_valign: gtk::Align::Center,
|
|
|
|
set_vexpand: true,
|
|
|
|
|
2023-02-23 19:16:49 +00:00
|
|
|
gtk::Label {
|
2023-02-25 14:06:43 +00:00
|
|
|
set_label: &tr("tos-violation-warning"),
|
2023-02-23 19:16:49 +00:00
|
|
|
add_css_class: "title-1"
|
2023-02-25 14:06:43 +00:00
|
|
|
}
|
|
|
|
},
|
2023-02-23 19:16:49 +00:00
|
|
|
|
2023-02-25 14:06:43 +00:00
|
|
|
add = &adw::PreferencesGroup {
|
|
|
|
gtk::Label {
|
|
|
|
set_label: &tr("tos-violation-warning-message"),
|
|
|
|
set_wrap: true,
|
|
|
|
set_selectable: true
|
2023-02-23 19:16:49 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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 {
|
2023-02-25 14:06:43 +00:00
|
|
|
set_label: &tr("continue"),
|
2023-02-24 10:26:33 +00:00
|
|
|
set_css_classes: &["suggested-action", "pill"],
|
2023-02-23 19:16:49 +00:00
|
|
|
|
|
|
|
connect_clicked => TosWarningAppMsg::Continue
|
|
|
|
},
|
|
|
|
|
|
|
|
gtk::Button {
|
2023-02-25 14:06:43 +00:00
|
|
|
set_label: &tr("exit"),
|
2023-02-24 10:26:33 +00:00
|
|
|
add_css_class: "pill",
|
2023-02-23 19:16:49 +00:00
|
|
|
|
|
|
|
connect_clicked => TosWarningAppMsg::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 {
|
|
|
|
#[allow(unused_must_use)]
|
|
|
|
TosWarningAppMsg::Continue => {
|
|
|
|
if is_available("git") && is_available("xdelta3") {
|
|
|
|
sender.output(Self::Output::ScrollToDefaultPaths);
|
|
|
|
} else {
|
|
|
|
sender.output(Self::Output::ScrollToDependencies);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TosWarningAppMsg::Exit => {
|
|
|
|
// TODO: relm4 has some function for it
|
|
|
|
std::process::exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|