summaryrefslogtreecommitdiffstats
path: root/gurpm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-03-21 22:52:41 +0000
committerThierry Vignaud <tv@mageia.org>2013-03-21 22:52:41 +0000
commit968cebcee69fea76bc8a2b65d389af59c53bd6a9 (patch)
treed4ab2139a02007eff3af3a01ce6ab4cada418d6d /gurpm
parent2da511fc8bc48e1f15e805e282c496225d79a046 (diff)
downloadurpmi-968cebcee69fea76bc8a2b65d389af59c53bd6a9.tar
urpmi-968cebcee69fea76bc8a2b65d389af59c53bd6a9.tar.gz
urpmi-968cebcee69fea76bc8a2b65d389af59c53bd6a9.tar.bz2
urpmi-968cebcee69fea76bc8a2b65d389af59c53bd6a9.tar.xz
urpmi-968cebcee69fea76bc8a2b65d389af59c53bd6a9.zip
enable to have a cancel button in global progress bar dialog
(merged from rpmdrake)
Diffstat (limited to 'gurpm')
-rw-r--r--gurpm/RPMProgressDialog.pm67
1 files changed, 67 insertions, 0 deletions
diff --git a/gurpm/RPMProgressDialog.pm b/gurpm/RPMProgressDialog.pm
index 2b23fdb7..357d4f71 100644
--- a/gurpm/RPMProgressDialog.pm
+++ b/gurpm/RPMProgressDialog.pm
@@ -191,6 +191,51 @@ sub set_progressbar {
$w->{progressbar}->set_fraction($local_ratio);
}
+=item validate_cancel($self, $cancel_msg, $cancel_cb)
+
+Add a "Cancel" button, with $cancel_msg as label, calling
+$cancel_cb when clicked.
+
+=cut
+
+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->{mainbox}->add($self->{hbox_cancel});
+ $self->{cancel}->signal_connect('clicked' => \&$cancel_cb);
+ $self->{hbox_cancel}->show_all;
+ }
+ $self->{cancel}->set_sensitive(1);
+ $self->{cancel}->show;
+}
+
+=item invalidate_cancel($self)
+
+Disable the "Cancel" button if any.
+
+=cut
+
+sub invalidate_cancel {
+ my ($self) = @_;
+ $self->{cancel} and $self->{cancel}->set_sensitive(0);
+}
+
+=item invalidate_cancel($self)
+
+Disable the "Cancel" button if any.
+
+=cut
+
+
+sub invalidate_cancel_forever {
+ my ($self) = @_;
+ $self->{hbox_cancel} or return;
+ $self->{hbox_cancel}->destroy;
+}
+
+
=item sync($w)
tell Gtk+ to refresh the dialog content if needed.
@@ -213,6 +258,17 @@ sub get_something_done() {
$progress_nb;
}
+=item canceled($w)
+
+Whether downloading has been canceled or not.
+
+=cut
+
+sub canceled {
+ my ($w) = @_;
+ $w->{canceled};
+}
+
=back
=head2 Callbacks
@@ -289,6 +345,17 @@ sub callback_download {
$mainw->sync;
}
+=item callback_cancel()
+
+This callback is to be called when canceling packages download.
+
+=cut
+
+sub callback_cancel {
+ $mainw->{canceled} = 1;
+}
+
+
sub DESTROY {
my ($self) = @_;
undef $mainw;