mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
add closing functionality to dialgoue
This commit is contained in:
@@ -12,6 +12,7 @@ use gtk::{gio, glib};
|
||||
use crate::config::{APP_ID, PROFILE};
|
||||
use crate::modals::about::AboutDialog;
|
||||
use crate::modals::unsupported::UnsupportedDialog;
|
||||
use crate::modals::unsupported::UnsupportedDialogOutput;
|
||||
|
||||
pub(super) struct App {
|
||||
unsupported_dialog: Controller<UnsupportedDialog>,
|
||||
@@ -101,7 +102,9 @@ impl SimpleComponent for App {
|
||||
let unsupported_dialog = UnsupportedDialog::builder()
|
||||
.transient_for(root)
|
||||
.launch(())
|
||||
.detach();
|
||||
.forward(sender.input_sender(), |msg| match msg {
|
||||
UnsupportedDialogOutput::CloseApplication => AppMsg::Quit,
|
||||
});
|
||||
|
||||
let model = Self {
|
||||
about_dialog,
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
use adw::StatusPage;
|
||||
use gtk::prelude::GtkWindowExt;
|
||||
use gtk::prelude::{ButtonExt, GtkWindowExt};
|
||||
use relm4::view;
|
||||
use relm4::{adw, gtk, ComponentParts, ComponentSender, SimpleComponent};
|
||||
use relm4_icons::icon_name;
|
||||
|
||||
pub struct UnsupportedDialog {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum UnsupportedDialogOutput {
|
||||
CloseApplication,
|
||||
}
|
||||
|
||||
impl SimpleComponent for UnsupportedDialog {
|
||||
type Init = ();
|
||||
type Widgets = adw::Window;
|
||||
type Input = ();
|
||||
type Output = ();
|
||||
type Output = UnsupportedDialogOutput;
|
||||
type Root = adw::Window;
|
||||
|
||||
fn init_root() -> Self::Root {
|
||||
@@ -19,7 +25,7 @@ impl SimpleComponent for UnsupportedDialog {
|
||||
fn init(
|
||||
_: Self::Init,
|
||||
root: &Self::Root,
|
||||
_sender: ComponentSender<Self>,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
let model = Self {};
|
||||
|
||||
@@ -30,16 +36,22 @@ impl SimpleComponent for UnsupportedDialog {
|
||||
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!")),
|
||||
set_description: Some("Make sure Toolbox and Gnome Terminal are installed."),
|
||||
|
||||
#[name = "btn_close"]
|
||||
gtk::Button::with_label("Goodbye!") {
|
||||
connect_clicked[sender] => move |_| {
|
||||
sender.output(UnsupportedDialogOutput::CloseApplication).unwrap()
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
// TODO: when dialgue closes close application
|
||||
// TODO: close application on button press
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user