netlist: Listen for net-added events and update the list

This commit is contained in:
Cole Robinson 2014-01-28 14:40:17 -05:00
parent 8bb9853ec8
commit 1597677e61
1 changed files with 23 additions and 0 deletions

View File

@ -58,6 +58,11 @@ class vmmNetworkList(vmmGObjectUI):
self.top_vport = self.widget("vport-expander")
def _cleanup(self):
try:
self.conn.disconnect_by_func(self._repopulate_network_list)
except:
pass
self.conn = None
@ -90,6 +95,11 @@ class vmmNetworkList(vmmGObjectUI):
combo.set_active(0)
self.conn.connect("net-added", self._repopulate_network_list)
self.conn.connect("net-removed", self._repopulate_network_list)
self.conn.connect("interface-added", self._repopulate_network_list)
self.conn.connect("interface-removed", self._repopulate_network_list)
def _pretty_network_desc(self, nettype, source=None, netobj=None):
if nettype == virtinst.VirtualNetworkInterface.TYPE_USER:
return _("Usermode networking")
@ -445,6 +455,19 @@ class vmmNetworkList(vmmGObjectUI):
ignore = kwargs
self.emit("changed-vport")
def _repopulate_network_list(self, *args, **kwargs):
ignore = args
ignore = kwargs
netlist = self.widget("net-source")
label = uiutil.get_list_selection(netlist, 2)
self._populate_network_list()
for row in netlist.get_model():
if label and row[2] == label:
netlist.set_active_iter(row.iter)
return
def _on_net_source_changed(self, src):
self._emit_changed()