From 92c42bc5a08a77712774876905f0e6590ebd5e9b Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 9 Apr 2015 13:36:40 -0400 Subject: [PATCH] details: Improve UI labeling of keyboard devices --- tests/testdriver.xml | 1 + ui/details.ui | 2 +- virtManager/addhardware.py | 19 ++++++++++++++++--- virtManager/details.py | 16 +++------------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/testdriver.xml b/tests/testdriver.xml index 57bcaf77..fd963abb 100644 --- a/tests/testdriver.xml +++ b/tests/testdriver.xml @@ -292,6 +292,7 @@ + diff --git a/ui/details.ui b/ui/details.ui index 199dc0bf..a16b0edc 100644 --- a/ui/details.ui +++ b/ui/details.ui @@ -4532,7 +4532,7 @@ if you know what you are doing.</small> True False - <b>Virtual Pointer</b> + <b>Virtual Input Device</b> True diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index f808a005..f3ffdd6f 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -801,6 +801,16 @@ class vmmAddHardware(vmmGObjectUI): model.append([None, _("Hypervisor default")]) uiutil.set_grid_row_visible(combo, False) + @staticmethod + def label_for_input_device(typ, bus): + if typ == "tablet" and bus == "usb": + return _("EvTouch USB Graphics Tablet") + + if bus in ["usb", "ps2"]: + return _("Generic") + (" %s %s" % + (bus.upper(), str(typ).capitalize())) + return "%s %s" % (str(bus).capitalize(), str(typ).capitalize()) + ######################### # UI population methods # @@ -825,9 +835,12 @@ class vmmAddHardware(vmmGObjectUI): def populate_input_model(self, model): model.clear() - model.append([_("EvTouch USB Graphics Tablet"), "tablet", "usb"]) - model.append([_("Generic USB Mouse"), "mouse", "usb"]) - model.append([_("Generic USB Keyboard"), "keyboard", "usb"]) + def _add_row(typ, bus): + model.append([self.label_for_input_device(typ, bus), typ, bus]) + + _add_row("tablet", "usb") + _add_row("mouse", "usb") + _add_row("keyboard", "usb") def populate_host_device_model(self, devtype, devcap, subtype, subcap): devlist = self.widget("host-device") diff --git a/virtManager/details.py b/virtManager/details.py index ddaf886d..b6c26d72 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -265,6 +265,8 @@ def _icon_for_device(dev): return "drive-harddisk" if devtype == "input": + if dev.type == "keyboard": + return "input-keyboard" if dev.type == "tablet": return "input-tablet" return "input-mouse" @@ -2785,19 +2787,7 @@ class vmmDetails(vmmGObjectUI): if not inp: return - ident = "%s:%s" % (inp.type, inp.bus) - if ident == "tablet:usb": - dev = _("EvTouch USB Graphics Tablet") - elif ident == "mouse:usb": - dev = _("Generic USB Mouse") - elif ident == "mouse:xen": - dev = _("Xen Mouse") - elif ident == "mouse:ps2": - dev = _("PS/2 Mouse") - elif ident == "keyboard:ps2": - dev = _("PS/2 Keyboard") - else: - dev = inp.bus + " " + inp.type + dev = vmmAddHardware.label_for_input_device(inp.type, inp.bus) mode = None if inp.type == "tablet":