connection: Clean up autoconnect get/set routines

No reason to cache the autoconnect value, use gconf as intended.
This commit is contained in:
Cole Robinson 2009-11-25 14:16:31 -05:00
parent 919e82b477
commit a21a91f6c9
3 changed files with 10 additions and 13 deletions

View File

@ -512,15 +512,16 @@ class vmmConfig:
gconf.VALUE_STRING)
return ((uris is not None) and (uri in uris))
def toggle_conn_autoconnect(self, uri):
def set_conn_autoconnect(self, uri, val):
uris = self.conf.get_list(self.conf_dir + "/connections/autoconnect",
gconf.VALUE_STRING)
if uris is None:
uris = []
if uri in uris:
if not val and uri in uris:
uris.remove(uri)
else:
elif val and uri not in uris:
uris.append(uri)
self.conf.set_list(self.conf_dir + "/connections/autoconnect",
gconf.VALUE_STRING, uris)

View File

@ -122,7 +122,6 @@ class vmmConnection(gobject.GObject):
# Resource utilization statistics
self.record = []
self.hostinfo = None
self.autoconnect = self.config.get_conn_autoconnect(self.get_uri())
if netdev_helper and not self.is_remote():
# Make sure we get net device add/remove signals
@ -502,11 +501,9 @@ class vmmConnection(gobject.GObject):
######################################
def get_autoconnect(self):
return self.autoconnect
def toggle_autoconnect(self):
self.config.toggle_conn_autoconnect(self.get_uri())
self.autoconnect = (not self.autoconnect)
return self.config.get_conn_autoconnect(self.get_uri())
def set_autoconnect(self, val):
self.config.set_conn_autoconnect(self.get_uri(), val)
def close(self):
if self.vmm == None:

View File

@ -246,6 +246,7 @@ class vmmHost(gobject.GObject):
def reset_state(self):
self.refresh_resources()
self.conn_state_changed()
# Update autostart value
auto = self.conn.get_autoconnect()
self.window.get_widget("config-autoconnect").set_active(auto)
@ -269,10 +270,8 @@ class vmmHost(gobject.GObject):
self.window.get_widget("net-add").set_sensitive(state)
self.window.get_widget("pool-add").set_sensitive(state)
def toggle_autoconnect(self, ignore=None):
if self.conn.get_autoconnect() != \
self.window.get_widget("config-autoconnect").get_active():
self.conn.toggle_autoconnect()
def toggle_autoconnect(self, src):
self.conn.set_autoconnect(src.get_active())
# -------------------------
# Virtual Network functions