mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-29 20:28:48 +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,42 +1,14 @@
|
|||
use crate::constants::{get_developers, APP_ID, APP_NAME, REPO_URL, SINGLE_DEVELOPER, VERSION};
|
||||
use relm4::gtk::prelude::GtkWindowExt;
|
||||
use relm4::prelude::*;
|
||||
use relm4::{ComponentParts, SimpleComponent};
|
||||
|
||||
pub struct AboutDialog {}
|
||||
|
||||
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_icon(APP_ID)
|
||||
.license_type(gtk::License::Agpl30)
|
||||
.version(VERSION)
|
||||
.website(REPO_URL)
|
||||
.developer_name(SINGLE_DEVELOPER)
|
||||
.developers(get_developers())
|
||||
.modal(true)
|
||||
.hide_on_close(true)
|
||||
.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();
|
||||
}
|
||||
pub fn create_about_dialog() -> adw::AboutDialog {
|
||||
adw::AboutDialog::builder()
|
||||
.application_name(APP_NAME)
|
||||
.application_icon(APP_ID)
|
||||
.license_type(gtk::License::Agpl30)
|
||||
.version(VERSION)
|
||||
.website(REPO_URL)
|
||||
.developer_name(SINGLE_DEVELOPER)
|
||||
.developers(get_developers())
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use super::about_dialog::AboutDialog;
|
||||
use super::alert::{alert, alert_w_widget};
|
||||
use super::build_window::{BuildStatus, BuildWindow};
|
||||
use super::cmdline_opts::CmdLineOpts;
|
||||
|
@ -42,13 +41,14 @@ use crate::stateless_action;
|
|||
use crate::steam_linux_runtime_injector::{
|
||||
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::debug_view::{DebugViewInit, DebugViewOutMsg};
|
||||
use crate::ui::libsurvive_setup_window::LibsurviveSetupMsg;
|
||||
use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg};
|
||||
use crate::xr_devices::XRDevice;
|
||||
use adw::prelude::*;
|
||||
use gtk::glib::clone;
|
||||
use gtk::prelude::*;
|
||||
use relm4::actions::{AccelsPlus, ActionGroupName, RelmAction, RelmActionGroup};
|
||||
use relm4::adw::prelude::MessageDialogExt;
|
||||
use relm4::adw::ResponseAppearance;
|
||||
|
@ -77,7 +77,7 @@ pub struct App {
|
|||
#[tracker::do_not_track]
|
||||
split_view: Option<adw::NavigationSplitView>,
|
||||
#[tracker::do_not_track]
|
||||
about_dialog: Controller<AboutDialog>,
|
||||
about_dialog: adw::AboutDialog,
|
||||
#[tracker::do_not_track]
|
||||
build_window: Controller<BuildWindow>,
|
||||
#[tracker::do_not_track]
|
||||
|
@ -902,10 +902,7 @@ impl SimpleComponent for App {
|
|||
.forward(sender.input_sender(), |message| match message {
|
||||
DebugViewOutMsg::StartWithDebug => Msg::StartWithDebug,
|
||||
}),
|
||||
about_dialog: AboutDialog::builder()
|
||||
.transient_for(&root)
|
||||
.launch(())
|
||||
.detach(),
|
||||
about_dialog: create_about_dialog(),
|
||||
build_window: BuildWindow::builder()
|
||||
.launch(BuildWindowInit {
|
||||
parent: root.clone().upcast(),
|
||||
|
@ -936,12 +933,19 @@ impl SimpleComponent for App {
|
|||
};
|
||||
let widgets = view_output!();
|
||||
|
||||
{
|
||||
let abd_sender = model.about_dialog.sender().clone();
|
||||
stateless_action!(actions, AboutAction, move |_| {
|
||||
abd_sender.send(()).unwrap();
|
||||
});
|
||||
}
|
||||
stateless_action!(
|
||||
actions,
|
||||
AboutAction,
|
||||
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(
|
||||
&model.enable_debug_view,
|
||||
clone!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue