diff options
-rw-r--r-- | perl-install/ugtk2.pm | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index 13c83c786..407aa223b 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -1303,7 +1303,7 @@ sub gtk_set_treelist { sub gtk_TextView_get_log { - my ($log_w, $log_scroll, $command, $filter_output, $when_command_is_over) = @_; + my ($log_w, $command, $filter_output, $when_command_is_over) = @_; my $pid = open(my $F, "$command |") or return; fcntl($F, c::F_SETFL(), c::O_NONBLOCK()) or die "can not fcntl F_SETFL: $!"; @@ -1314,17 +1314,13 @@ sub gtk_TextView_get_log { $pid = $gtk_buffer = ''; #- ensure $gtk_buffer is valid when its value is non-null }); - my ($prev_scroll, $want_scroll_down) = (0, 1); Glib::Timeout->add(100, sub { if ($gtk_buffer) { my $end = $gtk_buffer->get_end_iter; while (defined (my $s = <$F>)) { $gtk_buffer->insert($end, $filter_output->($s)); } - my $new_scroll = $log_scroll->get_vadjustment->get_value; - $want_scroll_down &&= $new_scroll >= $prev_scroll; - $prev_scroll = $new_scroll; - $log_w->scroll_to_iter($end, 0, 0, 0, 0) if $want_scroll_down; + $log_w->{to_bottom}->(); } if (waitpid($pid, c::WNOHANG()) > 0) { #- we do not call $when_command_is_over if $gtk_buffer does not exist anymore @@ -1343,8 +1339,8 @@ sub gtk_new_TextView_get_log { my ($command, $filter_output, $when_command_is_over) = @_; my $log_w = gtknew('TextView', editable => 0); - my $log_scroll = gtknew('ScrolledWindow', child => $log_w); #- $log_scroll is a frame, not a ScrolledWindow, so giving $log_scroll->child - my $pid = gtk_TextView_get_log($log_w, $log_scroll->child, $command, $filter_output, $when_command_is_over) or return; + my $log_scroll = gtknew('ScrolledWindow', child => $log_w, to_bottom => 1); + my $pid = gtk_TextView_get_log($log_w, $command, $filter_output, $when_command_is_over) or return; $log_scroll, $pid; } |