mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
devices: input: Add set_defaults
This commit is contained in:
parent
698c72e60d
commit
31d74ff0eb
@ -15,15 +15,11 @@ class DeviceInput(Device):
|
||||
TYPE_MOUSE = "mouse"
|
||||
TYPE_TABLET = "tablet"
|
||||
TYPE_KEYBOARD = "keyboard"
|
||||
TYPE_DEFAULT = "default"
|
||||
TYPES = [TYPE_MOUSE, TYPE_TABLET, TYPE_KEYBOARD, TYPE_DEFAULT]
|
||||
|
||||
BUS_PS2 = "ps2"
|
||||
BUS_USB = "usb"
|
||||
BUS_VIRTIO = "virtio"
|
||||
BUS_XEN = "xen"
|
||||
BUS_DEFAULT = "default"
|
||||
BUSES = [BUS_PS2, BUS_USB, BUS_XEN, BUS_DEFAULT]
|
||||
|
||||
@staticmethod
|
||||
def pretty_name(typ, bus):
|
||||
@ -36,16 +32,23 @@ class DeviceInput(Device):
|
||||
return "%s %s" % (str(bus).capitalize(), str(typ).capitalize())
|
||||
|
||||
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=lambda s: s.TYPE_MOUSE,
|
||||
default_name=TYPE_DEFAULT)
|
||||
type = XMLProperty("./@type")
|
||||
bus = XMLProperty("./@bus")
|
||||
|
||||
def _default_bus(self):
|
||||
|
||||
##################
|
||||
# Default config #
|
||||
##################
|
||||
|
||||
def _default_bus(self, _guest):
|
||||
if self.type == self.TYPE_TABLET:
|
||||
return self.BUS_USB
|
||||
if self.conn.is_xen():
|
||||
return self.BUS_XEN
|
||||
return self.BUS_PS2
|
||||
bus = XMLProperty("./@bus",
|
||||
default_cb=_default_bus,
|
||||
default_name=BUS_DEFAULT)
|
||||
|
||||
def set_defaults(self, guest):
|
||||
if not self.type:
|
||||
self.type = self.TYPE_MOUSE
|
||||
if not self.bus:
|
||||
self.bus = self._default_bus(guest)
|
||||
|
Loading…
Reference in New Issue
Block a user