mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
add unsupported dialogue to be shown if not all prerequisits are fulfilled
This commit is contained in:
15
src/app.rs
15
src/app.rs
@@ -11,8 +11,10 @@ use gtk::{gio, glib};
|
||||
|
||||
use crate::config::{APP_ID, PROFILE};
|
||||
use crate::modals::about::AboutDialog;
|
||||
use crate::modals::unsupported::UnsupportedDialog;
|
||||
|
||||
pub(super) struct App {
|
||||
unsupported_dialog: Controller<UnsupportedDialog>,
|
||||
about_dialog: Controller<AboutDialog>,
|
||||
}
|
||||
|
||||
@@ -96,7 +98,15 @@ impl SimpleComponent for App {
|
||||
.launch(())
|
||||
.detach();
|
||||
|
||||
let model = Self { about_dialog };
|
||||
let unsupported_dialog = UnsupportedDialog::builder()
|
||||
.transient_for(root)
|
||||
.launch(())
|
||||
.detach();
|
||||
|
||||
let model = Self {
|
||||
about_dialog,
|
||||
unsupported_dialog,
|
||||
};
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
@@ -116,6 +126,9 @@ impl SimpleComponent for App {
|
||||
})
|
||||
};
|
||||
|
||||
let sender = model.unsupported_dialog.sender().clone();
|
||||
sender.send(()).unwrap();
|
||||
|
||||
actions.add_action(shortcuts_action);
|
||||
actions.add_action(about_action);
|
||||
actions.register_for_widget(&widgets.main_window);
|
||||
|
||||
@@ -42,6 +42,7 @@ fn main() {
|
||||
app.set_accelerators_for_action::<QuitAction>(&["<Control>q"]);
|
||||
|
||||
let app = RelmApp::from_app(app);
|
||||
relm4_icons::initialize_icons();
|
||||
|
||||
app.run::<App>(());
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
pub mod about;
|
||||
pub mod unsupported;
|
||||
|
||||
49
src/modals/unsupported.rs
Normal file
49
src/modals/unsupported.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use adw::StatusPage;
|
||||
use gtk::prelude::GtkWindowExt;
|
||||
use relm4::view;
|
||||
use relm4::{adw, gtk, ComponentParts, ComponentSender, SimpleComponent};
|
||||
use relm4_icons::icon_name;
|
||||
pub struct UnsupportedDialog {}
|
||||
|
||||
impl SimpleComponent for UnsupportedDialog {
|
||||
type Init = ();
|
||||
type Widgets = adw::Window;
|
||||
type Input = ();
|
||||
type Output = ();
|
||||
type Root = adw::Window;
|
||||
|
||||
fn init_root() -> Self::Root {
|
||||
adw::Window::builder().build()
|
||||
}
|
||||
|
||||
fn init(
|
||||
_: Self::Init,
|
||||
root: &Self::Root,
|
||||
_sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
let model = Self {};
|
||||
|
||||
view! {
|
||||
widgets = root.clone() {
|
||||
set_hide_on_close: true,
|
||||
set_modal: true,
|
||||
set_resizable: false,
|
||||
set_default_width: 400,
|
||||
|
||||
StatusPage::new() {
|
||||
set_icon_name: Some(icon_name::ISSUE),
|
||||
set_title: "Missing requirements",
|
||||
set_description: Some("Make sure Toolbx and Gnome Terminal are installed."),
|
||||
set_child: Some(>k::Button::with_label("Goodbye!")),
|
||||
},
|
||||
}
|
||||
}
|
||||
// TODO: when dialgue closes close application
|
||||
// TODO: close application on button press
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update_view(&self, dialog: &mut Self::Widgets, _sender: ComponentSender<Self>) {
|
||||
dialog.present();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user