mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-10 01:18:03 +03:00
console: Simplify usbredir menu handling
+ Don't check for redirdev devices, let the spice widget tell us if things aren't configured correctly. + Remove some duplication Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
4cc52de8bb
commit
371cd1ad60
@ -702,8 +702,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
|
||||
def _viewer_can_usb_redirect(self):
|
||||
return (self._viewer_is_visible() and
|
||||
self._viewer.console_has_usb_redirection() and
|
||||
self.vm.has_spicevmc_type_redirdev())
|
||||
self._viewer.console_has_usb_redirection())
|
||||
|
||||
|
||||
#########################
|
||||
@ -989,9 +988,8 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
# API used by vmmVMWindow #
|
||||
###########################
|
||||
|
||||
def vmwindow_viewer_has_usb_redirection(self):
|
||||
return bool(self._viewer and
|
||||
self._viewer.console_has_usb_redirection())
|
||||
def vmwindow_viewer_can_usb_redirect(self):
|
||||
return self._viewer_can_usb_redirect()
|
||||
def vmwindow_viewer_get_usb_widget(self):
|
||||
return self._viewer.console_get_usb_widget()
|
||||
def vmwindow_viewer_get_pixbuf(self):
|
||||
@ -1021,8 +1019,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
return self._consolemenu.get_menu()
|
||||
def vmwindow_get_viewer_is_visible(self):
|
||||
return self._viewer_is_visible()
|
||||
def vmwindow_get_can_usb_redirect(self):
|
||||
return self._viewer_can_usb_redirect()
|
||||
def vmwindow_get_resizeguest_tooltip(self):
|
||||
return self._viewer_get_resizeguest_tooltip()
|
||||
|
||||
|
@ -789,8 +789,4 @@ class SpiceViewer(Viewer):
|
||||
def _has_usb_redirection(self):
|
||||
if not self._spice_session or not self._usbdev_manager:
|
||||
return False # pragma: no cover
|
||||
|
||||
for c in self._spice_session.get_channels():
|
||||
if c.__class__ is SpiceClientGLib.UsbredirChannel:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
@ -425,13 +425,6 @@ class vmmDomain(vmmLibvirtObject):
|
||||
def get_install_abort(self):
|
||||
return bool(self._install_abort)
|
||||
|
||||
def has_spicevmc_type_redirdev(self):
|
||||
devs = self.xmlobj.devices.redirdev
|
||||
for dev in devs:
|
||||
if dev.type == "spicevmc":
|
||||
return True
|
||||
return False
|
||||
|
||||
def has_nvram(self):
|
||||
return bool(self.get_xmlobj().is_uefi() or
|
||||
self.get_xmlobj().os.nvram)
|
||||
|
@ -114,7 +114,7 @@ class vmmVMWindow(vmmGObjectUI):
|
||||
"on_details_customize_finish_clicked": self.customize_finish,
|
||||
"on_details_cancel_customize_clicked": self._customize_cancel_clicked,
|
||||
|
||||
"on_details_menu_virtual_manager_activate": self.control_vm_menu,
|
||||
"on_details_menu_virtual_manager_activate": self._on_menu_virtual_machine_activate_cb,
|
||||
"on_details_menu_screenshot_activate": self.control_vm_screenshot,
|
||||
"on_details_menu_usb_redirection": self.control_vm_usb_redirection,
|
||||
"on_details_menu_view_toolbar_activate": self.toggle_toolbar,
|
||||
@ -490,10 +490,8 @@ class vmmVMWindow(vmmGObjectUI):
|
||||
else:
|
||||
vmmenu.VMActionUI.resume(self, self.vm)
|
||||
|
||||
def control_vm_menu(self, src_ignore):
|
||||
can_usb = bool(self.vm.has_spicevmc_type_redirdev() and
|
||||
self._console.vmwindow_viewer_has_usb_redirection())
|
||||
self.widget("details-menu-usb-redirection").set_sensitive(can_usb)
|
||||
def _on_menu_virtual_machine_activate_cb(self, src):
|
||||
self._console_refresh_can_usbredir()
|
||||
|
||||
def control_vm_run(self, src_ignore):
|
||||
if self._details.vmwindow_has_unapplied_changes():
|
||||
@ -609,19 +607,23 @@ class vmmVMWindow(vmmGObjectUI):
|
||||
|
||||
paused = self.vm.is_paused()
|
||||
is_viewer = self._console.vmwindow_get_viewer_is_visible()
|
||||
can_usb = self._console.vmwindow_get_can_usb_redirect()
|
||||
|
||||
self.widget("details-menu-vm-screenshot").set_sensitive(is_viewer)
|
||||
self.widget("details-menu-usb-redirection").set_sensitive(can_usb)
|
||||
keycombo_menu = self._console.vmwindow_get_keycombo_menu()
|
||||
|
||||
can_sendkey = (is_viewer and not paused)
|
||||
for c in keycombo_menu.get_children():
|
||||
c.set_sensitive(can_sendkey)
|
||||
|
||||
self._console_refresh_can_usbredir()
|
||||
self._console_refresh_can_fullscreen()
|
||||
self._console_refresh_resizeguest_from_settings()
|
||||
|
||||
def _console_refresh_can_usbredir(self):
|
||||
can_usb = self._console.vmwindow_viewer_can_usb_redirect()
|
||||
self.widget("details-menu-usb-redirection").set_sensitive(
|
||||
bool(can_usb))
|
||||
|
||||
def _console_refresh_can_fullscreen(self):
|
||||
allow_fullscreen = self._console.vmwindow_get_viewer_is_visible()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user