summaryrefslogtreecommitdiffstats
path: root/perl-install/my_gtk.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-04-10 14:06:56 +0000
committerFrancois Pons <fpons@mandriva.com>2000-04-10 14:06:56 +0000
commitf8ce98a9ff2c26b6b7e613e4c994382c509aa630 (patch)
tree78bdb38600e4b063e772b534a94515201c6ce701 /perl-install/my_gtk.pm
parenta4e04610e2ce4e8f97805ba06bd4a02a6dac49f5 (diff)
downloaddrakx-backup-do-not-use-f8ce98a9ff2c26b6b7e613e4c994382c509aa630.tar
drakx-backup-do-not-use-f8ce98a9ff2c26b6b7e613e4c994382c509aa630.tar.gz
drakx-backup-do-not-use-f8ce98a9ff2c26b6b7e613e4c994382c509aa630.tar.bz2
drakx-backup-do-not-use-f8ce98a9ff2c26b6b7e613e4c994382c509aa630.tar.xz
drakx-backup-do-not-use-f8ce98a9ff2c26b6b7e613e4c994382c509aa630.zip
*** empty log message ***
Diffstat (limited to 'perl-install/my_gtk.pm')
-rw-r--r--perl-install/my_gtk.pm75
1 files changed, 75 insertions, 0 deletions
diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm
index be64d842b..c1f35749e 100644
--- a/perl-install/my_gtk.pm
+++ b/perl-install/my_gtk.pm
@@ -531,6 +531,81 @@ sub _ask_from_list {
$list->grab_focus;
}
+sub _ask_from_list_with_help {
+ my ($o, $title, $messages, $l, $help, $def) = @_;
+ my (undef, @okcancel) = ref $title ? @$title : $title;
+ my $list = new Gtk::List();
+ my ($first_time, $starting_word, $start_reg) = (1, '', "^");
+ my (@widgets, $timeout, $curr);
+
+ my $leave = sub { $o->{retval} = $l->[$curr]; Gtk->main_quit };
+ my $select = sub {
+ $list->select_item($_[1]);
+ };
+
+ ref $title && !@okcancel ?
+ $list->signal_connect(button_release_event => $leave) :
+ $list->signal_connect(button_press_event => sub { &$leave if $_[1]{type} =~ /^2/ });
+
+ $list->signal_connect(select_child => sub {
+ my ($w, $row) = @_;
+ $curr = $list->child_position($row);
+ });
+ $list->signal_connect(key_press_event => sub {
+ my ($w, $e) = @_;
+ my $c = chr $e->{keyval};
+
+ Gtk->timeout_remove($timeout) if $timeout; $timeout = '';
+
+ if ($e->{keyval} >= 0x100) {
+ &$leave if $c eq "\r" || $c eq "\x8d";
+ $starting_word = '' if $e->{keyval} != 0xffe4; # control
+ } else {
+ if ($e->{state} & 4) {
+ #- control pressed
+ $c eq "s" or return 1;
+ $start_reg and $start_reg = '', return 1;
+ $curr++;
+ } else {
+ &$leave if $c eq ' ';
+
+ $curr++ if $starting_word eq '' || $starting_word eq $c;
+ $starting_word .= $c unless $starting_word eq $c;
+ }
+ my $word = quotemeta $starting_word;
+ my $j; for ($j = 0; $j < @$l; $j++) {
+ $l->[($j + $curr) % @$l] =~ /$start_reg$word/i and last;
+ }
+ $j == @$l ?
+ $starting_word = '' :
+ &$select(($j + $curr) % @$l);
+
+ $w->{timeout} = $timeout = Gtk->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 } );
+ }
+ 1;
+ });
+
+ $o->{ok_clicked} = $leave;
+ $o->{cancel_clicked} = sub { $o->destroy; die "ask_from_list cancel" }; #- make sure windows doesn't live any more.
+ gtkadd($o->{window},
+ gtkpack($o->create_box_with_title(@$messages),
+ gtkpack_(new Gtk::VBox(0,7),
+ 1, @$l > 15 ? gtkset_usize(createScrolledWindow($list), 200, min(350, $::windowheight - 60)) : $list,
+ @okcancel || !ref $title ? (0, create_okcancel($o, @okcancel)) : ())
+ ));
+ $o->show; #- otherwise the moveto is not done
+ my $tips = new Gtk::Tooltips;
+ my $toselect; map_index {
+ my $item = new Gtk::ListItem($_);
+ $list->append_items($item);
+ $tips->set_tip($item, $help->{$_}) if $help->{$_};
+ $item->show;
+ $toselect = $::i if $def && $_ eq $def;
+ } @$l;
+ &$select($toselect);
+
+ $list->grab_focus;
+}
sub _ask_warn($@) {
my ($o, @msgs) = @_;