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::config::{APP_ID, PROFILE};
|
||||||
use crate::modals::about::AboutDialog;
|
use crate::modals::about::AboutDialog;
|
||||||
use crate::modals::unsupported::UnsupportedDialog;
|
use crate::modals::unsupported::UnsupportedDialog;
|
||||||
|
use crate::modals::unsupported::UnsupportedDialogOutput;
|
||||||
|
|
||||||
pub(super) struct App {
|
pub(super) struct App {
|
||||||
unsupported_dialog: Controller<UnsupportedDialog>,
|
unsupported_dialog: Controller<UnsupportedDialog>,
|
||||||
@@ -101,7 +102,9 @@ impl SimpleComponent for App {
|
|||||||
let unsupported_dialog = UnsupportedDialog::builder()
|
let unsupported_dialog = UnsupportedDialog::builder()
|
||||||
.transient_for(root)
|
.transient_for(root)
|
||||||
.launch(())
|
.launch(())
|
||||||
.detach();
|
.forward(sender.input_sender(), |msg| match msg {
|
||||||
|
UnsupportedDialogOutput::CloseApplication => AppMsg::Quit,
|
||||||
|
});
|
||||||
|
|
||||||
let model = Self {
|
let model = Self {
|
||||||
about_dialog,
|
about_dialog,
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
use adw::StatusPage;
|
use adw::StatusPage;
|
||||||
use gtk::prelude::GtkWindowExt;
|
use gtk::prelude::{ButtonExt, GtkWindowExt};
|
||||||
use relm4::view;
|
use relm4::view;
|
||||||
use relm4::{adw, gtk, ComponentParts, ComponentSender, SimpleComponent};
|
use relm4::{adw, gtk, ComponentParts, ComponentSender, SimpleComponent};
|
||||||
use relm4_icons::icon_name;
|
use relm4_icons::icon_name;
|
||||||
|
|
||||||
pub struct UnsupportedDialog {}
|
pub struct UnsupportedDialog {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum UnsupportedDialogOutput {
|
||||||
|
CloseApplication,
|
||||||
|
}
|
||||||
|
|
||||||
impl SimpleComponent for UnsupportedDialog {
|
impl SimpleComponent for UnsupportedDialog {
|
||||||
type Init = ();
|
type Init = ();
|
||||||
type Widgets = adw::Window;
|
type Widgets = adw::Window;
|
||||||
type Input = ();
|
type Input = ();
|
||||||
type Output = ();
|
type Output = UnsupportedDialogOutput;
|
||||||
type Root = adw::Window;
|
type Root = adw::Window;
|
||||||
|
|
||||||
fn init_root() -> Self::Root {
|
fn init_root() -> Self::Root {
|
||||||
@@ -19,7 +25,7 @@ impl SimpleComponent for UnsupportedDialog {
|
|||||||
fn init(
|
fn init(
|
||||||
_: Self::Init,
|
_: Self::Init,
|
||||||
root: &Self::Root,
|
root: &Self::Root,
|
||||||
_sender: ComponentSender<Self>,
|
sender: ComponentSender<Self>,
|
||||||
) -> ComponentParts<Self> {
|
) -> ComponentParts<Self> {
|
||||||
let model = Self {};
|
let model = Self {};
|
||||||
|
|
||||||
@@ -30,16 +36,22 @@ impl SimpleComponent for UnsupportedDialog {
|
|||||||
set_resizable: false,
|
set_resizable: false,
|
||||||
set_default_width: 400,
|
set_default_width: 400,
|
||||||
|
|
||||||
|
|
||||||
StatusPage::new() {
|
StatusPage::new() {
|
||||||
set_icon_name: Some(icon_name::ISSUE),
|
set_icon_name: Some(icon_name::ISSUE),
|
||||||
set_title: "Missing requirements",
|
set_title: "Missing requirements",
|
||||||
set_description: Some("Make sure Toolbx and Gnome Terminal are installed."),
|
set_description: Some("Make sure Toolbox and Gnome Terminal are installed."),
|
||||||
set_child: Some(>k::Button::with_label("Goodbye!")),
|
|
||||||
|
#[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 }
|
ComponentParts { model, widgets }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user