]> git.proxmox.com Git - pve-installer.git/commitdiff
UI: add ISO env on setup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 19 Jun 2023 16:30:15 +0000 (18:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 19 Jun 2023 19:49:00 +0000 (21:49 +0200)
can be useful for UI's to get resources or the like

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Proxmox/UI.pm
Proxmox/UI/Base.pm
proxinstall

index 3f502f9d37cc46de899cd83afd9a70288f73efcc..9c6990b0e45f24e5662c677a22a9216ebe0fa969 100644 (file)
@@ -11,29 +11,37 @@ use Carp;
 use Proxmox::UI::Gtk3;
 use Proxmox::UI::StdIO;
 
-my $ui = undef;
+my ($_ui, $_env) = (undef, undef);
 
+# state belongs fully to the UI
+# env is a reference to the return value of Proxmox::Install::ISOEnv
 sub init_gtk {
-    my ($state) = @_;
+    my ($state, $env) = @_;
 
-    croak "overriding existing UI!" if defined($ui);
+    croak "overriding existing UI!" if defined($_ui);
 
-    $ui = Proxmox::UI::Gtk3->new($state);
+    $_ui = Proxmox::UI::Gtk3->new($state, $env);
+    $_env = $env;
 
-    return $ui;
+    return $_ui;
 }
 sub init_stdio {
-    my ($state) = @_;
+    my ($state, $env) = @_;
 
-    croak "overriding existing UI!" if defined($ui);
+    croak "overriding existing UI!" if defined($_ui);
 
-    $ui = Proxmox::UI::StdIO->new($state);
+    $_ui = Proxmox::UI::StdIO->new($state, $env);
+    $_env = $env;
 
-    return $ui;
+    return $_ui;
 }
 
 sub get_ui {
-    return $ui // croak "no UI initialized!";
+    return $_ui // croak "no UI initialized!";
+}
+
+my sub get_env {
+    return $_env // croak "env not initialized!";
 }
 
 sub message {
index 19fd46c9d13796ae30eeb5e7ae48f8ada4898f3c..0487dc3f715c6764d1215ae2303405f95c4b622d 100644 (file)
@@ -5,12 +5,17 @@ use warnings;
 
 use Carp;
 
+# state belongs fully to the UI
+# env is a reference to the return value of Proxmox::Install::ISOEnv
 sub new {
-    my ($this, $state) = @_;
+    my ($this, $state, $env) = @_;
 
     my $class = ref($this) || $this;
 
-    my $self = bless { state => $state }, $class;
+    my $self = bless {
+       state => $state,
+       env => $env,
+    }, $class;
 
     return $self;
 }
index 2880d147258f3e5ecf05c1bd15e64e2a3e567128..9154e4e97b684ce29b223a7efcbdb8906b2a883f 100755 (executable)
@@ -1569,7 +1569,7 @@ sub create_main_window {
 
     $window->add($vbox);
 
-    Proxmox::UI::init_gtk({ window => $window });
+    Proxmox::UI::init_gtk({ window => $window }, $env);
 
     $window->show_all;
     $window->present();