]> git.proxmox.com Git - pve-installer.git/blobdiff - proxinstall
stop main loop when closing the main window
[pve-installer.git] / proxinstall
index 5926412bf11a8eeb2e894a7d1d854dc47d6b7ab1..21c7201eb388430cf957cc99b99346a8fad4c04e 100755 (executable)
@@ -235,6 +235,18 @@ compatibility_level = 2
 _EOD
 
 
+sub app_quit {
+    my ($exit_code) = @_;
+
+    Gtk3->main_quit() if Gtk3->main_level() > 0;
+
+    # reap left over zombie processes
+    while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) {
+       print "reaped child $child\n";
+    }
+    exit($exit_code);
+}
+
 sub detect_country {
     print "trying to detect country...\n";
     my $cpid = open2(my $TRACEROUTE_FH, undef, "traceroute -N 1 -q 1 -n 8.8.8.8");
@@ -491,7 +503,7 @@ sub ask_existing_vg_rename_or_abort {
                die "could not rename VG from '$vg->{pvs}' ($vg_uuid) to '$new_vgname'!\n";
        }
     } else {
-       set_next("_Reboot", sub { exit (0); } );
+       set_next("_Reboot", sub { app_quit(0); } );
        display_html("fail.htm");
        die "Cancled installation by user, due to already existing volume group '$vgname'\n";
     }
@@ -1486,9 +1498,10 @@ sub create_main_window {
 
     $window = Gtk3::Window->new();
     $window->set_default_size(1024, 768);
-    $window->set_has_resize_grip(0);
+    $window->signal_connect(map => sub { $window->set_resizable(0); });
     $window->fullscreen() if !is_test_mode();
     $window->set_decorated(0) if !is_test_mode();
+    $window->signal_connect(destroy => sub { Gtk3->main_quit(); });
 
     my $vbox = Gtk3::Box->new('vertical', 0);
 
@@ -1510,7 +1523,7 @@ sub create_main_window {
  #  $f1->set_shadow_type ('none');
  #  $hbox->pack_start ($f1, 1, 1, 0);
 
-    my $sep1 = Gtk3::HSeparator->new();
+    my $sep1 = Gtk3::Separator->new('horizontal');
     $vbox->pack_start($sep1, 0, 0, 0);
 
     $cmdbox = Gtk3::Box->new('horizontal', 0);
@@ -1529,7 +1542,7 @@ sub create_main_window {
     my $abort = Gtk3::Button->new('_Abort');
     $abort->set_can_focus(0);
     $cmdbox->pack_start($abort, 0, 0, 10);
-    $abort->signal_connect(clicked => sub { exit (-1); });
+    $abort->signal_connect(clicked => sub { app_quit(-1); });
 
     my $vbox2 = Gtk3::Box->new('vertical', 0);
     $hbox->add($vbox2);
@@ -1547,7 +1560,7 @@ sub create_main_window {
     my $vbox3 = Gtk3::Box->new('vertical', 0);
     $vbox2->pack_start($vbox3, 0, 0, 0);
 
-    my $sep2 = Gtk3::HSeparator->new;
+    my $sep2 = Gtk3::Separator->new('horizontal');
     $vbox3->pack_start($sep2, 0, 0, 0);
 
     $inbox = Gtk3::Box->new('horizontal', 0);
@@ -1556,7 +1569,7 @@ sub create_main_window {
     $window->add($vbox);
 
     $window->show_all;
-    $window->realize();
+    $window->present();
 }
 
 sub cleanup_view {
@@ -2550,7 +2563,7 @@ sub create_hdoption_view {
 
     $row++;
 
-    my $sep = Gtk3::HSeparator->new();
+    my $sep = Gtk3::Separator->new('horizontal');
     $sep->set_visible(1);
     $grid->attach($sep, 0, $row, 2, 1);
     $row++;
@@ -2671,7 +2684,7 @@ sub create_hdoption_view {
        &$switch_view();
     });
 
-    my $sep2 = Gtk3::HSeparator->new();
+    my $sep2 = Gtk3::Separator->new('horizontal');
     $sep2->set_visible(1);
     $contarea->pack_end($sep2, 1, 1, 10);
 
@@ -2968,7 +2981,7 @@ sub create_extract_view {
 
     $next->set_sensitive(1);
 
-    set_next("_Reboot", sub { exit (0); } );
+    set_next("_Reboot", sub { app_quit(0); } );
 
     if ($err) {
        display_html("fail.htm");
@@ -2983,7 +2996,7 @@ sub create_extract_view {
                    $autoreboot_seconds--;
                    display_html("success.htm");
                } else {
-                   exit(0);
+                   app_quit(0);
                }
            });
        }
@@ -3038,7 +3051,7 @@ my $initial_error = 0;
        print "no harddisks found\n";
        $initial_error = 1;
        display_html("nohds.htm");
-       set_next("Reboot", sub { exit(0); } );
+       set_next("Reboot", sub { app_quit(0); } );
     } else {
        foreach my $hd (@$cached_disks) {
            my ($disk, $devname) = @$hd;
@@ -3052,16 +3065,11 @@ if (!$initial_error && (scalar keys %{ $ipconf->{ifaces} } == 0)) {
     print "no network interfaces found\n";
     $initial_error = 1;
     display_html("nonics.htm");
-    set_next("Reboot", sub { exit(0); } );
+    set_next("Reboot", sub { app_quit(0); } );
 }
 
 create_intro_view () if !$initial_error;
 
 Gtk3->main;
 
-# reap left over zombie processes
-while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) {
-    print "reaped child $child\n";
-}
-
-exit 0;
+app_quit(0);