summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-28 23:40:13 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-28 23:40:13 +0000
commit057257fa958febda2bc31653186b34cee42e86d6 (patch)
tree9babe75ebf61e9b27e054e65eb288287d274c710 /perl-install
parentc3d9862e6651b0e5efb051e65e0dcd60ce88cc7f (diff)
downloaddrakx-backup-do-not-use-057257fa958febda2bc31653186b34cee42e86d6.tar
drakx-backup-do-not-use-057257fa958febda2bc31653186b34cee42e86d6.tar.gz
drakx-backup-do-not-use-057257fa958febda2bc31653186b34cee42e86d6.tar.bz2
drakx-backup-do-not-use-057257fa958febda2bc31653186b34cee42e86d6.tar.xz
drakx-backup-do-not-use-057257fa958febda2bc31653186b34cee42e86d6.zip
- make the gtk resolution chooser work
- dropped the differenciation between embedded or not
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Xconfig/resolution_and_depth.pm117
1 files changed, 109 insertions, 8 deletions
diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm
index bb23b8f95..d2a6ff16f 100644
--- a/perl-install/Xconfig/resolution_and_depth.pm
+++ b/perl-install/Xconfig/resolution_and_depth.pm
@@ -118,13 +118,9 @@ sub filter_using_HorizSync {
sub choose {
my ($in, $default_resolution, @resolutions) = @_;
- if (0 && $in->isa('interactive::gtk')) {
- chooseResolutionsGtk($default_resolution, @resolutions);
- } else {
- $in->ask_from_listf(_("Resolutions"), "",
- sub { "$_->{X}x$_->{Y} $_->{Depth}bpp" },
- \@resolutions, $default_resolution || {});
- }
+ $in->ask_from_listf(_("Resolutions"), "",
+ sub { "$_->{X}x$_->{Y} $_->{Depth}bpp" },
+ \@resolutions, $default_resolution || {});
}
@@ -163,7 +159,11 @@ sub configure {
my ($default_resolution, @resolutions) = choices($raw_X, $raw_X->get_resolution, $card, $monitor);
- $default_resolution = choose($in, $default_resolution, @resolutions) or return;
+ if ($in->isa('interactive::gtk')) {
+ $default_resolution = choose_gtk($card, $default_resolution, @resolutions) or return;
+ } else {
+ $default_resolution = choose($in, $default_resolution, @resolutions) or return;
+ }
$raw_X->set_resolution($default_resolution);
$default_resolution;
@@ -182,4 +182,105 @@ sub configure_auto_install {
$default_resolution;
}
+sub choose_gtk {
+ my ($card, $default_resolution, @resolutions) = @_;
+
+ my ($chosen_x_res, $chosen_Depth) = @$default_resolution{'X', 'Depth'};
+ $chosen_x_res ||= 640;
+
+ my %x_res2y_res = map { $_->{X} => $_->{Y} } @resolutions;
+ my %x_res2depth; push @{$x_res2depth{$_->{X}}}, $_->{Depth} foreach @resolutions;
+ my %depth2x_res; push @{$depth2x_res{$_->{Depth}}}, $_->{X} foreach @resolutions;
+
+ require my_gtk;
+ my_gtk->import(qw(:helpers :wrappers));
+ my $W = my_gtk->new(_("Resolution"));
+
+ my %monitor_images_x_res = do {
+ my @l = qw(640 800 1024 1280);
+ my %h = map { $_ => [ gtkcreate_png("monitor-$_.png") ] } @l;
+
+ #- for the other, use the biggest smaller
+ foreach my $x_res (uniq map { $_->{X} } @resolutions) {
+ my $x_res_ = max(grep { $_ <= $x_res } @l);
+ $h{$x_res} ||= $h{$x_res_};
+ }
+ %h;
+ };
+
+ my ($depth_combo, $x_res_combo);
+
+ my $pix_colors = gtkpng("colors");
+ my $set_chosen_Depth_image = sub {
+ $pix_colors->set(gtkcreate_png(
+ $chosen_Depth >= 24 ? "colors.png" :
+ $chosen_Depth >= 15 ? "colors16.png" : "colors8.png"));
+ };
+
+ my $set_chosen_Depth = sub {
+ $chosen_Depth = $_[0];
+ $depth_combo->entry->set_text(translate($depth2text{$chosen_Depth}));
+ $set_chosen_Depth_image->();
+ };
+
+ my $pixmap_mo;
+ my $set_chosen_x_res = sub {
+ $chosen_x_res = $_[0];
+ my $image = $monitor_images_x_res{$chosen_x_res} or internal_error("no image for resolution $chosen_x_res");
+ $pixmap_mo ? $pixmap_mo->set($image->[0], $image->[1]) : ($pixmap_mo = new Gtk::Pixmap($image->[0], $image->[1]));
+ };
+ $set_chosen_x_res->($chosen_x_res);
+
+ gtkadd($W->{window},
+ gtkpack_($W->create_box_with_title(_("Choose the resolution and the color depth"),
+ if_($card->{BoardName}, "(" . _("Graphics card: %s", $card->{BoardName}) . ")"),
+ ),
+ 1, gtkpack2(new Gtk::VBox(0,0),
+ gtkpack2__(new Gtk::VBox(0, 15),
+ $pixmap_mo,
+ gtkpack2(new Gtk::HBox(0,0),
+ create_packtable({ col_spacings => 5, row_spacings => 5},
+ [ $x_res_combo = new Gtk::Combo, new Gtk::Label("")],
+ [ $depth_combo = new Gtk::Combo, gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'), $pix_colors) ],
+ ),
+ ),
+ ),
+ ),
+ 0, gtkadd($W->create_okcancel(_("Ok"), _("Cancel"))),
+ ));
+ $depth_combo->disable_activate;
+ $depth_combo->set_use_arrows_always(1);
+ $depth_combo->entry->set_editable(0);
+ $depth_combo->set_popdown_strings(map { translate($depth2text{$_}) } ikeys %depth2x_res);
+ $depth_combo->entry->signal_connect(changed => sub {
+ my %txt2depth = reverse %depth2text;
+ my $s = $depth_combo->entry->get_text;
+ $chosen_Depth = $txt2depth{untranslate($s, keys %txt2depth)};
+ $set_chosen_Depth_image->();
+
+ if (!member($chosen_x_res, @{$depth2x_res{$chosen_Depth}})) {
+ $set_chosen_x_res->(max(@{$depth2x_res{$chosen_Depth}}));
+ }
+ });
+ $x_res_combo->disable_activate;
+ $x_res_combo->set_use_arrows_always(1);
+ $x_res_combo->entry->set_editable(0);
+ $x_res_combo->set_popdown_strings(map { $_ . "x" . $x_res2y_res{$_} } ikeys %x_res2y_res);
+ $x_res_combo->entry->signal_connect(changed => sub {
+ $x_res_combo->entry->get_text =~ /(.*?)x/;
+ $set_chosen_x_res->($1);
+
+ if (!member($chosen_Depth, @{$x_res2depth{$chosen_x_res}})) {
+ $set_chosen_Depth->(max(@{$x_res2depth{$chosen_x_res}}));
+ }
+ });
+ $set_chosen_Depth->($chosen_Depth);
+ $W->{ok}->grab_focus;
+
+ $x_res_combo->entry->set_text($chosen_x_res . "x" . $x_res2y_res{$chosen_x_res});
+ $W->main or return;
+
+ { X => $chosen_x_res, Depth => $chosen_Depth };
+}
+
1;