]>
git.proxmox.com Git - pve-installer.git/blob - Proxmox/UI.pm
3 # a few simple abstractions to be a bit more general over what UI is in use, this is basically an
4 # UIĀ², a User-Interface Interface
11 use Proxmox
::Sys
::File
qw(file_read_all);
13 use Proxmox
::UI
::Gtk3
;
14 use Proxmox
::UI
::StdIO
;
16 my ($_ui, $_env) = (undef, undef);
18 # state belongs fully to the UI
19 # env is a reference to the return value of Proxmox::Install::ISOEnv
21 my ($state, $env) = @_;
23 croak
"overriding existing UI!" if defined($_ui);
25 $_ui = Proxmox
::UI
::Gtk3-
>new($state, $env);
31 my ($state, $env) = @_;
33 croak
"overriding existing UI!" if defined($_ui);
35 $_ui = Proxmox
::UI
::StdIO-
>new($state, $env);
42 return $_ui // croak
"no UI initialized!";
46 return $_env // croak
"env not initialized!";
51 get_ui
()->message($msg);
56 get_ui
()->error($msg);
60 my ($success, $msg) = @_;
61 get_ui
()->finished(!!$success, $msg);
66 return get_ui
()->prompt($query);
70 my ($filename, $transform) = @_;
73 my $html_dir = "$env->{locations}->{lib}/html";
76 if (-f
"$html_dir/$env->{product}/$filename") {
77 $path = "$html_dir/$env->{product}/$filename";
79 $path = "$html_dir/$filename";
82 my $raw_html = file_read_all
($path);
84 $raw_html = $transform->($raw_html, $env) if $transform;
86 $raw_html =~ s/__FULL_PRODUCT_NAME__/$env->{cfg}->{fullname}/g;
88 return get_ui
()->display_html($raw_html, $html_dir);
92 my ($frac, $start, $end, $text) = @_;
94 my $part = $end - $start;
95 my $ratio = $start + $frac * $part;
97 get_ui
()->progress($ratio, $text);
103 get_ui
()->process_events();