summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2010-12-08 14:14:38 -0500
committerCole Robinson <crobinso@redhat.com>2010-12-08 14:14:38 -0500
commit41605b2d6f42694f1eb53da3b60160812360efa8 (patch)
tree65f9759f4b005a8cba64be9372b2267e2168126c
parent59b69f0a5145b04ecef78f6d191538afac3a6ebd (diff)
downloadvirt-manager-41605b2d6f42694f1eb53da3b60160812360efa8.tar.gz
progress: Show cancel errors in the progress dialog
-rw-r--r--src/virtManager/asyncjob.py49
-rw-r--r--src/virtManager/engine.py4
-rw-r--r--src/virtManager/migrate.py4
-rw-r--r--src/vmm-progress.glade40
4 files changed, 68 insertions, 29 deletions
diff --git a/src/virtManager/asyncjob.py b/src/virtManager/asyncjob.py
index e488fe03..0ed64861 100644
--- a/src/virtManager/asyncjob.py
+++ b/src/virtManager/asyncjob.py
@@ -24,7 +24,6 @@ import gtk
import gobject
from virtManager import util
-from virtManager.error import vmmErrorDialog
# This thin wrapper only exists so we can put debugging
# code in the run() method every now & then
@@ -50,11 +49,14 @@ class vmmAsyncJob(gobject.GObject):
"/vmm-progress.glade",
"vmm-progress", domain="virt-manager")
self.topwin = self.window.get_widget("vmm-progress")
- self.err = vmmErrorDialog(self.topwin)
+ self.topwin.set_title(title)
+ self.topwin.hide()
+
self.window.signal_autoconnect({
"on_async_job_delete_event" : self.delete,
"on_async_job_cancel_clicked" : self.cancel,
})
+
self.cancel_job = cancel_back
self.cancel_args = cancel_args or []
self.cancel_args.append(self)
@@ -63,11 +65,6 @@ class vmmAsyncJob(gobject.GObject):
else:
self.window.get_widget("cancel-async-job").hide()
self.job_canceled = False
- self.window.get_widget("pbar-text").set_text(text)
-
- self.topwin = self.window.get_widget("vmm-progress")
- self.topwin.set_title(title)
- self.topwin.hide()
# Callback sets this if there is an error
self._error_info = None
@@ -75,6 +72,7 @@ class vmmAsyncJob(gobject.GObject):
self.stage = self.window.get_widget("pbar-stage")
self.pbar = self.window.get_widget("pbar")
+ self.window.get_widget("pbar-text").set_text(text)
args.append(self)
self.bg_thread = asyncJobWorker(callback, args)
@@ -117,22 +115,34 @@ class vmmAsyncJob(gobject.GObject):
if thread_active:
self.cancel()
+ def set_stage_text(self, text, canceling=False):
+ if self.job_canceled and not canceling:
+ return
+ self.stage.set_text(text)
+
+ def hide_warning(self):
+ self.window.get_widget("warning-box").hide()
+
def show_warning(self, summary):
- self.err.ok(summary)
+ markup = "<small>%s</small>" % summary
+ self.window.get_widget("warning-box").show()
+ self.window.get_widget("warning-text").set_markup(markup)
def cancel(self, ignore1=None, ignore2=None):
- if self.cancel_job:
- self.cancel_job(*self.cancel_args)
+ if not self.cancel_job:
+ return
+
+ self.cancel_job(*self.cancel_args)
+ if self.job_canceled:
+ self.hide_warning()
+ self.set_stage_text(_("Cancelling job..."), canceling=True)
def pulse_pbar(self, progress="", stage=None):
gtk.gdk.threads_enter()
try:
self.is_pulsing = True
self.pbar.set_text(progress)
- if stage is not None:
- self.stage.set_text(stage)
- else:
- self.stage.set_text(_("Processing..."))
+ self.set_stage_text(stage or _("Processing..."))
finally:
gtk.gdk.threads_leave()
@@ -142,11 +152,9 @@ class vmmAsyncJob(gobject.GObject):
gtk.gdk.threads_enter()
try:
self.is_pulsing = False
- if stage is not None:
- self.stage.set_text(stage)
- else:
- self.stage.set_text(_("Processing..."))
+ self.set_stage_text(stage or _("Processing..."))
self.pbar.set_text(progress)
+
if frac > 1:
frac = 1.0
if frac < 0:
@@ -161,10 +169,7 @@ class vmmAsyncJob(gobject.GObject):
gtk.gdk.threads_enter()
try:
self.is_pulsing = False
- if stage is not None:
- self.stage.set_text(stage)
- else:
- self.stage.set_text(_("Completed"))
+ self.set_stage_text(stage or _("Completed"))
self.pbar.set_text(progress)
self.pbar.set_fraction(1)
finally:
diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py
index e5feca5d..3df76659 100644
--- a/src/virtManager/engine.py
+++ b/src/virtManager/engine.py
@@ -844,13 +844,15 @@ class vmmEngine(gobject.GObject):
src.err.show_err(_("Error saving domain: %s") % error, details)
def _save_cancel(self, vm, asyncjob):
+ logging.debug("Cancelling save job")
if not vm:
return
try:
vm.abort_job()
except Exception, e:
- asyncjob.show_warning(str(e))
+ logging.exception("Error cancelling save job")
+ asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
return
asyncjob.job_canceled = True
diff --git a/src/virtManager/migrate.py b/src/virtManager/migrate.py
index 064a3f5e..71a3d88d 100644
--- a/src/virtManager/migrate.py
+++ b/src/virtManager/migrate.py
@@ -491,13 +491,15 @@ class vmmMigrateDialog(gobject.GObject):
return False
def cancel_migration(self, vm, asyncjob):
+ logging.debug("Cancelling migrate job")
if not vm:
return
try:
vm.abort_job()
except Exception, e:
- asyncjob.show_warning(str(e))
+ logging.exception("Error cancelling migrate job")
+ asyncjob.show_warning(_("Error cancelling migrate job: %s") % e)
return
asyncjob.job_canceled = True
diff --git a/src/vmm-progress.glade b/src/vmm-progress.glade
index 677d6be4..0a804ac8 100644
--- a/src/vmm-progress.glade
+++ b/src/vmm-progress.glade
@@ -43,8 +43,6 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
- <property name="xpad">10</property>
- <property name="ypad">10</property>
<property name="label" translatable="yes">Please wait a few moments...</property>
<property name="wrap">True</property>
</widget>
@@ -58,6 +56,38 @@
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="warning-box">
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkImage" id="warning-icon">
+ <property name="visible">True</property>
+ <property name="xpad">3</property>
+ <property name="stock">gtk-dialog-warning</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="warning-text">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label">some warning</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkLabel" id="pbar-stage">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -69,7 +99,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -80,7 +110,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -114,7 +144,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
</widget>