]> git.proxmox.com Git - pve-installer.git/blobdiff - Proxmox/UI/Gtk3.pm
UI: add progress and process_events helper
[pve-installer.git] / Proxmox / UI / Gtk3.pm
index 98cdc8c4aec31ad1cf7aa12450d7c4443180f1a5..7bb9ddf12c98efcc2709c72ffa38a8210d6e8c89 100644 (file)
@@ -45,4 +45,19 @@ sub display_html {
     $html_view->load_html($raw_html,  "file://$html_dir/");
 }
 
+sub progress {
+    my ($self, $ratio, $text) = @_;
+
+    my ($bar, $status) = $self->{state}->@{'progress_bar', 'progress_status'};
+
+    $bar->set_fraction($ratio);
+    $bar->set_text(sprintf ("%d%%", int ($ratio * 100)));
+    $status->set_text($text) if defined($text);
+}
+
+sub process_events {
+    my ($self) = @_;
+    Gtk3::main_iteration() while Gtk3::events_pending();
+}
+
 1;