baseclass: share wizard cursor setting code

This commit is contained in:
Cole Robinson 2017-04-27 15:00:17 -04:00
parent 8181e86098
commit c0a3234633
11 changed files with 39 additions and 77 deletions

View File

@ -1354,9 +1354,7 @@ class vmmAddHardware(vmmGObjectUI):
if error is not None:
self.err.show_err(error, details=details)
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
self._dev = None
if not failure:
@ -1371,10 +1369,7 @@ class vmmAddHardware(vmmGObjectUI):
"input: %s") % str(e))
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
progWin = vmmAsyncJob(self._setup_device, [],
self._finish_cb, [],
_("Creating device"),

View File

@ -238,3 +238,18 @@ class vmmGObjectUI(vmmGObject):
def bind_escape_key_close(self):
self.bind_escape_key_close_helper(self.topwin, self.close)
def set_finish_cursor(self):
self.topwin.set_sensitive(False)
cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
self.topwin.get_window().set_cursor(cursor)
def reset_finish_cursor(self, topwin=None):
if not topwin:
topwin = self.topwin
topwin.set_sensitive(True)
if not topwin.get_window():
return
cursor = Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW)
topwin.get_window().set_cursor(cursor)

View File

@ -803,9 +803,7 @@ class vmmCloneVM(vmmGObjectUI):
return True
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error is not None:
error = (_("Error creating virtual machine clone '%s': %s") %
@ -824,9 +822,7 @@ class vmmCloneVM(vmmGObjectUI):
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
title = (_("Creating virtual machine clone '%s'") %
self.clone_design.clone_name)

View File

@ -366,7 +366,7 @@ class vmmCreate(vmmGObjectUI):
self._failed_guest = None
self._guest = None
self._show_all_os_was_selected = False
self._undo_finish_cursor(self.topwin)
self.reset_finish_cursor()
self.widget("create-pages").set_current_page(PAGE_NAME)
self._page_changed(None, None, PAGE_NAME)
@ -2218,18 +2218,6 @@ class vmmCreate(vmmGObjectUI):
# Guest install routines #
##########################
def _set_finish_cursor(self, topwin):
topwin.set_sensitive(False)
topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
def _undo_finish_cursor(self, topwin):
topwin.set_sensitive(True)
if not topwin.get_window():
return
topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
def _finish_clicked(self, src_ignore):
# Validate the final page
page = self.widget("create-pages").get_current_page()
@ -2241,7 +2229,7 @@ class vmmCreate(vmmGObjectUI):
# Start the install
self._failed_guest = None
self._set_finish_cursor(self.topwin)
self.set_finish_cursor()
if not self.widget("summary-customize").get_active():
self._start_install(guest)
@ -2251,7 +2239,7 @@ class vmmCreate(vmmGObjectUI):
try:
self._show_customize_dialog(guest)
except Exception, e:
self._undo_finish_cursor(self.topwin)
self.reset_finish_cursor()
self.err.show_err(_("Error starting installation: ") + str(e))
return
@ -2287,7 +2275,7 @@ class vmmCreate(vmmGObjectUI):
self._customize_window.show()
def _install_finished_cb(self, error, details, parentobj):
self._undo_finish_cursor(parentobj.topwin)
self.reset_finish_cursor(parentobj.topwin)
if error:
error = (_("Unable to complete install: '%s'") % error)

View File

@ -1111,9 +1111,7 @@ class vmmCreateInterface(vmmGObjectUI):
#####################
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error:
error = _("Error creating interface: '%s'") % error
@ -1134,10 +1132,7 @@ class vmmCreateInterface(vmmGObjectUI):
activate = self.widget("interface-activate").get_active()
# Start the install
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
progWin = vmmAsyncJob(self.do_install, [activate],
self._finish_cb, [],
_("Creating virtual interface"),

View File

@ -791,9 +791,7 @@ class vmmCreateNetwork(vmmGObjectUI):
return net
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error:
error = _("Error creating virtual network: %s") % str(error)
@ -816,10 +814,7 @@ class vmmCreateNetwork(vmmGObjectUI):
self.err.show_err(_("Error generating network xml: %s") % str(e))
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
progWin = vmmAsyncJob(self._async_net_create, [net],
self._finish_cb, [],
_("Creating virtual network..."),

View File

@ -411,9 +411,7 @@ class vmmCreatePool(vmmGObjectUI):
self.emit("pool-created", connkey)
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error:
error = _("Error creating pool: %s") % error
@ -426,11 +424,9 @@ class vmmCreatePool(vmmGObjectUI):
self.close()
def finish(self):
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
build = self.widget("pool-build").get_active()
self.reset_finish_cursor()
build = self.widget("pool-build").get_active()
progWin = vmmAsyncJob(self._async_pool_create, [build],
self._finish_cb, [],
_("Creating storage pool..."),

View File

@ -273,9 +273,7 @@ class vmmCreateVolume(vmmGObjectUI):
self.emit("vol-created", pool.get_connkey(), volname)
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error:
error = _("Error creating vol: %s") % error
@ -295,10 +293,7 @@ class vmmCreateVolume(vmmGObjectUI):
self.show_err(_("Uncaught error validating input: %s") % str(e))
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
progWin = vmmAsyncJob(self._async_vol_create, [],
self._finish_cb, [],
_("Creating storage volume..."),

View File

@ -125,9 +125,7 @@ class vmmDeleteDialog(vmmGObjectUI):
return paths
def _finish_cb(self, error, details):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error is not None:
self.err.show_err(error, details=details)
@ -149,9 +147,7 @@ class vmmDeleteDialog(vmmGObjectUI):
if not ret:
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
title = _("Deleting virtual machine '%s'") % self.vm.get_name()
text = title

View File

@ -352,9 +352,7 @@ class vmmMigrateDialog(vmmGObjectUI):
return uri
def _finish_cb(self, error, details, destconn):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error:
error = _("Unable to migrate guest: %s") % error
@ -385,9 +383,7 @@ class vmmMigrateDialog(vmmGObjectUI):
details=details)
return
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self.set_finish_cursor()
cancel_cb = None
if self.vm.getjobinfo_supported:

View File

@ -460,9 +460,7 @@ class vmmSnapshotPage(vmmGObjectUI):
self.widget("snapshot-new-ok").set_sensitive(bool(src.get_text()))
def _new_finish_cb(self, error, details, newname):
self.topwin.set_sensitive(True)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.TOP_LEFT_ARROW))
self.reset_finish_cursor()
if error is not None:
error = _("Error creating snapshot: %s") % error
@ -530,12 +528,9 @@ class vmmSnapshotPage(vmmGObjectUI):
xml = snap.get_xml_config()
name = snap.name
mime, sndata = self._get_screenshot_data_for_save()
self.topwin.set_sensitive(False)
self.topwin.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.WATCH))
self._snapshot_new_close()
self.set_finish_cursor()
progWin = vmmAsyncJob(
self._do_create_snapshot, [xml, name, mime, sndata],
self._new_finish_cb, [name],