virtManager/ui: add opengl graphics option

Add an OpenGL checkbox to the Spice graphics options (only available if
SUPPORT_CONN_SPICE_GL).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2017-02-21 17:00:56 +04:00 committed by Cole Robinson
parent ecd66a7df2
commit 88942028b3
5 changed files with 52 additions and 6 deletions

View File

@ -363,5 +363,35 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Open_GL:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">graphics-opengl</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="graphics-opengl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_graphics_opengl_toggled" swapped="no"/>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
</packing>
</child>
</object>
</interface>

View File

@ -1555,7 +1555,7 @@ class vmmAddHardware(vmmGObjectUI):
def _validate_page_graphics(self):
try:
(gtype, port,
tlsport, addr, passwd, keymap) = self._gfxdetails.get_values()
tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
self._dev.type = gtype
@ -1563,6 +1563,7 @@ class vmmAddHardware(vmmGObjectUI):
self._dev.passwd = passwd
self._dev.listen = addr
self._dev.tlsPort = tlsport
self._dev.gl = gl
if keymap:
self._dev.keymap = keymap
except ValueError, e:

View File

@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
EDIT_GFX_ADDRESS,
EDIT_GFX_TLSPORT,
EDIT_GFX_PORT,
EDIT_GFX_OPENGL,
EDIT_VIDEO_MODEL,
@ -104,7 +105,7 @@ EDIT_FS,
EDIT_HOSTDEV_ROMBAR,
) = range(1, 45)
) = range(1, 46)
# Columns in hw list model
@ -394,6 +395,8 @@ class vmmDetails(vmmGObjectUI):
lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
self.gfxdetails.connect("changed-port",
lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
self.gfxdetails.connect("changed-opengl",
lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
self.gfxdetails.connect("changed-tlsport",
lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
self.gfxdetails.connect("changed-address",
@ -2158,7 +2161,7 @@ class vmmDetails(vmmGObjectUI):
def config_graphics_apply(self, devobj):
(gtype, port,
tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
kwargs = {}
@ -2170,6 +2173,8 @@ class vmmDetails(vmmGObjectUI):
kwargs["keymap"] = keymap
if self.edited(EDIT_GFX_PORT):
kwargs["port"] = port
if self.edited(EDIT_GFX_OPENGL):
kwargs["gl"] = gl
if self.edited(EDIT_GFX_TLSPORT):
kwargs["tlsport"] = tlsport
if self.edited(EDIT_GFX_TYPE):

View File

@ -825,7 +825,8 @@ class vmmDomain(vmmLibvirtObject):
def define_graphics(self, devobj, do_hotplug,
listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
gl=_SENTINEL):
xmlobj = self._make_xmlobj_to_define()
editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
if not editdev:
@ -843,6 +844,8 @@ class vmmDomain(vmmLibvirtObject):
editdev.keymap = keymap
if gtype != _SENTINEL:
editdev.type = gtype
if gl != _SENTINEL:
editdev.gl = gl
if do_hotplug:
self.hotplug(device=editdev)

View File

@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
"changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
"changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
"changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
"changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
}
def __init__(self, vm, builder, topwin):
@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
"on_graphics_tlsport_changed": lambda ignore: self.emit("changed-tlsport"),
"on_graphics_port_changed": lambda ignore: self.emit("changed-port"),
"on_graphics_keymap_changed": lambda ignore: self.emit("changed-keymap"),
"on_graphics_opengl_toggled": lambda ignore: self.emit("changed-opengl"),
})
self._init_ui()
@ -143,7 +145,9 @@ class vmmGraphicsDetails(vmmGObjectUI):
if not self.widget("graphics-password-chk").get_active():
passwd = None
return gtype, port, tlsport, addr, passwd, keymap
gl = self.widget("graphics-opengl").get_active()
return gtype, port, tlsport, addr, passwd, keymap, gl
def set_dev(self, gfx):
self.reset_state()
@ -188,6 +192,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
if is_spice:
set_port("graphics-tlsport", gfx.tlsPort)
self.widget("graphics-opengl").set_active(gfx.gl or False)
if is_sdl:
title = _("Local SDL Window")
@ -208,13 +213,15 @@ class vmmGraphicsDetails(vmmGObjectUI):
def _show_rows_from_type(self):
hide_all = ["graphics-xauth", "graphics-display", "graphics-address",
"graphics-password-box", "graphics-keymap", "graphics-port-box",
"graphics-tlsport-box"]
"graphics-tlsport-box", "graphics-opengl"]
gtype = uiutil.get_list_selection(self.widget("graphics-type"))
sdl_rows = ["graphics-xauth", "graphics-display"]
vnc_rows = ["graphics-password-box", "graphics-address",
"graphics-port-box", "graphics-keymap"]
spice_rows = vnc_rows[:] + ["graphics-tlsport-box"]
if self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_GL):
spice_rows.extend(["graphics-opengl"])
rows = []
if gtype == "sdl":