diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-05-10 08:42:47 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-05-10 08:42:47 +0000 |
commit | 896291788e5530a0c1b8f77fd5d17e2c4450661d (patch) | |
tree | d158306217452df2818f480054cd3b865d64d5d9 /perl-install | |
parent | 90a06c043cf17b05881f4e9e8726f3fb5858d98a (diff) | |
download | drakx-896291788e5530a0c1b8f77fd5d17e2c4450661d.tar drakx-896291788e5530a0c1b8f77fd5d17e2c4450661d.tar.gz drakx-896291788e5530a0c1b8f77fd5d17e2c4450661d.tar.bz2 drakx-896291788e5530a0c1b8f77fd5d17e2c4450661d.tar.xz drakx-896291788e5530a0c1b8f77fd5d17e2c4450661d.zip |
allow to modify progress bar and console box by dragging the mouse
Diffstat (limited to 'perl-install')
-rwxr-xr-x | perl-install/standalone/draksplash | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash index 49becb23e..d5be9f46f 100755 --- a/perl-install/standalone/draksplash +++ b/perl-install/standalone/draksplash @@ -7,15 +7,18 @@ use common; use ugtk2 qw(:create :dialogs :helpers :wrappers); use interactive; use bootsplash; -use Xconfig::resolution_and_depth; my $in = 'interactive'->vnew('su'); my $window = ugtk2->new('DrakSplash'); $window->{rwindow}->signal_connect(delete_event => \&close_window); +my $current_rect = []; +my $current_point; + my ($image_area, @image_pixbuf); create_image_area(); +switch_to_mode(0); #- verification of package image magik unless ($in->do_pkgs->ensure_is_installed('ImageMagick', '/usr/bin/convert')) { @@ -42,10 +45,10 @@ set_resolution([ bootsplash::get_framebuffer_resolution() ]->[0]); my %adj; create_adj_widgets(); -my $mode; +my $current_mode; my $notebook = gtksignal_connect(Gtk2::Notebook->new, switch_page => sub { - (undef, undef, $mode) = @_; - $image_area->queue_draw; + my (undef, undef, $mode) = @_; + switch_to_mode($mode); }); $notebook->append_page(gtkpack__(Gtk2::VBox->new(0, 5), create_scale_table('px', 'pw', 'py', 'ph'), @@ -208,7 +211,9 @@ sub update_scale_values { sub create_image_area() { $image_area = Gtk2::DrawingArea->new; $image_area->can_focus(1); - $image_area->add_events('button-press-mask'); + $image_area->add_events($_) foreach qw(button-press-mask pointer-motion-mask); + $image_area->signal_connect(motion_notify_event => \&image_motion_notify); + $image_area->signal_connect(button_press_event => \&image_button_pressed); $image_area->signal_connect(expose_event => \&image_expose); $image_area->signal_connect(key_press_event => sub { my (undef, $event) = @_; @@ -223,8 +228,8 @@ sub create_image_area() { sub image_expose { my ($widget) = @_; my $window = $widget->window; - $window->draw_pixbuf($widget->style->white_gc, $image_pixbuf[$mode], 0, 0, 0, 0, -1, -1, 'none', 0, 0) if $image_pixbuf[$mode]; - if ($mode == 0) { #- silent + $window->draw_pixbuf($widget->style->white_gc, $image_pixbuf[$current_mode], 0, 0, 0, 0, -1, -1, 'none', 0, 0) if $image_pixbuf[$current_mode]; + if ($current_mode == 0) { #- silent $window->draw_rectangle($widget->style->white_gc, 1, @{$theme{conf}}{'px', 'py', 'pw', 'ph'}); } else { #- verbose or console $window->draw_rectangle($widget->style->black_gc, 0, @{$theme{conf}}{'tx', 'ty', 'tw', 'th'}); @@ -233,5 +238,42 @@ sub image_expose { $window->draw_line($widget->style->white_gc, $tx1, $ty1, $tx2, $ty2); $window->draw_line($widget->style->white_gc, $tx1, $ty2, $tx2, $ty1); } - 0; +} + +sub switch_to_mode { + my ($mode) = @_; + $current_mode = $mode; + if ($current_mode == 0) { #- silent + $current_rect = bootsplash::xywh2rectangle(@{$theme{conf}}{'px', 'py', 'pw', 'ph'}); + } else { #- verbose or console + $current_rect = bootsplash::xywh2rectangle(@{$theme{conf}}{'px', 'py', 'pw', 'ph'}); + } + undef $current_point; + $image_area->queue_draw; +} + +sub update_rect() { + if ($current_mode == 0) { #- silent + @{$theme{conf}}{'px', 'py', 'pw', 'ph'} = bootsplash::rectangle2xywh($current_rect); + } else { #- verbose or console + @{$theme{conf}}{'tx', 'ty', 'tw', 'th'} = bootsplash::rectangle2xywh($current_rect); + } + update_scale_values(); + $image_area->queue_draw; +} + +sub image_button_pressed { + my (undef, $event) = @_; + my $point = { X => $event->x, Y => $event->y }; + $current_point = bootsplash::nearest($point, @$current_rect); + %$current_point = %$point; + update_rect(); +} + +sub image_motion_notify { + my (undef, $event) = @_; + member('button1-mask', @{$event->state}) or return; + my $point = { X => $event->x, Y => $event->y }; + $current_point and %$current_point = %$point; + update_rect(); } |