Skip to content

Commit

Permalink
Revert "Minor improvements (#3102)" (#3110)
Browse files Browse the repository at this point in the history
This reverts commit 38cad2d.
  • Loading branch information
koplo199 authored Oct 1, 2023
1 parent 38cad2d commit af3a7cc
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 118 deletions.
117 changes: 76 additions & 41 deletions bottles/backend/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand Down
98 changes: 55 additions & 43 deletions bottles/frontend/views/bottle_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"""
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -544,36 +556,36 @@ 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()

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()
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions bottles/frontend/windows/dlloverrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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"]
)
Expand All @@ -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
)
Expand Down
Loading

0 comments on commit af3a7cc

Please sign in to comment.