mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-13 13:17:57 +03:00
connect: If readding an existing connection, update 'autoconnect'
This commit is contained in:
parent
fa8460ff65
commit
595d3d13e7
@ -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", [])
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user