feat: set transient for by propagating root window

This commit is contained in:
Gabriele Musco 2023-06-26 08:01:17 +02:00
commit 18febae805
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
5 changed files with 14 additions and 24 deletions

View file

@ -457,6 +457,7 @@ impl SimpleComponent for App {
.launch(MainViewInit { .launch(MainViewInit {
config: config.clone(), config: config.clone(),
selected_profile: config.get_selected_profile(&profiles), selected_profile: config.get_selected_profile(&profiles),
root_win: root.clone().into(),
}) })
.forward(sender.input_sender(), |message| match message { .forward(sender.input_sender(), |message| match message {
MainViewOutMsg::EnableDebugViewChanged(val) => Msg::EnableDebugViewChanged(val), MainViewOutMsg::EnableDebugViewChanged(val) => Msg::EnableDebugViewChanged(val),

View file

@ -41,6 +41,7 @@ pub enum InstallWivrnBoxMsg {
#[derive(Debug)] #[derive(Debug)]
pub struct InstallWivrnBoxInit { pub struct InstallWivrnBoxInit {
pub selected_profile: Profile, pub selected_profile: Profile,
pub root_win: gtk::Window,
} }
#[relm4::component(pub)] #[relm4::component(pub)]
@ -202,6 +203,7 @@ impl SimpleComponent for InstallWivrnBox {
) -> ComponentParts<Self> { ) -> ComponentParts<Self> {
let adb_missing_dialog = adw::MessageDialog::builder() let adb_missing_dialog = adw::MessageDialog::builder()
.modal(true) .modal(true)
.transient_for(&init.root_win)
.heading("ADB is not installed") .heading("ADB is not installed")
.body("Please install ADB on your computer to install WiVRn on your Android headset") .body("Please install ADB on your computer to install WiVRn on your Android headset")
.hide_on_close(true) .hide_on_close(true)

View file

@ -68,6 +68,7 @@ pub enum MainViewOutMsg {
pub struct MainViewInit { pub struct MainViewInit {
pub config: Config, pub config: Config,
pub selected_profile: Profile, pub selected_profile: Profile,
pub root_win: gtk::Window,
} }
#[relm4::component(pub)] #[relm4::component(pub)]
@ -301,6 +302,7 @@ impl SimpleComponent for MainView {
) -> ComponentParts<Self> { ) -> ComponentParts<Self> {
let profile_not_editable_dialog = adw::MessageDialog::builder() let profile_not_editable_dialog = adw::MessageDialog::builder()
.modal(true) .modal(true)
.transient_for(&init.root_win)
.hide_on_close(true) .hide_on_close(true)
.heading("This profile is not editable") .heading("This profile is not editable")
.body(concat!( .body(concat!(
@ -324,6 +326,7 @@ impl SimpleComponent for MainView {
let profile_delete_confirm_dialog = adw::MessageDialog::builder() let profile_delete_confirm_dialog = adw::MessageDialog::builder()
.modal(true) .modal(true)
.transient_for(&init.root_win)
.hide_on_close(true) .hide_on_close(true)
.heading("Are you sure you want to delete this profile?") .heading("Are you sure you want to delete this profile?")
.build(); .build();
@ -351,6 +354,7 @@ impl SimpleComponent for MainView {
install_wivrn_box: InstallWivrnBox::builder() install_wivrn_box: InstallWivrnBox::builder()
.launch(InstallWivrnBoxInit { .launch(InstallWivrnBoxInit {
selected_profile: init.selected_profile.clone(), selected_profile: init.selected_profile.clone(),
root_win: init.root_win.clone(),
}) })
.detach(), .detach(),
runtime_switcher_box: RuntimeSwitcherBox::builder() runtime_switcher_box: RuntimeSwitcherBox::builder()
@ -359,7 +363,9 @@ impl SimpleComponent for MainView {
}) })
.detach(), .detach(),
profile_editor: ProfileEditor::builder() profile_editor: ProfileEditor::builder()
.launch(ProfileEditorInit {}) .launch(ProfileEditorInit {
root_win: init.root_win.clone(),
})
.forward(sender.input_sender(), |message| match message { .forward(sender.input_sender(), |message| match message {
ProfileEditorOutMsg::SaveProfile(p) => Self::Input::SaveProfile(p), ProfileEditorOutMsg::SaveProfile(p) => Self::Input::SaveProfile(p),
}), }),

View file

@ -53,7 +53,9 @@ pub enum ProfileEditorOutMsg {
SaveProfile(Profile), SaveProfile(Profile),
} }
pub struct ProfileEditorInit {} pub struct ProfileEditorInit {
pub root_win: gtk::Window,
}
#[relm4::component(pub)] #[relm4::component(pub)]
impl SimpleComponent for ProfileEditor { impl SimpleComponent for ProfileEditor {
@ -66,6 +68,7 @@ impl SimpleComponent for ProfileEditor {
adw::PreferencesWindow { adw::PreferencesWindow {
set_hide_on_close: true, set_hide_on_close: true,
set_modal: true, set_modal: true,
set_transient_for: Some(&init.root_win),
#[track = "model.changed(Self::profile())"] #[track = "model.changed(Self::profile())"]
set_title: match model.profile.as_ref() { set_title: match model.profile.as_ref() {
Some(p) => Some(p.name.as_str()), Some(p) => Some(p.name.as_str()),

View file

@ -1,22 +0,0 @@
#[macro_use]
pub mod widgets {
use iced::Length;
use iced_aw::quad::{Quad, InnerBounds};
pub fn vseparator() -> Quad {
Quad {
width: Length::Fixed(1.0),
height: Length::Fill,
inner_bounds: InnerBounds::Ratio(0.0001, 0.9999),
..Default::default()
}
}
pub fn hseparator() -> Quad {
Quad {
width: Length::Fill,
height: Length::Fixed(1.0),
inner_bounds: InnerBounds::Ratio(0.9999, 0.0001),
..Default::default()
}
}
}