From 0643e73675db83d2cfc0d2ac2531297c0fd5fa6d Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sat, 1 Apr 2023 00:24:07 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20refactor=20installation=20dialog?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5cb0fdb..a96e8b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,9 +43,19 @@ static mut G_HELLO_WINDOW: Option> = None; fn quick_message(message: &'static str) { // Create the widgets - let dialog = gtk::Dialog::builder().title(message).modal(true).build(); + let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; + let application_window = + window_ref.application().expect("Unable to retrieve application instance!"); + let dialog = gtk::Dialog::builder() + .application(&application_window) + .attached_to(window_ref) + .transient_for(window_ref) + .title(message) + .modal(true) + .expand(true) + .destroy_with_parent(true) + .build(); - dialog.set_destroy_with_parent(true); dialog.add_button("_Offline", gtk::ResponseType::No); dialog.add_button("_Online", gtk::ResponseType::Yes); let content_area = dialog.content_area(); @@ -76,11 +86,18 @@ fn quick_message(message: &'static str) { }; if !status && result == gtk::ResponseType::Yes { + let window_ref = unsafe { &G_HELLO_WINDOW.as_ref().unwrap().window }; + let application_window = + window_ref.application().expect("Unable to retrieve application instance!"); + let errordialog = gtk::MessageDialog::builder() - .title(message) - .text("Unable to start online installation! No internet connection") - .modal(true) + .application(&application_window) + .attached_to(window_ref) + .transient_for(window_ref) .message_type(gtk::MessageType::Error) + .text("Unable to start online installation! No internet connection") + .title(message) + .modal(true) .build(); errordialog.show(); return;