🧹 refactor installation dialogs
This commit is contained in:
parent
85566348a2
commit
0643e73675
27
src/main.rs
27
src/main.rs
|
@ -43,9 +43,19 @@ static mut G_HELLO_WINDOW: Option<Arc<HelloWindow>> = None;
|
||||||
|
|
||||||
fn quick_message(message: &'static str) {
|
fn quick_message(message: &'static str) {
|
||||||
// Create the widgets
|
// 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("_Offline", gtk::ResponseType::No);
|
||||||
dialog.add_button("_Online", gtk::ResponseType::Yes);
|
dialog.add_button("_Online", gtk::ResponseType::Yes);
|
||||||
let content_area = dialog.content_area();
|
let content_area = dialog.content_area();
|
||||||
|
@ -76,11 +86,18 @@ fn quick_message(message: &'static str) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if !status && result == gtk::ResponseType::Yes {
|
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()
|
let errordialog = gtk::MessageDialog::builder()
|
||||||
.title(message)
|
.application(&application_window)
|
||||||
.text("Unable to start online installation! No internet connection")
|
.attached_to(window_ref)
|
||||||
.modal(true)
|
.transient_for(window_ref)
|
||||||
.message_type(gtk::MessageType::Error)
|
.message_type(gtk::MessageType::Error)
|
||||||
|
.text("Unable to start online installation! No internet connection")
|
||||||
|
.title(message)
|
||||||
|
.modal(true)
|
||||||
.build();
|
.build();
|
||||||
errordialog.show();
|
errordialog.show();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue