summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-01-21 13:04:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-01-21 13:04:54 +0000
commit39dc82c13e55f94cf00eeddcf4579627d7fcf34b (patch)
tree9f0f1715f7881519ee217517f83a015fa861c62d /perl-install
parent424f21c103811b61abfb7475f201d8fc98f4def3 (diff)
downloaddrakx-backup-do-not-use-39dc82c13e55f94cf00eeddcf4579627d7fcf34b.tar
drakx-backup-do-not-use-39dc82c13e55f94cf00eeddcf4579627d7fcf34b.tar.gz
drakx-backup-do-not-use-39dc82c13e55f94cf00eeddcf4579627d7fcf34b.tar.bz2
drakx-backup-do-not-use-39dc82c13e55f94cf00eeddcf4579627d7fcf34b.tar.xz
drakx-backup-do-not-use-39dc82c13e55f94cf00eeddcf4579627d7fcf34b.zip
(ask_fromW): very smart code to know which widget to focus (dilemna is: "Next" vs first widget). One can also force focusing of first widget using $common->{focus_first}
(ask_fromW): have "advanced" widgets above buttons, not below (create_list): fix old bug (nb: this code must be unused) (create_boxradio): need to set {focus_w} to the selected widget (nb: this is ugly) (create_boxradio, $may_go_to_next): no special case for "tab", gtk2 handles things better than gtk1 ($set_all): pass the full_struct to the setters (this allows modifying {focus_w}) (nb: this is ugly)
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/interactive/gtk.pm55
1 files changed, 27 insertions, 28 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm
index 6ebeb5bf3..c52560b2c 100644
--- a/perl-install/interactive/gtk.pm
+++ b/perl-install/interactive/gtk.pm
@@ -46,8 +46,7 @@ sub create_boxradio {
$w->signal_connect(button_press_event => $double_click) if $double_click;
$w->signal_connect(key_press_event => sub {
- my ($w, $event) = @_;
- $may_go_to_next->($w, $event, 'tab');
+ &$may_go_to_next;
1;
});
$w->signal_connect(clicked => sub {
@@ -62,8 +61,11 @@ sub create_boxradio {
} $e->{list}, \@radios;
$boxradio, sub {
- my ($v) = @_;
- mapn { $_[0]->set_active($_[1] eq $v) } \@radios, $e->{list};
+ my ($v, $full_struct) = @_;
+ mapn {
+ $_[0]->set_active($_[1] eq $v);
+ $full_struct->{focus_w} = $_[0] if $_[1] eq $v;
+ } \@radios, $e->{list};
}, $radios[0];
}
@@ -302,7 +304,7 @@ sub create_list {
$item->signal_connect(key_press_event => sub {
my ($_w, $event) = @_;
my $c = chr($event->keyval & 0xff);
- $may_go_to_next->($event) if $event->keyval < 0x100 ? $c eq ' ' : $c eq "\r" || $c eq "\x8d";
+ &$may_go_to_next if $event->keyval < 0x100 ? $c eq ' ' : $c eq "\r" || $c eq "\x8d";
1;
});
$list->append_items($item);
@@ -344,7 +346,7 @@ sub ask_fromW {
my $set_all = sub {
$ignore = 1;
- $_->{set}->(${$_->{e}{val}}) foreach @widgets_always, @widgets_advanced;
+ $_->{set}->(${$_->{e}{val}}, $_) foreach @widgets_always, @widgets_advanced;
$_->{real_w}->set_sensitive(!$_->{e}{disabled}()) foreach @widgets_always, @widgets_advanced;
$ignore = 0;
};
@@ -363,23 +365,12 @@ sub ask_fromW {
my $may_go_to_next = sub {
my ($w, $event, $kind) = @_;
- if ($kind eq 'tab') {
- if (($event->keyval & 0x7f) == 0x9) {
- $w->signal_stop_emission_by_name('key_press_event');
- if ($ind == $#widgets) {
- $mainw->{ok}->grab_focus;
- } else {
- $widgets[$ind+1]{focus_w}->grab_focus;
- }
- }
- } else {
- if (!$event || ($event->keyval & 0x7f) == 0xd) {
- $w->signal_stop_emission_by_name('key_press_event') if $event;
- if ($ind == $#widgets) {
- @widgets == 1 ? $mainw->{ok}->clicked : $mainw->{ok}->grab_focus;
- } else {
- $widgets[$ind+1]{focus_w}->grab_focus;
- }
+ if (!$event || ($event->keyval & 0x7f) == 0xd) {
+ $w->signal_stop_emission_by_name('key_press_event') if $event;
+ if ($ind == $#widgets) {
+ @widgets == 1 ? $mainw->{ok}->clicked : $mainw->{ok}->grab_focus;
+ } else {
+ $widgets[$ind+1]{focus_w}->grab_focus;
}
}
};
@@ -613,11 +604,9 @@ sub ask_fromW {
$has ? create_scrolled_window($w) : $w;
};
- gtkpack_($pack,
- 1, $create_widgets->($always_total_size, @widgets_always),
- if_($common->{ok} || !exists $common->{ok},
- 0, $mainw->create_okcancel($common->{ok}, $common->{cancel}, '', if_(@$l2, $advanced_button))));
+ my $always_pack = $create_widgets->($always_total_size, @widgets_always);
my $has_scroll_always = $has_scroll;
+
my @adv = map { warp_text($_) } @{$common->{advanced_messages}};
$advanced_pack =
gtkpack_(Gtk2::VBox->new(0,0),
@@ -626,11 +615,21 @@ sub ask_fromW {
0, Gtk2::HSeparator->new,
1, $create_widgets->($advanced_total_size, @widgets_advanced));
+ my $buttons_pack = ($common->{ok} || !exists $common->{ok}) && $mainw->create_okcancel($common->{ok}, $common->{cancel}, '', if_(@$l2, $advanced_button));
+
+ $pack->pack_start($always_pack, 1, 1, 0); $always_pack->show;
$pack->pack_start($advanced_pack, 1, 1, 0);
+ $pack->pack_start($buttons_pack, 0, 0, 0) if $buttons_pack; $buttons_pack->show if $buttons_pack;
gtkadd($mainw->{window}, $pack);
$set_default_size->() if $has_scroll_always;
$set_advanced->(0);
- ($common->{focus_cancel} ? $mainw->{cancel} : $mainw->{ok})->grab_focus();
+
+ my $widget_to_focus =
+ $common->{focus_cancel} ? $mainw->{cancel} :
+ @widgets && ($common->{focus_first} || @widgets == 1 && member(ref $widgets[0]{focus_w}, "Gtk2::TreeView", "Gtk2::RadioButton")) ?
+ $widgets[0]{focus_w} :
+ $mainw->{ok};
+ $widget_to_focus->grab_focus();
my $check = sub {
my ($f) = @_;