Source code for fortrace.utility.desktop_environments.desktop_environment_factory

from fortrace.core.qemu_monitor import QEMUMonitorSession
from fortrace.utility.desktop_environments.desktop_environment import (
    DesktopEnvironment,
    DesktopEnvironmentType,
)
from fortrace.utility.desktop_environments.Linux.gnome import GNOME
from fortrace.utility.desktop_environments.Linux.kde_plasma import Plasma
from fortrace.utility.desktop_environments.Windows.Windows_10 import Windows10
from fortrace.utility.desktop_environments.Windows.Windows_11 import Windows11
from fortrace.utility.distribution_constants import OSType


[docs] def get_desktop_env( os_type: OSType, desktop_env: DesktopEnvironmentType, qemu_monitor_session: QEMUMonitorSession, ) -> DesktopEnvironment: """Construct a new desktop environment object. This is the entry point for any GUI interaction. Args: os_type: OSType of the guest desktop_env: desktop environment of the guest qemu_monitor_session: and active QEMUMonitorSession Returns: desktop environment object """ if os_type == OSType.LINUX: match desktop_env: case DesktopEnvironmentType.GNOME: return GNOME(qemu_monitor_session) case DesktopEnvironmentType.KDE_Plasma: return Plasma(qemu_monitor_session) case _: raise ValueError( f"{desktop_env} is not supported/not implemented on Linux" ) elif os_type == OSType.WINDOWS: match desktop_env: case DesktopEnvironmentType.Windows_10: return Windows10(qemu_monitor_session) case DesktopEnvironmentType.Windows_11: return Windows11(qemu_monitor_session) case _: raise ValueError( f"{desktop_env} is not supported/not implemented on Windows" ) elif os_type == OSType.MACOS: raise NotImplementedError else: raise ValueError(f"Provided unsupported OS type: {os_type}")