diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-12-08 15:26:33 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-12-08 15:26:33 +0000 |
commit | add2cc6b19432a8214ded2afb7cbc64e4338a46b (patch) | |
tree | 5c672b067c402de4711282624cd413c17979a335 | |
parent | 79c5cc3ea66382767f799c54710d6fad49a9bf6b (diff) | |
download | urpmi-add2cc6b19432a8214ded2afb7cbc64e4338a46b.tar urpmi-add2cc6b19432a8214ded2afb7cbc64e4338a46b.tar.gz urpmi-add2cc6b19432a8214ded2afb7cbc64e4338a46b.tar.bz2 urpmi-add2cc6b19432a8214ded2afb7cbc64e4338a46b.tar.xz urpmi-add2cc6b19432a8214ded2afb7cbc64e4338a46b.zip |
Nice scrollable windows for long messages
-rw-r--r-- | gurpmi | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -75,6 +75,22 @@ sub sync { Gtk2->main_iteration while Gtk2->events_pending; } +sub new_label { + my ($msg) = @_; + my $label = Gtk2::Label->new($msg); + $label->set_line_wrap(1); + $label->set_alignment(0.5, 0.5); + if (($msg =~ y/\n/\n/) > 5) { + my $sw = Gtk2::ScrolledWindow->new(); + $sw->set_policy('never', 'automatic'); + $sw->add_with_viewport($label); + $sw->set_size_request(-1,200); + return $sw; + } else { + return $label; + } +} + #- sets the window to a please-wait message sub wait_label { my $wait_vbox = Gtk2::VBox->new(0, 5); @@ -118,7 +134,7 @@ $mainw->add($mainbox); #- change depending on the number of rpms, and on the presence of srpms ($srpms, $rpms) = partition { /\.src\.rpm$/ } @all_rpms; { - my $label = Gtk2::Label->new( + my $msg = ( @$srpms > 0 ? N("You have selected a source package: @@ -139,9 +155,7 @@ You may prefer to just save it. What is your choice?", $rpms->[0]) Proceed?", join "\n", @all_rpms) ); - $label->set_line_wrap(1); - $label->set_alignment(0.5, 0.5); - $mainbox->pack_start($label, 1, 1, 0); + $mainbox->pack_start(new_label($msg), 1, 1, 0); } { #- buttons @@ -226,9 +240,7 @@ sub ask_choice { sub ask_continue { my ($msg, $nextclosure) = @_; my $vbox = Gtk2::VBox->new(0, 5); - my $label = Gtk2::Label->new($_[0]); - $label->set_alignment(0.5, 0.5); - $vbox->pack_start($label, 1, 1, 0); + $vbox->pack_start(new_label($msg), 1, 1, 0); my $continue_button = Gtk2::Button->new(but N("_Ok")); my $quit_button = Gtk2::Button->new(but N("_Abort")); $quit_button->signal_connect(clicked => \&quit); |