mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
baseclass: Add is_visible
Remove the duplicated implementations everywhere
This commit is contained in:
parent
5367f3343a
commit
3784864e10
@ -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 #
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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 #
|
||||
|
@ -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():
|
||||
|
@ -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 #
|
||||
################
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user