From 182eb4bcb64ae2a555f691d4b426bd7fdf26d6e5 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 23 Feb 2010 14:18:12 -0500 Subject: [PATCH] Drop redundant calls to window.show() --- src/virtManager/about.py | 1 - src/virtManager/addhardware.py | 1 - src/virtManager/clone.py | 1 - src/virtManager/connect.py | 1 - src/virtManager/createinterface.py | 1 - src/virtManager/createnet.py | 1 - src/virtManager/createpool.py | 1 - src/virtManager/createvol.py | 1 - src/virtManager/delete.py | 1 - src/virtManager/details.py | 1 - src/virtManager/domain.py | 16 ++++++++++------ src/virtManager/host.py | 6 ++++-- src/virtManager/manager.py | 12 ++++++------ src/virtManager/preferences.py | 2 -- src/virtManager/storagebrowse.py | 1 - 15 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/virtManager/about.py b/src/virtManager/about.py index f8877933..40e80078 100644 --- a/src/virtManager/about.py +++ b/src/virtManager/about.py @@ -48,7 +48,6 @@ class vmmAbout: def show(self): dialog = self.window.get_widget("vmm-about") dialog.set_version(self.config.get_appversion()) - dialog.show_all() dialog.present() def close(self,ignore1=None,ignore2=None): diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py index 7d675e36..6a01898c 100644 --- a/src/virtManager/addhardware.py +++ b/src/virtManager/addhardware.py @@ -166,7 +166,6 @@ class vmmAddHardware(gobject.GObject): def show(self): self.reset_state() - self.topwin.show() self.topwin.present() def close(self, ignore1=None,ignore2=None): diff --git a/src/virtManager/clone.py b/src/virtManager/clone.py index 5d72fab7..99382c10 100644 --- a/src/virtManager/clone.py +++ b/src/virtManager/clone.py @@ -140,7 +140,6 @@ class vmmCloneVM(gobject.GObject): def show(self): self.reset_state() - self.topwin.show() self.topwin.present() def close(self, ignore1=None, ignore2=None): diff --git a/src/virtManager/connect.py b/src/virtManager/connect.py index 8c07575c..4ef6f398 100644 --- a/src/virtManager/connect.py +++ b/src/virtManager/connect.py @@ -108,7 +108,6 @@ class vmmConnect(gobject.GObject): def show(self): win = self.window.get_widget("vmm-open-connection") - win.show_all() win.present() self.reset_state() diff --git a/src/virtManager/createinterface.py b/src/virtManager/createinterface.py index 464b5d18..dd628959 100644 --- a/src/virtManager/createinterface.py +++ b/src/virtManager/createinterface.py @@ -124,7 +124,6 @@ class vmmCreateInterface(gobject.GObject): def show(self): self.reset_state() - self.topwin.show() self.topwin.present() def show_bond_config(self, src): diff --git a/src/virtManager/createnet.py b/src/virtManager/createnet.py index 914a144d..d0173d46 100644 --- a/src/virtManager/createnet.py +++ b/src/virtManager/createnet.py @@ -82,7 +82,6 @@ class vmmCreateNetwork(gobject.GObject): self.set_initial_state() def show(self): - self.topwin.show() self.reset_state() self.topwin.present() diff --git a/src/virtManager/createpool.py b/src/virtManager/createpool.py index 1f6c20fb..10ba1c5a 100644 --- a/src/virtManager/createpool.py +++ b/src/virtManager/createpool.py @@ -115,7 +115,6 @@ class vmmCreatePool(gobject.GObject): self.set_initial_state() def show(self): - self.topwin.show() self.reset_state() self.topwin.present() diff --git a/src/virtManager/createvol.py b/src/virtManager/createvol.py index f21e3c13..7b9fbecf 100644 --- a/src/virtManager/createvol.py +++ b/src/virtManager/createvol.py @@ -89,7 +89,6 @@ class vmmCreateVolume(gobject.GObject): def show(self): self.reset_state() - self.topwin.show() self.topwin.present() def close(self, ignore1=None, ignore2=None): diff --git a/src/virtManager/delete.py b/src/virtManager/delete.py index c889c1e9..2caf536f 100644 --- a/src/virtManager/delete.py +++ b/src/virtManager/delete.py @@ -85,7 +85,6 @@ class vmmDeleteDialog(gobject.GObject): def show(self): self.reset_state() - self.topwin.show() self.topwin.present() def close(self, ignore1=None, ignore2=None): diff --git a/src/virtManager/details.py b/src/virtManager/details.py index 519c9325..4c9e89ec 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -302,7 +302,6 @@ class vmmDetails(gobject.GObject): if self.is_visible(): self.topwin.present() return - self.topwin.show() self.topwin.present() self.engine.increment_window_counter() diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py index 2ad154f6..de6f1b02 100644 --- a/src/virtManager/domain.py +++ b/src/virtManager/domain.py @@ -134,7 +134,7 @@ class vmmDomainBase(gobject.GObject): def set_autostart(self, val): raise NotImplementedError() - def attach_device(self, devobj): + def attach_device(self, devobj, devxml=None): raise NotImplementedError() def detach_device(self, devtype, dev_id_info): raise NotImplementedError() @@ -1314,13 +1314,17 @@ class vmmDomain(vmmDomainBase): def get_id(self): return self._backend.ID() - def attach_device(self, devobj): + def attach_device(self, devobj, devxml=None): """ Hotplug device to running guest """ - if self.is_active(): - xml = devobj.get_xml_config() - self._backend.attachDevice(xml) + if not self.is_active(): + return + + if not devxml: + devxml = devobj.get_xml_config() + + self._backend.attachDevice(devxml) def detach_device(self, devtype, dev_id_info): """ @@ -1591,7 +1595,7 @@ class vmmDomain(vmmDomainBase): ignore, diskxml = util.xml_parse_wrapper(self.get_xml(), func, dev_id_info, newpath, _type) - self.attach_device(diskxml) + self.attach_device(None, diskxml) # VCPU changing def define_vcpus(self, vcpus): diff --git a/src/virtManager/host.py b/src/virtManager/host.py index 33a3dc83..62c019db 100644 --- a/src/virtManager/host.py +++ b/src/virtManager/host.py @@ -294,8 +294,10 @@ class vmmHost(gobject.GObject): def show(self): - dialog = self.window.get_widget("vmm-host") - dialog.present() + if self.is_visible(): + self.topwin.present() + return + self.topwin.present() self.engine.increment_window_counter() diff --git a/src/virtManager/manager.py b/src/virtManager/manager.py index 3d3871fa..a05b1020 100644 --- a/src/virtManager/manager.py +++ b/src/virtManager/manager.py @@ -124,6 +124,8 @@ class vmmManager(gobject.GObject): 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, _("Unexpected Error"), _("An unexpected error occurred")) + self.topwin = self.window.get_widget("vmm-manager") + self.config = config self.engine = engine @@ -136,8 +138,7 @@ class vmmManager(gobject.GObject): self.rows = {} w, h = self.config.get_manager_window_size() - self.window.get_widget("vmm-manager").set_default_size(w or 550, - h or 550) + self.topwin.set_default_size(w or 550, h or 550) self.init_vmlist() self.init_stats() @@ -221,12 +222,11 @@ class vmmManager(gobject.GObject): ################## def show(self): - win = self.window.get_widget("vmm-manager") if self.is_visible(): - win.present() + self.topwin.present() return - win.show() - win.present() + self.topwin.present() + self.engine.increment_window_counter() if self.startup_error: diff --git a/src/virtManager/preferences.py b/src/virtManager/preferences.py index d13a9225..1a467c8c 100644 --- a/src/virtManager/preferences.py +++ b/src/virtManager/preferences.py @@ -37,7 +37,6 @@ class vmmPreferences(gobject.GObject): self.config = config self.topwin = self.window.get_widget("vmm-preferences") - self.topwin.hide() self.config.on_view_system_tray_changed(self.refresh_view_system_tray) self.config.on_console_popup_changed(self.refresh_console_popup) @@ -102,7 +101,6 @@ class vmmPreferences(gobject.GObject): return 1 def show(self): - self.topwin.show() self.topwin.present() ######################### diff --git a/src/virtManager/storagebrowse.py b/src/virtManager/storagebrowse.py index d4b2f02c..364f3a47 100644 --- a/src/virtManager/storagebrowse.py +++ b/src/virtManager/storagebrowse.py @@ -90,7 +90,6 @@ class vmmStorageBrowser(gobject.GObject): def show(self, conn=None): self.reset_state(conn) - self.topwin.show() self.topwin.present() def close(self, ignore1=None, ignore2=None):