From f4c77d966b0b5340d60c4632fce5b28e8f13162a Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 1 Mar 2004 08:09:00 +0000 Subject: lighter cpu usage on wait_area: compute images once per animation --- control-center | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/control-center b/control-center index a2e5ac60..4598748d 100755 --- a/control-center +++ b/control-center @@ -523,7 +523,8 @@ gtkadd($window_global, map { gtkset_border_width($_, 3) } gtksignal_connect(my $cancel = Gtk2::Button->new(N("Cancel")), clicked => sub { - Glib::Source->remove($timeout) if $timeout; kill_children(); + stop_wait_area(); + kill_children(); child_just_exited(); }), gtksignal_connect(my $previous = Gtk2::Button->new(N("Previous")), @@ -674,13 +675,19 @@ foreach (keys %check_boxes) { # "wait while launching a program" area : -my ($run_pixbuf, $run_counter, $run_counter_add); +my ($run_pixbuf, $run_counter, $run_counter_add, %run_pixbufs); + +sub stop_wait_area() { + $wait_darea->hide; + Glib::Source->remove($timeout) if $timeout; + undef %run_pixbufs; +} $wait_darea->signal_connect(expose_event => sub { return if !$wait_darea->realized; return unless $run_pixbuf; # some people got an expose event before we start an embedded tool $wait_darea->{layout} ||= $wait_darea->create_pango_layout(N("Loading... Please wait")); - my $pixbuf = render_alpha($run_pixbuf, $run_counter); + my $pixbuf = $run_pixbufs{$run_counter} ||= render_alpha($run_pixbuf, $run_counter); my $size = $wait_darea->allocation; my ($d_width, $d_height) = ($size->width, $size->height); my ($window, $gc, $width, $height) = ($wait_darea->window, $wait_darea->style->fg_gc('normal'), $pixbuf->get_width, $pixbuf->get_height); @@ -757,7 +764,7 @@ sub child_just_exited() { $notebook->show; } - Glib::Source->remove($timeout) if $timeout; + stop_wait_area(); } sub hide_socket_and_clean() { @@ -778,9 +785,8 @@ sub create_hidden_socket { # signal emitted when embedded apps begin to draw: $emb_socket->signal_connect('plug-added' => sub { $banner->show; - Glib::Source->remove($timeout) if $timeout; + stop_wait_area(); $left_locked = 0; - $wait_darea->hide; show_hide_previous(0); $buttons->hide; return if !$emb_socket; @@ -791,7 +797,6 @@ sub create_hidden_socket { }); $emb_box->set_focus_child($emb_socket); $emb_socket->hide; - $wait_darea->hide; } -- cgit v1.2.1