baseclass: Add is_visible

Remove the duplicated implementations everywhere
This commit is contained in:
Cole Robinson 2019-04-13 17:03:16 -04:00
parent 5367f3343a
commit 3784864e10
10 changed files with 8 additions and 25 deletions

View File

@ -131,7 +131,7 @@ class vmmAddHardware(vmmGObjectUI):
pollnodedev=True)
def close(self, ignore1=None, ignore2=None):
if self.topwin.is_visible():
if self.is_visible():
logging.debug("Closing addhw")
self.topwin.hide()
if self._storagebrowser:
@ -159,9 +159,6 @@ class vmmAddHardware(vmmGObjectUI):
self._vsockdetails.cleanup()
self._vsockdetails = None
def is_visible(self):
return self.topwin.get_visible()
##########################
# Initialization methods #

View File

@ -321,6 +321,9 @@ class vmmGObjectUI(vmmGObject):
def close(self, ignore1=None, ignore2=None):
pass
def is_visible(self):
return bool(self.topwin and self.topwin.get_visible())
def bind_escape_key_close(self):
self.bind_escape_key_close_helper(self.topwin, self.close)

View File

@ -88,7 +88,7 @@ class vmmConnect(vmmGObjectUI):
def show(self, parent):
logging.debug("Showing open connection")
if self.topwin.is_visible():
if self.is_visible():
self.topwin.present()
return

View File

@ -243,12 +243,6 @@ class vmmConsolePages(vmmGObjectUI):
self.config.on_console_accels_changed(self._refresh_enable_accel))
def is_visible(self):
if self.topwin:
return self.topwin.get_visible()
else:
return False
def _cleanup(self):
self.vm = None

View File

@ -193,9 +193,6 @@ class vmmCreate(vmmGObjectUI):
# Standard window methods #
###########################
def is_visible(self):
return self.topwin.get_visible()
def show(self, parent, uri):
logging.debug("Showing new vm wizard")

View File

@ -754,9 +754,6 @@ class vmmDetails(vmmGObjectUI):
vmmEngine.get_instance().decrement_window_counter()
return 1
def is_visible(self):
return bool(self.topwin.get_visible())
##########################
# Initialization helpers #

View File

@ -182,9 +182,6 @@ class vmmHost(vmmGObjectUI):
vmmEngine.get_instance().increment_window_counter()
def is_visible(self):
return self.topwin.get_visible()
def close(self, ignore1=None, ignore2=None):
logging.debug("Closing host window for %s", self.conn)
if not self.is_visible():

View File

@ -221,13 +221,11 @@ class vmmManager(vmmGObjectUI):
if self._window_size:
self.config.set_manager_window_size(*self._window_size)
def is_visible(self):
return bool(self.topwin.get_visible())
def set_startup_error(self, msg):
self.widget("vm-notebook").set_current_page(1)
self.widget("startup-error-label").set_text(msg)
################
# Init methods #
################

View File

@ -78,7 +78,7 @@ class vmmOSList(vmmGObjectUI):
def _set_default_selection(self):
os_list = self.widget("os-list")
sel = os_list.get_selection()
if not self.topwin.get_visible():
if not self.is_visible():
return
if not len(os_list.get_model()):
return

View File

@ -45,7 +45,7 @@ class vmmStorageBrowser(vmmGObjectUI):
self.conn.schedule_priority_tick(pollpool=True)
def close(self, ignore1=None, ignore2=None):
if self.topwin.is_visible():
if self.is_visible():
logging.debug("Closing storage browser")
self.topwin.hide()
self.storagelist.close()