summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2017-04-03 09:48:03 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2017-04-03 13:26:45 +0200
commit6ccf9ae5e67abed446049e39273908961c3c9bec (patch)
treec941c86b6346313c4bbb42b4f25de7837b3adeab
parent0f533bb6fce19527ad0ec900cfa6bc2f51fba4f3 (diff)
downloadcontrol-center-6ccf9ae5e67abed446049e39273908961c3c9bec.tar
control-center-6ccf9ae5e67abed446049e39273908961c3c9bec.tar.gz
control-center-6ccf9ae5e67abed446049e39273908961c3c9bec.tar.bz2
control-center-6ccf9ae5e67abed446049e39273908961c3c9bec.tar.xz
control-center-6ccf9ae5e67abed446049e39273908961c3c9bec.zip
use Gtk+ animations instead of manually doing it
This simplifies our code: we can remove our timer and our custom DrawingAread and its 'draw' hook. We just have to add the various fading variants of the icon in a PixbufSimpleAnim, set it to loop forver and let Gtk+ handles the animation. This also prevents delayed action to happen before first draw signal due to bad timing (mga#19827).
-rw-r--r--NEWS4
-rwxr-xr-xcontrol-center51
2 files changed, 17 insertions, 38 deletions
diff --git a/NEWS b/NEWS
index 5b64b9b0..9e3a37bd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+- simplify by using Gtk+ animations instead of our own manual one
+ thus preventing delayed action to happen before first draw signal due to bad
+ timing (mga#19827)
+
Version 13.14 - 30 March 2017, by Thierry Vignaud
- drop legacy loaders for drakbackup, drakmenustyle and tomoyo-gui
diff --git a/control-center b/control-center
index 7434fde7..5ef79346 100755
--- a/control-center
+++ b/control-center
@@ -50,11 +50,6 @@ use Gtk3::WebKit2;
use MDV::Control_Center;
-Glib::Object::Introspection->setup(
- basename => 'PangoCairo',
- version => '1.0',
- package => 'Pango::Cairo');
-
my (%tool_pids, %tool_feedback, $gurpmi_pid);
my ($conffile, $class_install) = ('/etc/mcc.conf', '/etc/sysconfig/system');
@@ -730,7 +725,13 @@ gtkadd($window_global,
], right_child => gtknew('ScrolledWindow', child => gtkset_border_width($view, 5),
no_shadow => 1, h_policy => 'never')),
1, gtkpack(my $emb_box = Gtk3::VBox->new(0, 0),
- my $wait_darea = gtkset_size_request(Gtk3::DrawingArea->new, -1, -1),
+ my $wait_darea = gtkset_size_request(
+ gtkpack_(gtknew('VBox'),
+ 1, gtknew('VBox'),
+ 0, my $wait_img = Gtk3::Image->new,
+ 0, Gtk3::Label->new(N("Loading... Please wait")),
+ 1, gtknew('VBox')
+ ), -1, -1),
),
),
0, Gtk3::HSeparator->new,
@@ -1044,7 +1045,7 @@ foreach (keys %check_boxes) {
# "wait while launching a program" area :
-my ($run_pixbuf, $run_counter, $run_counter_add, %run_pixbufs);
+my $run_pixbuf;
sub stop_wait_area() {
$wait_darea->hide;
@@ -1052,32 +1053,8 @@ sub stop_wait_area() {
Glib::Source->remove($timeout);
undef $timeout;
}
- undef %run_pixbufs;
}
-$wait_darea->signal_connect(draw => sub {
- my ($w, $cr) = @_;
- return if !$wait_darea->get_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 = $run_pixbufs{$run_counter} ||= mygtk3::_pixbuf_render_alpha($run_pixbuf, $run_counter);
- my $size = $wait_darea->get_allocation;
- my ($d_width, $d_height) = ($size->{width}, $size->{height});
- ($w->{pix_width}, $w->{pix_height}) = ($pixbuf->get_width, $pixbuf->get_height);
- my ($txt_width, $txt_height) = $wait_darea->{layout}->get_pixel_size;
- $w->{pix_yy} = ($d_width - $w->{pix_width})/2;
- $w->{pix_xx} = ($d_height - $w->{pix_height} - $txt_height)/2;
- $w->{text_yy} = $w->{pix_yy} + ($w->{pix_width} - $txt_width)/2;
- $w->{text_xx} = $w->{pix_xx} + $w->{pix_height} + 5;
- Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, $w->{pix_yy}, $w->{pix_xx}); #0, 0);
- $cr->paint;
- $cr->set_source_rgb(0, 0, 0);
- $cr->move_to($w->{text_yy}, $w->{text_xx});
- Pango::Cairo::show_layout($cr, $w->{layout});
- $run_counter += $run_counter_add;
- $run_counter_add = -$run_counter_add if $run_counter < 100 || 255-$run_counter_add < $run_counter;
-});
-
gtkflush();
# display first page (we use a timeout so that Y position of widgets is know):
@@ -1256,13 +1233,11 @@ sub run_tool {
$wait_darea->show;
$cancel->show;
$run_pixbuf = eval { gtkcreate_pixbuf($icon . "_128") };
- $run_counter = 255;
- $run_counter_add = -5;
- $timeout = Glib::Timeout->add(35, sub {
- my $w = $wait_darea;
- $w->queue_draw_area($w->{pix_yy}, $w->{pix_xx}, $w->{pix_width}, $w->{pix_height});
- 1;
- });
+ my $anim = Gtk3::Gdk::PixbufSimpleAnim->new(128,128, 1000/35);
+ $anim->add_frame(mygtk3::_pixbuf_render_alpha($run_pixbuf, 255-$_*5)) foreach 0..31; # fade away
+ $anim->add_frame(mygtk3::_pixbuf_render_alpha($run_pixbuf, 95+$_*5)) foreach 0..31; # fade back
+ $anim->set_loop(1);
+ $wait_img->set_from_animation($anim);
$left_locked = 1;
$buttons->show;
$tool_pids{$label} = fork_($exec);