diff options
-rw-r--r-- | gurpm/RPMProgressDialog.pm | 30 | ||||
-rwxr-xr-x | gurpmi | 22 | ||||
-rw-r--r-- | gurpmi.pm | 28 | ||||
-rwxr-xr-x | gurpmi2 | 42 |
4 files changed, 61 insertions, 61 deletions
diff --git a/gurpm/RPMProgressDialog.pm b/gurpm/RPMProgressDialog.pm index 84b1767c..3ef68fc3 100644 --- a/gurpm/RPMProgressDialog.pm +++ b/gurpm/RPMProgressDialog.pm @@ -5,7 +5,7 @@ package gurpm::RPMProgressDialog; #- Copyright (C) 2013 Mageia # Sharing code from gurpmi2 && Rpmdrake::gurpm -# Gtk2 only (no ugtk3/mygtk3) as it's used by gurpmi too... +# Gtk3 only (no ugtk3/mygtk3) as it's used by gurpmi too... # =head1 SYNOPSYS @@ -18,7 +18,7 @@ that presents a global progress bar. How to use: my $w = gurpm::RPMProgressDialog->new: - #$w->change_widget(Gtk2::Box->new); + #$w->change_widget(Gtk3::Box->new); label(N("Preparing packages installation...")); ... # compute packages to install/remove... $w->init_progressbar; @@ -35,13 +35,13 @@ How to use: =cut use strict; -use Gtk2; +use Gtk3; use urpm::download; use urpm::msg 'N'; use urpm::util qw(max member); use Scalar::Util qw(weaken); -our @ISA = qw(Gtk2::Window); +our @ISA = qw(Gtk3::Window); sub title { $::auto_select ? N("Distribution Upgrade") : N("Packages installation"); @@ -70,7 +70,7 @@ Arguments are an urpm object and a quit routine reference. sub new { my ($self, $global_urpm, $o_quit, $o_no_modal) = @_; # my $w = ugtk3->new($title, %options, default_width => 600, width => 600); - my $w = $mainw = bless(Gtk2::Window->new('toplevel'), $self); + my $w = $mainw = bless(Gtk3::Window->new('toplevel'), $self); $old_main_window = $::main_window; $::main_window = $w; @@ -84,7 +84,7 @@ sub new { $w->set_type_hint('dialog'); $w->set_modal(1); } - $w->{mainbox} = Gtk2::VBox->new(0, 5); + $w->{mainbox} = Gtk3::VBox->new(0, 5); $w->add($w->{mainbox}); $urpm = $global_urpm; @@ -124,8 +124,8 @@ sets the window to a please-wait message sub label { my ($w, $o_text) = @_; - my $wait_vbox = Gtk2::VBox->new(0, 5); - my $label = Gtk2::Label->new($o_text || N("Please wait...")); + my $wait_vbox = Gtk3::VBox->new(0, 5); + my $label = Gtk3::Label->new($o_text || N("Please wait...")); $label->set_alignment(0.5, 0.5); $wait_vbox->pack_start($label, 1, 1, 0); $w->change_widget($wait_vbox); @@ -136,7 +136,7 @@ sub label { # From ugtk3.pm/mygtk3.pm: sub gtk_new_Label_Left { my ($text) = @_; - my $w = Gtk2::Label->new($text); + my $w = Gtk3::Label->new($text); $w->set_alignment(0, 0); $w; } @@ -149,18 +149,18 @@ Put a progress bar in the dialog. sub init_progressbar { my ($w) = @_; - my $vbox = Gtk2::VBox->new(0, 5); + my $vbox = Gtk3::VBox->new(0, 5); my $global_label = gtk_new_Label_Left('<b>' . $w->title . '</b>'); $global_label->set_use_markup(1); $vbox->pack_start($global_label, 0, 0, 0); - my $global_progressbar = $w->{global_progressbar} = Gtk2::ProgressBar->new; + my $global_progressbar = $w->{global_progressbar} = Gtk3::ProgressBar->new; $vbox->pack_start($global_progressbar, 0, 0, 0); $vbox->pack_start($w->{progresslabel} = gtk_new_Label_Left('-'), 1, 1, 0); - my $progressbar = Gtk2::ProgressBar->new; + my $progressbar = Gtk3::ProgressBar->new; $progressbar->set_size_request($progressbar_size, -1); $vbox->pack_start($progressbar, 0, 0, 0); $w->{progressbar} = $progressbar; @@ -204,8 +204,8 @@ $cancel_cb when clicked. sub validate_cancel { my ($self, $cancel_msg, $cancel_cb) = @_; if (!$self->{cancel}) { - $self->{hbox_cancel} = Gtk2::HButtonBox->new; - $self->{hbox_cancel}->add($self->{cancel} = Gtk2::Button->new($cancel_msg)); + $self->{hbox_cancel} = Gtk3::HButtonBox->new; + $self->{hbox_cancel}->add($self->{cancel} = Gtk3::Button->new($cancel_msg)); $self->{mainbox}->add($self->{hbox_cancel}); $self->{cancel}->signal_connect('clicked' => \&$cancel_cb); $self->{hbox_cancel}->show_all; @@ -248,7 +248,7 @@ tell Gtk+ to refresh the dialog content if needed. sub sync { my ($w) = @_; $w->show; - Gtk2->main_iteration while Gtk2->events_pending; + Gtk3->main_iteration while Gtk3->events_pending; } =item gurpm::RPMProgressDialog::get_something_done() @@ -10,7 +10,7 @@ BEGIN { #- set up a safe path and environment delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; } -use Gtk2; +use Gtk3; use gurpmi; use urpm::util 'basename'; @@ -29,17 +29,17 @@ my @all_rpms = gurpmi::parse_command_line(); #- Now, the graphical stuff. -Gtk2->init; +Gtk3->init; #- Create main window -$mainw = Gtk2::Window->new('toplevel'); +$mainw = Gtk3::Window->new('toplevel'); $mainw->set_border_width(3); $mainw->set_title(N("RPM installation")); $mainw->signal_connect(destroy => \&cancel_n_quit); $mainw->set_position('center'); $mainw->set_modal(0); -$mainbox = Gtk2::VBox->new(0, 5); +$mainbox = Gtk3::VBox->new(0, 5); $mainw->add($mainbox); sub all_descriptions { @@ -50,11 +50,11 @@ sub all_descriptions { foreach (@all_rpms) { unless (-e $_) { $mainbox->pack_start(new_label(N("Error: unable to find file %s, will cancel operation", $_)), 1, 1, 0); - my $abort_button = Gtk2::Button->new(but(N("_Ok"))); + my $abort_button = Gtk3::Button->new(but(N("_Ok"))); $abort_button->signal_connect(clicked => sub { cancel_n_quit(); exit 1 }); add_button_box($mainbox, $abort_button); $mainw->show_all; - Gtk2->main; + Gtk3->main; } /\.src\.rpm$/ ? push(@$srpms, $_) : push(@$rpms, $_); } @@ -102,9 +102,9 @@ Proceed?", all_descriptions(@all_rpms)) } { #- buttons - my $inst_button = Gtk2::Button->new(but(N("_Install"))); - my $save_button = @all_rpms == 1 ? Gtk2::Button->new(but(N("_Save"))) : undef; - my $ccel_button = Gtk2::Button->new(but(N("_Cancel"))); + my $inst_button = Gtk3::Button->new(but(N("_Install"))); + my $save_button = @all_rpms == 1 ? Gtk3::Button->new(but(N("_Save"))) : undef; + my $ccel_button = Gtk3::Button->new(but(N("_Cancel"))); $inst_button->signal_connect(clicked => sub { #- performs installation. @@ -112,7 +112,7 @@ Proceed?", all_descriptions(@all_rpms)) proceed(); }); $save_button and $save_button->signal_connect(clicked => sub { - my $file_dialog = Gtk2::FileSelection->new(N("Choose location to save file")); + my $file_dialog = Gtk3::FileSelection->new(N("Choose location to save file")); $file_dialog->set_modal(1); $file_dialog->set_position('center'); my $filename = @$srpms > 0 ? $srpms->[0] : $rpms->[0]; @@ -131,4 +131,4 @@ Proceed?", all_descriptions(@all_rpms)) } $mainw->show_all; -Gtk2->main; +Gtk3->main; @@ -4,7 +4,7 @@ package gurpmi; #- Copyright (C) 2005-2010 Mandriva SA #- $Id: gurpmi.pm 271299 2010-11-21 15:54:30Z peroyvind $ -#- This is needed because text printed by Gtk2 will always be encoded +#- This is needed because text printed by Gtk3 will always be encoded #- in UTF-8; we first check if LC_ALL is defined, because if it is, #- changing only LC_COLLATE will have no effect. use POSIX (); @@ -19,7 +19,7 @@ if ($collation_locale) { use urpm; use strict; -use Gtk2; +use Gtk3; use urpm::util 'member'; use urpm::msg; use urpm::args; @@ -48,7 +48,7 @@ on a Mageia Linux distribution. =cut -urpm::select::add_packages_to_priority_upgrade_list('gurpmi', 'perl-Glib', 'perl-Gtk2'); +urpm::select::add_packages_to_priority_upgrade_list('gurpmi', 'perl-Glib', 'perl-Gtk3'); sub usage () { print urpm::args::copyright('gurpmi', [ '1999-2010', 'Mandriva' ]) @@ -125,8 +125,8 @@ Quits top level gtk+ main loop or, if not such a loop, terminates with 1 as exit =cut sub quit() { - if (Gtk2->main_level) { - Gtk2->main_quit; + if (Gtk3->main_level) { + Gtk3->main_quit; } else { # just exit if not in main loop (eg: while starting the GUI) exit 1; @@ -140,7 +140,7 @@ Quits gtk+ main loop and terminates with 1 as exit code =cut sub cancel_n_quit() { - Gtk2->main_quit; + Gtk3->main_quit; exit(1); } @@ -152,7 +152,7 @@ Packs the buttons in an horizontal ButtonBox, on edges. sub add_button_box { my ($vbox, @buttons) = @_; - my $hbox = Gtk2::HButtonBox->new; + my $hbox = Gtk3::HButtonBox->new; $vbox->pack_start($hbox, 0, 0, 0); $hbox->set_layout('edge'); $_->set_alignment(0.5, 0.5), $hbox->add($_) foreach @buttons; @@ -160,14 +160,14 @@ sub add_button_box { =item new_label($msg) -Creates a new Gtk2::Label widget. +Creates a new Gtk3::Label widget. If messages is too big, it's wrapped in a scrolled window =cut sub new_label { my ($msg) = @_; - my $label = Gtk2::Label->new($msg); + my $label = Gtk3::Label->new($msg); $label->set_line_wrap(1); $label->set_alignment(0.5, 0.5); if (($msg =~ tr/\n/\n/) > 5) { @@ -188,19 +188,19 @@ Creates a scrolled window around the $W widget # copied from ugtk3: sub create_scrolled_window { my ($W, $o_policy, $o_viewport_shadow) = @_; - my $w = Gtk2::ScrolledWindow->new(undef, undef); + my $w = Gtk3::ScrolledWindow->new(undef, undef); $w->set_policy($o_policy ? @$o_policy : ('automatic', 'automatic')); - if (member(ref($W), qw(Gtk2::Layout Gtk2::Html2::View Gtk2::Text Gtk2::TextView Gtk2::TreeView))) { + if (member(ref($W), qw(Gtk3::Layout Gtk3::Html2::View Gtk3::Text Gtk3::TextView Gtk3::TreeView))) { $w->add($W); } else { $w->add_with_viewport($W); } $o_viewport_shadow and $w->child->set_shadow_type($o_viewport_shadow); $W->can('set_focus_vadjustment') and $W->set_focus_vadjustment($w->get_vadjustment); - $W->set_left_margin(6) if ref($W) =~ /Gtk2::TextView/; + $W->set_left_margin(6) if ref($W) =~ /Gtk3::TextView/; $W->show; - if (ref($W) =~ /Gtk2::TextView|Gtk2::TreeView/) { - my $f = Gtk2::Frame->new; + if (ref($W) =~ /Gtk3::TextView|Gtk3::TreeView/) { + my $f = Gtk3::Frame->new; $w->show; # unlike ugtk3, we'd to do this explicitely... $f->set_shadow_type('in'); $f->add($w); @@ -19,7 +19,7 @@ use urpm::get_pkgs; use urpm::msg; use urpm::select; use urpm::main_loop; -use Gtk2; +use Gtk3; #- default options. our $allow_medium_change = 0; @@ -43,7 +43,7 @@ $> and fatal(N("Must be root")); #- Now, the graphical stuff. -Gtk2->init; +Gtk3->init; #- Initialize urpm @@ -98,7 +98,7 @@ if (@ask_unselect) { : do_install(); $mainw->show_all; -Gtk2->main; +Gtk3->main; my ($rpm_lock, $urpmi_lock); @@ -112,9 +112,9 @@ sub ask_warn { my $nb_lines = $message =~ tr/\n/\n/; my $w; if ($nb_lines > 30 || $message =~ /^transaction is too small/) { - $w = Gtk2::Dialog->new(N("Warning"), $mainw, [qw(modal destroy-with-parent)], N("Ok"), 'ok'); - $w->vbox->add(my $f = Gtk2::Frame->new); - my $sw = create_scrolled_window(my $text = Gtk2::TextView->new); + $w = Gtk3::Dialog->new(N("Warning"), $mainw, [qw(modal destroy-with-parent)], N("Ok"), 'ok'); + $w->vbox->add(my $f = Gtk3::Frame->new); + my $sw = create_scrolled_window(my $text = Gtk3::TextView->new); $sw->set_border_width(2); $text->set_wrap_mode('word'); $f->add($sw); @@ -124,7 +124,7 @@ sub ask_warn { $w->set_size_request(400, 400); $w->set_default_response('ok'); } else { - $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', $message); + $w = Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', $message); } $w->run; $w->destroy; @@ -136,7 +136,7 @@ sub configure_urpm { $urpm->{fatal} = sub { printf STDERR "%s\n", $_[1]; - Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'error', 'ok', Locale::gettext::iconv($_[1], undef, 'UTF-8'))->run; + Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'error', 'ok', Locale::gettext::iconv($_[1], undef, 'UTF-8'))->run; quit(); exit $_[0]; }; @@ -159,15 +159,15 @@ sub ask_choice { return $choices->[0] if $gurpmi::options{auto}; my $radio; my @radios = map { - $radio = Gtk2::RadioButton->new_with_label( + $radio = Gtk3::RadioButton->new_with_label( $radio ? $radio->get_group : undef, (scalar $_->fullname) . " : " . $_->summary . ($_->flag_installed ? N(" (to upgrade)") : '') . ($_->flag_upgrade ? N(" (to install)") : '') ); } @$choices; - my $d = Gtk2::Dialog->new(N("Package choice"), $mainw, [], N("_Cancel") => 0, N("_Ok") => 1); - my $label = Gtk2::Label->new(N("One of the following packages is needed:")); + my $d = Gtk3::Dialog->new(N("Package choice"), $mainw, [], N("_Cancel") => 0, N("_Ok") => 1); + my $label = Gtk3::Label->new(N("One of the following packages is needed:")); $label->set_alignment(0.5, 0.5); $d->vbox->pack_start($label, 1, 1, 0); $d->vbox->pack_start($_, 1, 1, 0) foreach @radios; @@ -188,7 +188,7 @@ sub ask_choice { sub ask_continue { my ($msg, $nextclosure, $o_list, $o_end_msg) = @_; - my $vbox = Gtk2::VBox->new(0, 5); + my $vbox = Gtk3::VBox->new(0, 5); $vbox->pack_start(new_label($msg), 1, 1, 0); $urpm->{log}($msg); warn ">> o_list='$o_list'\n"; @@ -196,8 +196,8 @@ sub ask_continue { $vbox->pack_start(new_label($o_list), 1, 1, 0); $vbox->pack_start(new_label($o_end_msg), 1, 1, 0); } - my $continue_button = Gtk2::Button->new(but(N("_Ok"))); - my $quit_button = Gtk2::Button->new(but(N("_Abort"))); + my $continue_button = Gtk3::Button->new(but(N("_Ok"))); + my $quit_button = Gtk3::Button->new(but(N("_Abort"))); $quit_button->signal_connect(clicked => sub { $urpm->{log}("=> cancel"); &quit(); exit 1 }); $continue_button->signal_connect(clicked => sub { $urpm->{log}("=> ok"); goto &$nextclosure }); add_button_box($vbox, $quit_button, $continue_button); @@ -219,7 +219,7 @@ sub ask_continue_if_no_auto { sub ask_continue_blocking { my ($msg) = @_; - my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'question', 'yes-no', $msg); + my $w = Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'question', 'yes-no', $msg); my $answer = $w->run; $w->destroy; $urpm->{log}($msg . " => " . $answer); @@ -279,7 +279,7 @@ sub do_install_3 () { }, copy_removable => sub { #FIXME: use use udisks to wait-for/mount cdroms: - my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok-cancel', + my $w = Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok-cancel', N("Please insert the medium named \"%s\"", $_[0]) ); my $response = $w->run; @@ -306,13 +306,13 @@ sub do_install_3 () { $urpmi_lock->unlock; $rpm_lock->unlock; urpm::removable::try_umounting_removables($urpm); - my $vbox = Gtk2::VBox->new(0, 5); # FIXME: should it be change_widget??? - my $progress_label = Gtk2::Label->new('-'); # TEST ME + my $vbox = Gtk3::VBox->new(0, 5); # FIXME: should it be change_widget??? + my $progress_label = Gtk3::Label->new('-'); # TEST ME return 0 if $gurpmi::options{auto}; my $sw = create_scrolled_window($progress_label); $sw->set_size_request(500, 200); $vbox->pack_start($sw, 1, 1, 0); - my $quit_button = Gtk2::Button->new(but(N("_Done"))); + my $quit_button = Gtk3::Button->new(but(N("_Done"))); $quit_button->signal_connect(clicked => \&quit); add_button_box($vbox, $quit_button); $mainw->change_widget($vbox); @@ -321,7 +321,7 @@ sub do_install_3 () { need_restart => sub { return if $gurpmi::options{auto}; my ($need_restart_formatted) = @_; - my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', + my $w = Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', join("\n", values %$need_restart_formatted) ); $w->run; @@ -375,7 +375,7 @@ return_with_exit_code: sub ask_yes_or_no { my ($_title, $msg) = @_; # MessageDialogs have no titles unless using 'secondary-text' - my $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'yes-no', $msg); + my $w = Gtk3::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'yes-no', $msg); my $response = $w->run; $w->destroy; $response eq 'yes'; |