diff --git a/bottles/backend/health.py b/bottles/backend/health.py index 3756b3e59f..1ef0111818 100644 --- a/bottles/backend/health.py +++ b/bottles/backend/health.py @@ -69,16 +69,27 @@ def __init__(self): } self.get_ram_data() - self.cabextract = self.check_cabextract() - self.p7zip = self.check_p7zip() - self.patool = self.check_patool() - self.icoextract = self.check_icoextract() - self.pefile = self.check_pefile() - self.orjson = self.check_orjson() - self.markdown = self.check_markdown() - self.xdpyinfo = self.check_xdpyinfo() - self.ImageMagick = self.check_ImageMagick() - self.FVS = self.check_FVS() + if "FLATPAK_ID" not in os.environ: + self.cabextract = self.check_cabextract() + self.p7zip = self.check_p7zip() + self.patool = self.check_patool() + self.icoextract = self.check_icoextract() + self.pefile = self.check_pefile() + self.orjson = self.check_orjson() + self.markdown = self.check_markdown() + self.xdpyinfo = self.check_xdpyinfo() + self.ImageMagick = self.check_ImageMagick() + self.FVS = self.check_FVS() + else: + self.cabextract = True + self.p7zip = True + self.patool = True + self.icoextract = True + self.pefile = True + self.orjson = True + self.markdown = True + self.ImageMagick = True + self.FVS = True @staticmethod def check_gpus(): @@ -93,68 +104,92 @@ def check_x11(self): @staticmethod def check_wayland(): - return "WAYLAND_DISPLAY" in os.environ + if "WAYLAND_DISPLAY" in os.environ: + return True + return False def check_xwayland(self): - return self.x11 and self.wayland + if self.x11 and self.wayland: + return True + return False def check_desktop(self): - return os.environ.get("XDG_CURRENT_DESKTOP") - - @staticmethod - # TODO: additional cleanup: don't have individual `check_*` methods, just one like this, - # and iterate over them for the results. - def check_executable(executable): - return bool(shutil.which(executable)) + return os.environ.get("DESKTOP_SESSION") @staticmethod def check_cabextract(): - return check_executable("cabextract") + res = shutil.which("cabextract") + if res is None: + return False + return True @staticmethod def check_p7zip(): - return check_executable("7z") + res = shutil.which("7z") + if res is None: + return False + return True @staticmethod def check_patool(): - return check_executable("patool") - - @staticmethod - def check_xdpyinfo(): - return check_executable("xdpyinfo") + res = shutil.which("patool") + if res is None: + return False + return True @staticmethod - def check_ImageMagick(): - return check_executable("identify") + def check_icoextract(): + try: + import icoextract + return True + except ModuleNotFoundError: + return False @staticmethod - def check_module(module): + def check_pefile(): try: - __import__(module) + import pefile + return True except ModuleNotFoundError: return False - else: - return True @staticmethod - def check_icoextract(): - return check_module("icoextract") + def check_markdown(): + try: + import markdown + return True + except ModuleNotFoundError: + return False @staticmethod - def check_pefile(): - return check_module("pefile") + def check_orjson(): + try: + import orjson + return True + except ModuleNotFoundError: + return False @staticmethod - def check_markdown(): - return check_module("markdown") + def check_xdpyinfo(): + res = shutil.which("xdpyinfo") + if res is None: + return False + return True @staticmethod - def check_orjson(): - return check_module("orjson") + def check_ImageMagick(): + res = shutil.which("identify") + if res is None: + return False + return True @staticmethod def check_FVS(): - return check_module("fvs") + try: + from fvs.repo import FVSRepo + return True + except ModuleNotFoundError: + return False @staticmethod def get_bottles_envs(): diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index 66241e71cf..7f5e9cb96f 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -143,30 +143,30 @@ def __init__(self, details, config, **kwargs): self.btn_manage_vmtouch.connect("clicked", self.__show_vmtouch_settings) self.btn_cwd.connect("clicked", self.choose_cwd) self.btn_cwd_reset.connect("clicked", self.reset_cwd, True) - self.switch_mangohud.connect("state-set", self.__toggle_mangohud) - self.switch_obsvkc.connect("state-set", self.__toggle_obsvkc) - self.switch_vkbasalt.connect("state-set", self.__toggle_vkbasalt) - self.switch_fsr.connect("state-set", self.__toggle_fsr) - self.switch_nvapi.connect("state-set", self.__toggle_nvapi) - # self.switch_latencyflex.connect("state-set", self.__toggle_latencyflex) - self.switch_gamemode.connect("state-set", self.__toggle_gamemode) - self.switch_gamescope.connect("state-set", self.__toggle_gamescope) - self.switch_sandbox.connect("state-set", self.__toggle_sandbox) - self.switch_discrete.connect("state-set", self.__toggle_discrete_gpu) - self.switch_versioning_compression.connect("state-set", self.__toggle_versioning_compression) - self.switch_auto_versioning.connect("state-set", self.__toggle_auto_versioning) - self.switch_versioning_patterns.connect("state-set", self.__toggle_versioning_patterns) - self.switch_vmtouch.connect("state-set", self.__toggle_vmtouch) - self.combo_runner.connect("notify::selected", self.__set_runner) - self.combo_dxvk.connect("notify::selected", self.__set_dxvk) - self.combo_vkd3d.connect("notify::selected", self.__set_vkd3d) - self.combo_nvapi.connect("notify::selected", self.__set_nvapi) - self.combo_latencyflex.connect("notify::selected", self.__set_latencyflex) - self.combo_windows.connect("notify::selected", self.__set_windows) + self.switch_mangohud.connect('state-set', self.__toggle_mangohud) + self.switch_obsvkc.connect('state-set', self.__toggle_obsvkc) + self.switch_vkbasalt.connect('state-set', self.__toggle_vkbasalt) + self.switch_fsr.connect('state-set', self.__toggle_fsr) + self.switch_nvapi.connect('state-set', self.__toggle_nvapi) + # self.switch_latencyflex.connect('state-set', self.__toggle_latencyflex) + self.switch_gamemode.connect('state-set', self.__toggle_gamemode) + self.switch_gamescope.connect('state-set', self.__toggle_gamescope) + self.switch_sandbox.connect('state-set', self.__toggle_sandbox) + self.switch_discrete.connect('state-set', self.__toggle_discrete_gpu) + self.switch_versioning_compression.connect('state-set', self.__toggle_versioning_compression) + self.switch_auto_versioning.connect('state-set', self.__toggle_auto_versioning) + self.switch_versioning_patterns.connect('state-set', self.__toggle_versioning_patterns) + self.switch_vmtouch.connect('state-set', self.__toggle_vmtouch) + self.combo_runner.connect('notify::selected', self.__set_runner) + self.combo_dxvk.connect('notify::selected', self.__set_dxvk) + self.combo_vkd3d.connect('notify::selected', self.__set_vkd3d) + self.combo_nvapi.connect('notify::selected', self.__set_nvapi) + self.combo_latencyflex.connect('notify::selected', self.__set_latencyflex) + self.combo_windows.connect('notify::selected', self.__set_windows) self.combo_language.connect('notify::selected-item', self.__set_language) - self.combo_sync.connect("notify::selected", self.__set_sync_type) - self.entry_name.connect("changed", self.__check_entry_name) - self.entry_name.connect("apply", self.__save_name) + self.combo_sync.connect('notify::selected', self.__set_sync_type) + self.entry_name.connect('changed', self.__check_entry_name) + self.entry_name.connect('apply', self.__save_name) # endregion """Set DXVK_NVAPI related rows to visible when an NVIDIA GPU is detected (invisible by default)""" @@ -177,11 +177,11 @@ def __init__(self, details, config, **kwargs): """Set Bottles Runtime row to visible when Bottles is not running inside Flatpak""" if "FLATPAK_ID" not in os.environ and RuntimeManager.get_runtimes("bottles"): self.row_runtime.set_visible(True) - self.switch_runtime.connect("state-set", self.__toggle_runtime) + self.switch_runtime.connect('state-set', self.__toggle_runtime) if RuntimeManager.get_runtimes("steam"): self.row_steam_runtime.set_visible(True) - self.switch_steam_runtime.connect("state-set", self.__toggle_steam_runtime) + self.switch_steam_runtime.connect('state-set', self.__toggle_steam_runtime) '''Toggle some utilities according to its availability''' self.switch_gamemode.set_sensitive(gamemode_available) @@ -338,16 +338,26 @@ def update_combo_components(self): ]: string_list.splice(0, string_list.get_n_items()) - self.str_list_dxvk.append(_("Disabled")) - self.str_list_vkd3d.append(_("Disabled")) - self.str_list_latencyflex.append(_("Disabled")) + self.str_list_dxvk.append("Disabled") + self.str_list_vkd3d.append("Disabled") + self.str_list_latencyflex.append("Disabled") + for index, dxvk in enumerate(self.manager.dxvk_available): + self.str_list_dxvk.append(dxvk) - self.str_list_dxvk.splice(self.str_list_dxvk.get_n_items(), 0, self.manager.dxvk_available) - self.str_list_vkd3d.splice(self.str_list_vkd3d.get_n_items(), 0, self.manager.vkd3d_available) - self.str_list_runner.splice(self.str_list_runner.get_n_items(), 0, self.manager.runners_available) - self.str_list_nvapi.splice(self.str_list_nvapi.get_n_items(), 0, self.manager.nvapi_available) - self.str_list_latencyflex.splice(self.str_list_latencyflex.get_n_items(), 0, self.manager.latencyflex_available) - self.str_list_languages.splice(self.str_list_languages.get_n_items(), 0, ManagerUtils.get_languages()) + for index, vkd3d in enumerate(self.manager.vkd3d_available): + self.str_list_vkd3d.append(vkd3d) + + for index, runner in enumerate(self.manager.runners_available): + self.str_list_runner.append(runner) + + for index, nvapi in enumerate(self.manager.nvapi_available): + self.str_list_nvapi.append(nvapi) + + for index, latencyflex in enumerate(self.manager.latencyflex_available): + self.str_list_latencyflex.append(latencyflex) + + for lang in ManagerUtils.get_languages(): + self.str_list_languages.append(lang) self.combo_runner.handler_unblock_by_func(self.__set_runner) self.combo_dxvk.handler_unblock_by_func(self.__set_dxvk) @@ -435,8 +445,10 @@ def set_config(self, config: BottleConfig): self.windows_versions["win98"] = "Windows 98" self.windows_versions["win95"] = "Windows 95" - self.str_list_windows.splice(self.str_list_windows.get_n_items(), 0, list(self.windows_versions.values())) - self.combo_windows.set_selected(list(self.windows_versions).index(self.config.get("Windows"))) + for index, windows_version in enumerate(self.windows_versions): + self.str_list_windows.append(self.windows_versions[windows_version]) + if windows_version == self.config.Windows: + self.combo_windows.set_selected(index) # endregion parameters = self.config.Parameters @@ -512,7 +524,7 @@ def set_config(self, config: BottleConfig): def __show_gamescope_settings(self, widget): new_window = GamescopeDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() @@ -544,21 +556,21 @@ def __show_display_settings(self, widget): def __show_exclusionpatterns_settings(self, widget): new_window = ExclusionPatternsDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() def __show_sandbox_settings(self, widget): new_window = SandboxDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() def __show_drives(self, widget): new_window = DrivesDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() @@ -566,14 +578,14 @@ def __show_drives(self, widget): def __show_environment_variables(self, widget=False): """Show the environment variables dialog""" new_window = EnvVarsDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() def __show_vmtouch_settings(self, widget): new_window = VmtouchDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() @@ -1039,7 +1051,7 @@ def __set_language(self, *_args): def __show_dll_overrides_view(self, widget=False): """Show the DLL overrides view""" new_window = DLLOverridesDialog( - parent_window=self.window, + window=self.window, config=self.config ) new_window.present() diff --git a/bottles/frontend/windows/dlloverrides.py b/bottles/frontend/windows/dlloverrides.py index 28003bf6e9..3db97747e3 100644 --- a/bottles/frontend/windows/dlloverrides.py +++ b/bottles/frontend/windows/dlloverrides.py @@ -27,12 +27,12 @@ class DLLEntry(Adw.ComboRow): # endregion - def __init__(self, parent_window, config, override, **kwargs): + def __init__(self, window, config, override, **kwargs): super().__init__(**kwargs) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config self.override = override types = ("b", "n", "b,n", "n,b", "d") @@ -87,13 +87,13 @@ class DLLOverridesDialog(Adw.PreferencesWindow): # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config self.__populate_overrides_list() @@ -117,7 +117,7 @@ def __save_override(self, *_args): scope="DLL_Overrides" ) _entry = DLLEntry( - parent_window=self.parent_window, + window=self.window, config=self.config, override=[dll_name, "n,b"] ) @@ -139,7 +139,7 @@ def __populate_overrides_list(self): self.group_overrides.set_description("") for override in overrides: _entry = DLLEntry( - parent_window=self.parent_window, + window=self.window, config=self.config, override=override ) diff --git a/bottles/frontend/windows/drives.py b/bottles/frontend/windows/drives.py index 37971e56d8..7482543545 100644 --- a/bottles/frontend/windows/drives.py +++ b/bottles/frontend/windows/drives.py @@ -18,7 +18,6 @@ from gi.repository import Gtk, GLib, Adw from bottles.backend.wine.drives import Drives -from string import ascii_uppercase @Gtk.Template(resource_path='/com/usebottles/bottles/drive-entry.ui') @@ -91,7 +90,10 @@ def __remove(self, *_args): @Gtk.Template(resource_path='/com/usebottles/bottles/dialog-drives.ui') class DrivesDialog(Adw.Window): __gtype_name__ = 'DrivesDialog' - __alphabet = list(ascii_uppercase.replace("C", "")) + __alphabet = ["A", "B", "D", "E", "F", "G", "H", + "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", + "W", "X", "Y", "Z"] # region Widgets combo_letter = Gtk.Template.Child() @@ -101,12 +103,12 @@ class DrivesDialog(Adw.Window): # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window + self.window = window self.manager = window.manager self.config = config @@ -141,6 +143,7 @@ def __populate_drives_list(self): def __populate_combo_letter(self): drives = Drives(self.config).get_all() + self.str_list_letters.splice(0, self.str_list_letters.get_n_items()) for letter in self.__alphabet: if letter not in drives: diff --git a/bottles/frontend/windows/envvars.py b/bottles/frontend/windows/envvars.py index 84a9fdccbb..3ec5d6c656 100644 --- a/bottles/frontend/windows/envvars.py +++ b/bottles/frontend/windows/envvars.py @@ -80,13 +80,13 @@ class EnvVarsDialog(Adw.Window): group_vars = Gtk.Template.Child() # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config self.__populate_vars_list() diff --git a/bottles/frontend/windows/exclusionpatterns.py b/bottles/frontend/windows/exclusionpatterns.py index a3a084de42..139d9c6c60 100644 --- a/bottles/frontend/windows/exclusionpatterns.py +++ b/bottles/frontend/windows/exclusionpatterns.py @@ -66,13 +66,13 @@ class ExclusionPatternsDialog(Adw.Window): group_patterns = Gtk.Template.Child() # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config self.__populate_patterns_list() diff --git a/bottles/frontend/windows/fsr.py b/bottles/frontend/windows/fsr.py index a82af6f2f0..99838fb6b6 100644 --- a/bottles/frontend/windows/fsr.py +++ b/bottles/frontend/windows/fsr.py @@ -56,7 +56,8 @@ def __update(self, config): parameters = config.Parameters # Populate entries - self.str_list_quality_mode.splice(0, 0, list(self.quality_mode.values())) + for mode in self.quality_mode.values(): + self.str_list_quality_mode.append(mode) # Select right entry if parameters.fsr_quality_mode: diff --git a/bottles/frontend/windows/gamescope.py b/bottles/frontend/windows/gamescope.py index de19a21d73..b04203bb81 100644 --- a/bottles/frontend/windows/gamescope.py +++ b/bottles/frontend/windows/gamescope.py @@ -37,13 +37,13 @@ class GamescopeDialog(Adw.Window): # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config # connect signals diff --git a/bottles/frontend/windows/sandbox.py b/bottles/frontend/windows/sandbox.py index 45205b6fe0..3f47a98322 100644 --- a/bottles/frontend/windows/sandbox.py +++ b/bottles/frontend/windows/sandbox.py @@ -28,12 +28,12 @@ class SandboxDialog(Adw.Window): # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window + self.window = window self.manager = window.manager self.config = config self.__update(config) diff --git a/bottles/frontend/windows/vmtouch.py b/bottles/frontend/windows/vmtouch.py index 16d9bcebd8..29d59ce137 100644 --- a/bottles/frontend/windows/vmtouch.py +++ b/bottles/frontend/windows/vmtouch.py @@ -31,13 +31,13 @@ class VmtouchDialog(Adw.Window): # endregion - def __init__(self, parent_window, config, **kwargs): + def __init__(self, window, config, **kwargs): super().__init__(**kwargs) - self.set_transient_for(parent_window) + self.set_transient_for(window) # common variables and references - self.parent_window = parent_window - self.manager = parent_window.manager + self.window = window + self.manager = window.manager self.config = config # connect signals