fix problem with never ending gtk.main()

This commit is contained in:
Karel Zak 2006-11-03 10:02:02 -05:00
parent 05764da2c6
commit ddadec4a7e
7 changed files with 41 additions and 0 deletions

View File

@ -15,6 +15,7 @@ done by:
Further patches have been submitted by:
William Sheehan <william-dot-sheehan-at-openinterface-dot-com>
Karel Zak <kzak-at-redhat-dot-com>
<...send a patch & get your name here...>

View File

@ -136,6 +136,11 @@ class vmmConsole(gobject.GObject):
logging.error("Failure when disconnecting from VNC server")
return 1
def is_visible(self):
if self.window.get_widget("vmm-console").flags() & gtk.VISIBLE:
return 1
return 0
def control_vm_run(self, src):
return 0

View File

@ -309,6 +309,11 @@ class vmmCreate(gobject.GObject):
self.topwin.hide()
return 1
def is_visible(self):
if self.topwin.flags() & gtk.VISIBLE:
return 1
return 0
def finish(self, ignore=None):
# first things first, are we trying to create a fully virt guest?
if self.get_config_method() == VM_FULLY_VIRT:

View File

@ -148,6 +148,11 @@ class vmmDetails(gobject.GObject):
self.window.get_widget("vmm-details").hide()
return 1
def is_visible(self):
if self.window.get_widget("vmm-details").flags() & gtk.VISIBLE:
return 1
return 0
def hw_selected(self, src=None):
vmlist = self.window.get_widget("hw-list")
selection = vmlist.get_selection()

View File

@ -116,6 +116,9 @@ class vmmEngine:
self.timer = gobject.timeout_add(interval, self.tick)
def tick(self):
if self.windowConnect == None and gtk.main_level() > 0 and self.count_visible_windows() == 0:
gtk.main_quit()
for uri in self.connections.keys():
try:
self.connections[uri]["connection"].tick()
@ -125,6 +128,18 @@ class vmmEngine:
logging.error(("Could not refresh connection %s" % (uri)) + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
return 1
def count_visible_windows(self):
ct = 0
for conn in self.connections.values():
for name in [ "windowDetails", "windowConsole", "windowSerialConsole" ]:
for window in conn[name].values():
ct += window.is_visible()
if conn["windowManager"]:
ct += conn["windowManager"].is_visible()
if self.windowCreate:
ct += self.windowCreate.is_visible()
return ct
def change_timer_interval(self,ignore1,ignore2,ignore3,ignore4):
gobject.source_remove(self.timer)
self.schedule_timer()

View File

@ -153,6 +153,11 @@ class vmmManager(gobject.GObject):
win.hide()
return 1
def is_visible(self):
if self.window.get_widget("vmm-manager").flags() & gtk.VISIBLE:
return 1
return 0
def exit_app(self, src=None, src2=None):
gtk.main_quit()

View File

@ -71,6 +71,11 @@ class vmmSerialConsole:
self.window.hide()
return True
def is_visible(self):
if self.window.flags() & gtk.VISIBLE:
return 1
return 0
def opentty(self):
if self.ptyio != None:
self.closetty()