connect: If readding an existing connection, update 'autoconnect'

This commit is contained in:
Cole Robinson 2011-07-14 20:52:40 -04:00
parent fa8460ff65
commit 595d3d13e7
2 changed files with 13 additions and 15 deletions

View File

@ -335,16 +335,14 @@ class vmmConnect(vmmGObjectUI):
if not self.validate():
return
readonly = False
auto = False
if self.widget("autoconnect").get_property("sensitive"):
auto = self.widget("autoconnect").get_active()
uri = self.generate_uri()
logging.debug("Generate URI=%s, auto=%s, readonly=%s" %
(uri, auto, readonly))
logging.debug("Generate URI=%s, auto=%s" % (uri, auto))
self.close()
self.emit("completed", uri, readonly, auto)
self.emit("completed", uri, auto)
def sanitize_hostname(self, host):
if host == "linux" or host == "localhost":
@ -400,5 +398,5 @@ class vmmConnect(vmmGObjectUI):
vmmGObjectUI.type_register(vmmConnect)
vmmConnect.signal_new(vmmConnect, "completed", [str, object, object])
vmmConnect.signal_new(vmmConnect, "completed", [str, str])
vmmConnect.signal_new(vmmConnect, "cancelled", [])

View File

@ -345,13 +345,15 @@ class vmmEngine(vmmGObject):
if conn.get_autoconnect():
self.connect_to_uri(uri)
def connect_to_uri(self, uri, readOnly=None, autoconnect=False,
do_start=True):
def connect_to_uri(self, uri, autoconnect=None, do_start=True):
try:
conn = self._check_connection(uri)
if not conn:
# Unknown connection, add it
conn = self.add_connection(uri, readOnly, autoconnect)
conn = self.add_connection(uri)
if autoconnect is not None:
conn.set_autoconnect(bool(autoconnect))
self.show_manager()
if do_start:
@ -529,12 +531,12 @@ class vmmEngine(vmmGObject):
logging.debug("Exiting app normally.")
gtk.main_quit()
def add_connection(self, uri, readOnly=None, autoconnect=False):
def add_connection(self, uri):
conn = self._check_connection(uri)
if conn:
return conn
conn = vmmConnection(uri, readOnly=readOnly)
conn = vmmConnection(uri)
self.connections[uri] = {
"connection": conn,
"windowHost": None,
@ -548,9 +550,6 @@ class vmmEngine(vmmGObject):
self.emit("connection-added", conn)
self.config.add_connection(conn.get_uri())
if autoconnect:
conn.set_autoconnect(True)
return conn
def cleanup_connection(self, uri):
@ -663,8 +662,9 @@ class vmmEngine(vmmGObject):
if self.windowConnect:
return self.windowConnect
def connect_wrap(src_ignore, *args):
return self.connect_to_uri(*args)
def connect_wrap(src, uri, autoconnect):
ignore = src
return self.connect_to_uri(uri, autoconnect)
obj = vmmConnect()
obj.connect("completed", connect_wrap)