details: Fix unsetting autoport values

This commit is contained in:
Cole Robinson 2014-03-22 18:25:53 -04:00
parent 565ef4f3ef
commit b49f647e0c
3 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<input type="mouse" bus="ps2"/>
<input type="keyboard" bus="ps2"/>
- <graphics type="vnc" port="-1" autoport="yes"/>
+ <graphics type="vnc" port="-1" autoport="yes" tlsPort="5902" keymap="ja"/>
+ <graphics type="vnc" port="-1" tlsPort="5902" keymap="ja"/>
<graphics type="vnc" port="-1" autoport="yes"/>
<graphics type="vnc" port="-1" autoport="yes" listen="1.2.3.4" keymap="fi">
<listen type="address" address="1.2.3.4"/>

View File

@ -153,6 +153,8 @@ class vmmGraphicsDetails(vmmGObjectUI):
def set_port(basename, val):
auto = self.widget(basename + "-auto")
widget = self.widget(basename)
auto.set_inconsistent(False)
if val == -1 or gfx.autoport:
auto.set_active(True)
elif val is None:
@ -227,10 +229,12 @@ class vmmGraphicsDetails(vmmGObjectUI):
self.emit("changed-type")
def _change_port_auto(self, ignore):
self.widget("graphics-port-auto").set_inconsistent(False)
self._change_ports()
self.emit("changed-port")
def _change_tlsport_auto(self, ignore):
self.widget("graphics-tlsport-auto").set_inconsistent(False)
self._change_ports()
self.emit("changed-tlsport")

View File

@ -136,6 +136,14 @@ class VirtualGraphics(VirtualDevice):
default_cb=_default_keymap,
set_converter=_set_keymap_converter)
def _set_port_converter(self, val):
val = _validate_port("Port", val)
self.autoport = self._get_default_autoport()
return val
def _set_tlsport_converter(self, val):
val = _validate_port("TLS Port", val)
self.autoport = self._get_default_autoport()
return val
def _get_default_port(self):
if self.type == "vnc" or self.type == "spice":
return -1
@ -153,10 +161,10 @@ class VirtualGraphics(VirtualDevice):
return True
return None
port = XMLProperty("./@port", is_int=True,
set_converter=lambda s, v: _validate_port("Port", v),
set_converter=_set_port_converter,
default_cb=_get_default_port)
tlsPort = XMLProperty("./@tlsPort", is_int=True,
set_converter=lambda s, v: _validate_port("TLS port", v),
set_converter=_set_tlsport_converter,
default_cb=_get_default_tlsport)
autoport = XMLProperty("./@autoport", is_yesno=True,
default_cb=_get_default_autoport)