From 3cf259db80808d7c5aca9998eba5cdb2c99dc2e9 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 24 Aug 2024 10:09:21 +0300 Subject: [PATCH] integrate complete page --- src/build_ui.rs | 2 ++ src/installation_complete_page/mod.rs | 30 ++++++++++++++++++++++++++- src2/main.rs | 3 +++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/build_ui.rs b/src/build_ui.rs index 228fef5..ebd71ec 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -203,5 +203,7 @@ pub fn build_ui(app: &adw::Application) { installation_progress_page::installation_progress_page(&carousel, &language_changed_action, installation_log_loop_receiver); + installation_complete_page::installation_complete_page(&carousel, &window, &language_changed_action, installation_log_status_loop_receiver); + window.present() } diff --git a/src/installation_complete_page/mod.rs b/src/installation_complete_page/mod.rs index 5a57926..02fc78d 100644 --- a/src/installation_complete_page/mod.rs +++ b/src/installation_complete_page/mod.rs @@ -1,4 +1,4 @@ -use crate::{build_ui::PikaKeymap, installer_stack_page}; +use crate::{build_ui::PikaKeymap, config::LOG_FILE_PATH, installer_stack_page}; use adw::prelude::*; use glib::{clone, closure_local}; use gnome_desktop::XkbInfoExt; @@ -7,6 +7,7 @@ use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc}; pub fn installation_complete_page( main_carousel: &adw::Carousel, + window: &adw::ApplicationWindow, language_changed_action: &gio::SimpleAction, installation_log_status_loop_receiver: async_channel::Receiver, ) { @@ -92,6 +93,33 @@ pub fn installation_complete_page( ) ); + // + + installation_complete_exit_button.connect_clicked(clone!( + #[strong] + window, + move |_| + { + window.close() + } + ) + ); + + installation_complete_reboot_button.connect_clicked(move |_| { + Command::new("reboot") + .spawn() + .expect("reboot failed to start"); + }); + + installation_complete_view_logs_button.connect_clicked(move |_| { + Command::new("xdg-open") + .arg(LOG_FILE_PATH) + .spawn() + .expect("xdg-open failed to start"); + }); + + // + installation_complete_page.set_child_widget(&content_box); // diff --git a/src2/main.rs b/src2/main.rs index 2dd2257..2489bf5 100644 --- a/src2/main.rs +++ b/src2/main.rs @@ -55,5 +55,8 @@ fn main() { app.connect_activate(build_ui); }); + let instance = SingleInstance::new(APP_ID).unwrap(); + assert!(instance.is_single()); + application.run(); }