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

View File

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