return get_ui()->display_html($raw_html, $html_dir);
}
+sub progress {
+ my ($frac, $start, $end, $text) = @_;
+
+ my $part = $end - $start;
+ my $ratio = $start + $frac * $part;
+
+ get_ui()->progress($ratio, $text);
+
+ return $ratio;
+}
+
+sub process_events {
+ get_ui()->process_events();
+}
+
1;
croak "implement me in sub-class";
}
+sub progress {
+ my ($self, $ratio, $text) = @_;
+
+ croak "implement me in sub-class";
+}
+
+sub process_events {
+ my ($self) = @_;
+
+ croak "implement me in sub-class";
+}
+
1;
$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;
# ignore for now
}
+sub progress {
+ my ($self, $ratio, $text) = @_;
+
+ print STDOUT "progress: $ratio $text\n";
+}
+
+sub process_events {
+ my ($self) = @_;
+
+ # nothing to do for now?
+}
+
1;
sub update_progress {
my ($frac, $start, $end, $text) = @_;
- my $part = $end - $start;
- my $res = $start + $frac * $part;
-
- $gtk_state->{progress_bar}->set_fraction ($res);
- $gtk_state->{progress_bar}->set_text(sprintf ("%d%%", int ($res*100)));
- $gtk_state->{progress_status}->set_text($text) if defined($text);
+ my $res = Proxmox::UI::progress($frac, $start, $end, $text);
display_info() if $res < 0.9;
- Gtk3::main_iteration() while Gtk3::events_pending();
+ Proxmox::UI::process_events();
}
my $fssetup = {