summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive_gtk.pm
blob: 935766470d9cb1bb7e083d5279dda1b5ce45bbdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package interactive_gtk;

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(interactive);

use interactive;
use common qw(:common);
use my_gtk qw(:helpers :wrappers);

1;

sub ask_from_listW {
    my ($o, $title, $messages, $l, $def) = @_;

    if (@$l < 5 && sum(map { length $_ } @$l) < 70) {
	my $w = my_gtk->new($title);
	my $f = sub { $w->{retval} = $_[1]; Gtk->main_quit };
	gtkadd($w->{window},
	       gtkpack(create_box_with_title($o, @$messages),
		       gtkadd(create_hbox(),
			      map {
				  my $b = new Gtk::Button($_);
				  $b->signal_connect(clicked => [ $f, $_ ]);
				  $_ eq $def and $def = $b;
				  $b;
			      } @$l),
		       ),
	       );
	$def->grab_focus if $def;
	$w->main;
    } else {
	my_gtk::ask_from_list($title, $messages, $l, $def);
    }
}