mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-01 13:48:47 +00:00
feat: switch to adw about dialog
This commit is contained in:
parent
3072000ddd
commit
a88c0ba802
2 changed files with 27 additions and 51 deletions
|
@ -1,19 +1,8 @@
|
||||||
use crate::constants::{get_developers, APP_ID, APP_NAME, REPO_URL, SINGLE_DEVELOPER, VERSION};
|
use crate::constants::{get_developers, APP_ID, APP_NAME, REPO_URL, SINGLE_DEVELOPER, VERSION};
|
||||||
use relm4::gtk::prelude::GtkWindowExt;
|
|
||||||
use relm4::prelude::*;
|
use relm4::prelude::*;
|
||||||
use relm4::{ComponentParts, SimpleComponent};
|
|
||||||
|
|
||||||
pub struct AboutDialog {}
|
pub fn create_about_dialog() -> adw::AboutDialog {
|
||||||
|
adw::AboutDialog::builder()
|
||||||
impl SimpleComponent for AboutDialog {
|
|
||||||
type Init = ();
|
|
||||||
type Input = ();
|
|
||||||
type Output = ();
|
|
||||||
type Root = adw::AboutWindow;
|
|
||||||
type Widgets = adw::AboutWindow;
|
|
||||||
|
|
||||||
fn init_root() -> Self::Root {
|
|
||||||
adw::AboutWindow::builder()
|
|
||||||
.application_name(APP_NAME)
|
.application_name(APP_NAME)
|
||||||
.application_icon(APP_ID)
|
.application_icon(APP_ID)
|
||||||
.license_type(gtk::License::Agpl30)
|
.license_type(gtk::License::Agpl30)
|
||||||
|
@ -21,22 +10,5 @@ impl SimpleComponent for AboutDialog {
|
||||||
.website(REPO_URL)
|
.website(REPO_URL)
|
||||||
.developer_name(SINGLE_DEVELOPER)
|
.developer_name(SINGLE_DEVELOPER)
|
||||||
.developers(get_developers())
|
.developers(get_developers())
|
||||||
.modal(true)
|
|
||||||
.hide_on_close(true)
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(
|
|
||||||
_init: Self::Init,
|
|
||||||
root: Self::Root,
|
|
||||||
_sender: relm4::ComponentSender<Self>,
|
|
||||||
) -> relm4::ComponentParts<Self> {
|
|
||||||
let model = AboutDialog {};
|
|
||||||
let widgets = root.clone();
|
|
||||||
ComponentParts { model, widgets }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_view(&self, dialog: &mut Self::Widgets, _sender: ComponentSender<Self>) {
|
|
||||||
dialog.present();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use super::about_dialog::AboutDialog;
|
|
||||||
use super::alert::{alert, alert_w_widget};
|
use super::alert::{alert, alert_w_widget};
|
||||||
use super::build_window::{BuildStatus, BuildWindow};
|
use super::build_window::{BuildStatus, BuildWindow};
|
||||||
use super::cmdline_opts::CmdLineOpts;
|
use super::cmdline_opts::CmdLineOpts;
|
||||||
|
@ -42,13 +41,14 @@ use crate::stateless_action;
|
||||||
use crate::steam_linux_runtime_injector::{
|
use crate::steam_linux_runtime_injector::{
|
||||||
restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile,
|
restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile,
|
||||||
};
|
};
|
||||||
|
use crate::ui::about_dialog::create_about_dialog;
|
||||||
use crate::ui::build_window::{BuildWindowInit, BuildWindowMsg, BuildWindowOutMsg};
|
use crate::ui::build_window::{BuildWindowInit, BuildWindowMsg, BuildWindowOutMsg};
|
||||||
use crate::ui::debug_view::{DebugViewInit, DebugViewOutMsg};
|
use crate::ui::debug_view::{DebugViewInit, DebugViewOutMsg};
|
||||||
use crate::ui::libsurvive_setup_window::LibsurviveSetupMsg;
|
use crate::ui::libsurvive_setup_window::LibsurviveSetupMsg;
|
||||||
use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg};
|
use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg};
|
||||||
use crate::xr_devices::XRDevice;
|
use crate::xr_devices::XRDevice;
|
||||||
|
use adw::prelude::*;
|
||||||
use gtk::glib::clone;
|
use gtk::glib::clone;
|
||||||
use gtk::prelude::*;
|
|
||||||
use relm4::actions::{AccelsPlus, ActionGroupName, RelmAction, RelmActionGroup};
|
use relm4::actions::{AccelsPlus, ActionGroupName, RelmAction, RelmActionGroup};
|
||||||
use relm4::adw::prelude::MessageDialogExt;
|
use relm4::adw::prelude::MessageDialogExt;
|
||||||
use relm4::adw::ResponseAppearance;
|
use relm4::adw::ResponseAppearance;
|
||||||
|
@ -77,7 +77,7 @@ pub struct App {
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
split_view: Option<adw::NavigationSplitView>,
|
split_view: Option<adw::NavigationSplitView>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
about_dialog: Controller<AboutDialog>,
|
about_dialog: adw::AboutDialog,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
build_window: Controller<BuildWindow>,
|
build_window: Controller<BuildWindow>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
|
@ -902,10 +902,7 @@ impl SimpleComponent for App {
|
||||||
.forward(sender.input_sender(), |message| match message {
|
.forward(sender.input_sender(), |message| match message {
|
||||||
DebugViewOutMsg::StartWithDebug => Msg::StartWithDebug,
|
DebugViewOutMsg::StartWithDebug => Msg::StartWithDebug,
|
||||||
}),
|
}),
|
||||||
about_dialog: AboutDialog::builder()
|
about_dialog: create_about_dialog(),
|
||||||
.transient_for(&root)
|
|
||||||
.launch(())
|
|
||||||
.detach(),
|
|
||||||
build_window: BuildWindow::builder()
|
build_window: BuildWindow::builder()
|
||||||
.launch(BuildWindowInit {
|
.launch(BuildWindowInit {
|
||||||
parent: root.clone().upcast(),
|
parent: root.clone().upcast(),
|
||||||
|
@ -936,12 +933,19 @@ impl SimpleComponent for App {
|
||||||
};
|
};
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
||||||
{
|
stateless_action!(
|
||||||
let abd_sender = model.about_dialog.sender().clone();
|
actions,
|
||||||
stateless_action!(actions, AboutAction, move |_| {
|
AboutAction,
|
||||||
abd_sender.send(()).unwrap();
|
clone!(
|
||||||
});
|
#[strong(rename_to = about_dialog)]
|
||||||
|
model.about_dialog,
|
||||||
|
#[strong(rename_to = app_win)]
|
||||||
|
model.app_win,
|
||||||
|
move |_| {
|
||||||
|
about_dialog.present(Some(&app_win));
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
actions.add_action(RelmAction::<DebugViewToggleAction>::new_stateful(
|
actions.add_action(RelmAction::<DebugViewToggleAction>::new_stateful(
|
||||||
&model.enable_debug_view,
|
&model.enable_debug_view,
|
||||||
clone!(
|
clone!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue