Skip to content

Commit

Permalink
Reapply "bottle-preferences: Use single private method to show dialog"
Browse files Browse the repository at this point in the history
This reverts commit 75f5867.
  • Loading branch information
TheEvilSkeleton committed Dec 23, 2024
1 parent 04a253e commit cccf40d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 63 deletions.
79 changes: 28 additions & 51 deletions bottles/frontend/views/bottle_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,33 @@ def __init__(self, details, config, **kwargs):
self.switch_obsvkc.set_tooltip_text(_obsvkc_not_available)

# region signals
self.row_overrides.connect("activated", self.__show_dll_overrides_view)
self.row_env_variables.connect("activated", self.__show_environment_variables)
self.row_drives.connect("activated", self.__show_drives)
self.row_manage_display.connect("activated", self.__show_display_settings)
self.btn_manage_gamescope.connect("clicked", self.__show_gamescope_settings)
self.btn_manage_vkbasalt.connect("clicked", self.__show_vkbasalt_settings)
self.btn_manage_fsr.connect("clicked", self.__show_fsr_settings)
self.btn_manage_mangohud.connect("clicked", self.__show_mangohud_settings)
self.btn_manage_sandbox.connect("clicked", self.__show_sandbox_settings)
self.row_overrides.connect(
"activated", self.__show_feature_dialog, DLLOverridesDialog
)
self.row_env_variables.connect(
"activated", self.__show_feature_dialog, EnvVarsDialog
)
self.row_drives.connect("activated", self.__show_feature_dialog, DrivesDialog)
self.btn_manage_gamescope.connect(
"clicked", self.__show_feature_dialog, GamescopeDialog
)
self.btn_manage_vkbasalt.connect(
"clicked", self.__show_feature_dialog, VkBasaltDialog
)
self.btn_manage_fsr.connect("clicked", self.__show_feature_dialog, FsrDialog)
self.btn_manage_mangohud.connect(
"clicked", self.__show_feature_dialog, MangoHudDialog
)
self.btn_manage_sandbox.connect(
"clicked", self.__show_feature_dialog, SandboxDialog
)
self.btn_manage_vmtouch.connect(
"clicked", self.__show_feature_dialog, VmtouchDialog
)
self.btn_manage_versioning_patterns.connect(
"clicked", self.__show_exclusionpatterns_settings
"clicked", self.__show_feature_dialog, ExclusionPatternsDialog
)
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)
Expand Down Expand Up @@ -555,22 +569,6 @@ def set_config(self, config: BottleConfig):

self.__set_steam_rules()

def __show_gamescope_settings(self, widget):
new_window = GamescopeDialog(window=self.window, config=self.config)
new_window.present()

def __show_vkbasalt_settings(self, widget):
new_window = VkBasaltDialog(parent_window=self.window, config=self.config)
new_window.present()

def __show_fsr_settings(self, widget):
new_window = FsrDialog(parent_window=self.window, config=self.config)
new_window.present()

def __show_mangohud_settings(self, widget):
new_window = MangoHudDialog(parent_window=self.window, config=self.config)
new_window.present()

def __show_display_settings(self, widget):
new_window = DisplayDialog(
parent_window=self.window,
Expand All @@ -582,26 +580,10 @@ def __show_display_settings(self, widget):
)
new_window.present()

def __show_exclusionpatterns_settings(self, widget):
new_window = ExclusionPatternsDialog(window=self.window, config=self.config)
new_window.present()

def __show_sandbox_settings(self, widget):
new_window = SandboxDialog(window=self.window, config=self.config)
new_window.present()

def __show_drives(self, widget):
new_window = DrivesDialog(window=self.window, config=self.config)
new_window.present()

def __show_environment_variables(self, widget=False):
"""Show the environment variables dialog"""
new_window = EnvVarsDialog(window=self.window, config=self.config)
new_window.present()

def __show_vmtouch_settings(self, widget):
new_window = VmtouchDialog(window=self.window, config=self.config)
new_window.present()
def __show_feature_dialog(self, _widget: Gtk.Widget, dialog: Adw.Window) -> None:
"""Present dialog of a specific feature."""
window = dialog(window=self.window, config=self.config)
window.present()

def __set_sync_type(self, *_args):
"""
Expand Down Expand Up @@ -1004,11 +986,6 @@ def __set_language(self, *_args):
value=language[0],
).data["config"]

def __show_dll_overrides_view(self, widget=False):
"""Show the DLL overrides view"""
new_window = DLLOverridesDialog(window=self.window, config=self.config)
new_window.present()

@GtkUtils.run_in_main_loop
def set_dxvk_status(self, status=None, error=None, pending=False):
"""Set the dxvk status"""
Expand Down
8 changes: 4 additions & 4 deletions bottles/frontend/windows/fsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class FsrDialog(Adw.Window):
str_list_quality_mode = Gtk.Template.Child()
spin_sharpening_strength = Gtk.Template.Child()

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.window = parent_window
self.manager = parent_window.manager
self.window = window
self.manager = window.manager
self.config = config
self.quality_mode = {
"none": _("None"),
Expand Down
8 changes: 4 additions & 4 deletions bottles/frontend/windows/mangohud.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class MangoHudDialog(Adw.Window):
btn_save = Gtk.Template.Child()
display_on_game_start = Gtk.Template.Child()

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.window = parent_window
self.manager = parent_window.manager
self.window = window
self.manager = window.manager
self.config = config

# Connect signals
Expand Down
8 changes: 4 additions & 4 deletions bottles/frontend/windows/vkbasalt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class VkBasaltDialog(Adw.Window):
spin_smaa_corner_rounding = Gtk.Template.Child()
btn_save = Gtk.Template.Child()

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.window = parent_window
self.manager = parent_window.manager
self.window = window
self.manager = window.manager
self.config = config
conf = os.path.join(
ManagerUtils.get_bottle_path(self.config), "vkBasalt.conf"
Expand Down

0 comments on commit cccf40d

Please sign in to comment.