diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-09-12 21:16:09 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-09-12 21:16:09 +0000 |
commit | 4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2 (patch) | |
tree | 3101d334f197c1912d11c2182f55a57d0551c142 /perl-install | |
parent | ef9cf6c94dd36993441c07a566bbfcca1592ea1e (diff) | |
download | drakx-backup-do-not-use-4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2.tar drakx-backup-do-not-use-4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2.tar.gz drakx-backup-do-not-use-4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2.tar.bz2 drakx-backup-do-not-use-4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2.tar.xz drakx-backup-do-not-use-4e7970e8c3429dfe2474a1c2caf9d0c5760be4d2.zip |
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/install_gtk.pm | 67 | ||||
-rw-r--r-- | perl-install/install_steps_gtk.pm | 21 | ||||
-rw-r--r-- | perl-install/my_gtk.pm | 45 |
3 files changed, 101 insertions, 32 deletions
diff --git a/perl-install/install_gtk.pm b/perl-install/install_gtk.pm index 9e38b3038..8d45d0c19 100644 --- a/perl-install/install_gtk.pm +++ b/perl-install/install_gtk.pm @@ -364,4 +364,71 @@ END #- ModeLine "640x480" 28 640 672 768 800 480 490 492 525 +sub test_mouse { + my ($mouse) = @_; + + my $w = my_gtk->new(''); + my ($width, $height, $offset) = (210, 300, 25); + my ($bw, $bh) = ($width / 3, $height * 2 / 5); + + gtkadd($w->{window}, + gtkpack(new Gtk::VBox(0,0), + my $darea = gtkset_usize(new Gtk::DrawingArea, $width+1, $height+1), + create_okcancel($w, '', '', "edge"), + ), + ); + + my $draw_rect; $draw_rect = sub { + my ($black, $fill, $rect) = @_; + $draw_rect->(0, 1, $rect) if !$fill; #- blank it first + $darea->window->draw_rectangle($black ? $darea->style->fg_gc('normal') : $darea->style->bg_gc('normal'), $fill, @$rect); + $darea->draw($rect); + }; + my $paintWheel = sub { + my ($x, $y, $w, $h) = ($width / 2 - $bw / 6, $bh / 4, $bw / 3, $bh / 2); + + my $offset = 0 if 0; + $offset += $_[0] if $_[0]; + + $draw_rect->(1, 0, [ $x, $y, $w, $h ]); + + my $step = 10; + for (my $i = $offset % $step; $i < $h; $i += $step) { + $draw_rect->(1, 1, [ $x, $y + $i, $w, min(2, $h - $i) ]); + } + }; + my $paintButton = sub { + my ($nb, $pressed) = @_; + my $rect = [ $bw * $nb, 0, $bw, $bh ]; + $draw_rect->(1, $pressed, $rect); + $paintWheel->(0) if $nb == 1 && $mouse->{nbuttons} > 3; + }; + my $draw_text = sub { + my ($t, $y) = @_; + my $font = $darea->style->font; + my $w = $font->string_width($t); + $darea->window->draw_string($font, $darea->style->black_gc, ($width - $w) / 2, $y, $t); + }; + $darea->signal_connect(button_press_event => sub { + my $b = $_[1]{button}; + $b >= 4 ? + $paintWheel->($b == 4 ? -1 : 1) : + $paintButton->($b - 1, 1); + }); + $darea->signal_connect(button_release_event => sub { + my $b = $_[1]{button}; + $paintButton->($b - 1, 0) if $b < 4; + }); + $darea->size($width, $height); + $darea->set_events([ 'button_press_mask', 'button_release_mask' ]); + + $w->sync; # HACK + $draw_rect->(0, 1, [ 0, 0, $width, $height]); + $draw_text->(_("Please test the mouse"), 2 * $bh - 20); + $draw_text->(_("Move your wheel"), 2 * $bh);# if 1 && $mouse->{XMOUSETYPE} eq 'IMPS/2'; + $paintButton->($_, 0) foreach 0..2; + $w->main; +} + + 1; diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index 32b78c041..42e017f81 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -178,16 +178,25 @@ sub selectInstallClass1 { #------------------------------------------------------------------------------ sub selectMouse { my ($o, $force) = @_; - my $old = $o->{mouse}{XMOUSETYPE}; + my %old = %{$o->{mouse}}; $o->SUPER::selectMouse($force); - if ($old ne $o->{mouse}{XMOUSETYPE} && !$::testing) { + my $set = sub { + my ($mouse) = @_; + symlinkf($mouse->{device}, "/dev/mouse"); + c::setMouseLive($ENV{DISPLAY}, mouse::xmouse2xId($mouse->{XMOUSETYPE})); + }; + + if ($old{XMOUSETYPE} ne $o->{mouse}{XMOUSETYPE}) { log::l("telling X server to use another mouse"); eval { commands::modprobe("serial") } if $o->{mouse}{device} =~ /ttyS/; - symlinkf($o->{mouse}{device}, "/dev/mouse"); - my $id = mouse::xmouse2xId($o->{mouse}{XMOUSETYPE}); - log::l("XMOUSETYPE: $o->{mouse}{XMOUSETYPE} = $id"); - c::setMouseLive($ENV{DISPLAY}, $id); + + $set->($o->{mouse}) unless $::testing; + + install_gtk::test_mouse($o->{mouse}) and return; + + $set->(\%old); + goto &selectMouse; } } diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm index 52bafba23..800777f7b 100644 --- a/perl-install/my_gtk.pm +++ b/perl-install/my_gtk.pm @@ -10,7 +10,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $border); @ISA = qw(Exporter); %EXPORT_TAGS = ( helpers => [ qw(create_okcancel createScrolledWindow create_menu create_notebook create_packtable create_hbox create_vbox create_adjustment create_box_with_title create_treeitem) ], - wrappers => [ qw(gtksignal_connect gtkpack gtkpack_ gtkpack__ gtkpack2 gtkpack2_ gtkpack2__ gtkappend gtkadd gtktext_insert gtkset_usize gtkset_justify gtkset_active gtkshow gtkdestroy gtkset_mousecursor gtkset_mousecursor_normal gtkset_mousecursor_wait gtkset_background gtkset_default_fontset gtkctree_children gtkxpm gtkcreate_xpm) ], + wrappers => [ qw(gtksignal_connect gtkpack gtkpack_ gtkpack__ gtkpack2 gtkpack2_ gtkpack2__ gtkappend gtkadd gtkput gtktext_insert gtkset_usize gtkset_justify gtkset_active gtkshow gtkdestroy gtkset_mousecursor gtkset_mousecursor_normal gtkset_mousecursor_wait gtkset_background gtkset_default_fontset gtkctree_children gtkxpm gtkcreate_xpm) ], ask => [ qw(ask_warn ask_okcancel ask_yesorno ask_from_entry ask_from_list ask_file) ], ); $EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ]; @@ -91,11 +91,6 @@ sub gtksignal_connect($@) { $w->signal_connect(@_); $w } -sub candefault { - my $w = shift; - $w->can_default(1); - $w -} sub gtkpack($@) { my $box = shift; gtkpack_($box, map {; 1, $_ } @_); @@ -152,6 +147,12 @@ sub gtkadd($@) { } $w } +sub gtkput { + my ($w, $w2, $x, $y) = @_; + $w->put($w2, $x, $y); + $w2->show; + $w +} sub gtktext_insert($$) { my ($w, $t) = @_; @@ -227,21 +228,18 @@ sub gtkxpm { new Gtk::Pixmap(gtkcreate_xpm(@_)) } #- these functions return a widget #-############################################################################### -sub create_okcancel($;$$) { - my ($w, $ok, $cancel) = @_; +sub create_okcancel { + my ($w, $ok, $cancel, $spread) = @_; + my $one = ($ok xor $cancel); + $spread ||= $::isStandalone ? "edge" : "spread"; + $ok ||= $::isStandalone ? _("Next ->") : _("Ok"); - if ($::isStandalone) { - gtkadd(create_hbox_(), - ($ok xor $cancel) ? () : candefault(gtksignal_connect(new Gtk::Button($cancel || _("Cancel")), "clicked" => $w->{cancel_clicked} || sub { $w->{retval} = 0; Gtk->main_quit })), - candefault(gtksignal_connect($w->{ok} = new Gtk::Button($ok || _("Next ->")), "clicked" => $w->{ok_clicked} || sub { Gtk->main_quit })), - ); - } - else { - gtkadd(create_hbox(), - gtksignal_connect($w->{ok} = new Gtk::Button($ok || _("Ok")), "clicked" => $w->{ok_clicked} || sub { $w->{retval} = 1; Gtk->main_quit }), - ($ok xor $cancel) ? () : gtksignal_connect(new Gtk::Button($cancel || _("Cancel")), "clicked" => $w->{cancel_clicked} || sub { $w->{retval} = 0; Gtk->main_quit }), - ); - } + my $b1 = gtksignal_connect($w->{ok} = new Gtk::Button($ok), "clicked" => $w->{ok_clicked} || sub { Gtk->main_quit }); + my $b2 = !$one && gtksignal_connect(new Gtk::Button($cancel || _("Cancel")), "clicked" => $w->{cancel_clicked} || sub { $w->{retval} = 0; Gtk->main_quit }); + my @l = grep { $_ } $::isStandalone ? ($b2, $b1) : ($b1, $b2); + + $_->can_default(1) foreach @l; + gtkadd(create_hbox($spread), @l); } sub create_box_with_title($@) { @@ -323,12 +321,7 @@ sub create_packtable($@) { sub create_hbox { my $w = new Gtk::HButtonBox; - $w->set_layout(-spread); - $w; -} -sub create_hbox_ { - my $w = new Gtk::HButtonBox; - $w->set_layout(-edge); + $w->set_layout($_[0] || "spread"); $w; } sub create_vbox { |