From 5e4be2a8b7975ca65f3df5a781c81d0b3fb8ad4e Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Sat, 21 Jan 2023 14:28:55 +0530 Subject: [PATCH 1/9] Remove unnecessary loop while deleting bottle --- bottles/backend/managers/manager.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bottles/backend/managers/manager.py b/bottles/backend/managers/manager.py index aca50c4cf9..df0a447a31 100644 --- a/bottles/backend/managers/manager.py +++ b/bottles/backend/managers/manager.py @@ -1415,11 +1415,7 @@ def delete_bottle(self, config: BottleConfig) -> bool: path = ManagerUtils.get_bottle_path(config) subprocess.run(["rm", "-rf", path], stdout=subprocess.DEVNULL) - local_bottles_tmp = self.local_bottles.copy() - for b in local_bottles_tmp.values(): - if b.Path == config.Path: - del self.local_bottles[b.Name] - break + del self.local_bottles[config.Name] logging.info(f"Deleted the bottle in: {path}") return True From 965f8e7705c540706360dc93b1b91755ef09c77a Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Sat, 21 Jan 2023 14:58:14 +0530 Subject: [PATCH 2/9] Update bottles list when deleting a bottle Makes sure the list view gets properly updated when deleting a bottle --- bottles/backend/managers/manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bottles/backend/managers/manager.py b/bottles/backend/managers/manager.py index df0a447a31..ebd7890358 100644 --- a/bottles/backend/managers/manager.py +++ b/bottles/backend/managers/manager.py @@ -1416,6 +1416,7 @@ def delete_bottle(self, config: BottleConfig) -> bool: subprocess.run(["rm", "-rf", path], stdout=subprocess.DEVNULL) del self.local_bottles[config.Name] + self.update_bottles(silent=True) logging.info(f"Deleted the bottle in: {path}") return True From bf20e1894db8466370c66ed4322a22449cf170ce Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Thu, 16 Feb 2023 13:29:17 +0530 Subject: [PATCH 3/9] Dont delete bottle config from local_bottles update_bottles already updates the config so this is not necessary --- bottles/backend/managers/manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bottles/backend/managers/manager.py b/bottles/backend/managers/manager.py index ebd7890358..1a44b4a102 100644 --- a/bottles/backend/managers/manager.py +++ b/bottles/backend/managers/manager.py @@ -1415,7 +1415,6 @@ def delete_bottle(self, config: BottleConfig) -> bool: path = ManagerUtils.get_bottle_path(config) subprocess.run(["rm", "-rf", path], stdout=subprocess.DEVNULL) - del self.local_bottles[config.Name] self.update_bottles(silent=True) logging.info(f"Deleted the bottle in: {path}") From 4f9609d4186fd8f395ee2fade7f6e6bddfd11371 Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Thu, 16 Feb 2023 14:34:44 +0530 Subject: [PATCH 4/9] Add accel for creating new bottle --- bottles/frontend/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bottles/frontend/main.py b/bottles/frontend/main.py index 9478e4b7f3..3071de8f8d 100644 --- a/bottles/frontend/main.py +++ b/bottles/frontend/main.py @@ -91,6 +91,7 @@ def __init__(self): self.__create_action('import', self.__show_importer_view, ['i']) self.__create_action('preferences', self.__show_preferences, ['comma']) self.__create_action('help', self.__help, ['F1']) + self.__create_action('new', self.__new_bottle, ['n']) self.__register_arguments() @@ -265,6 +266,9 @@ def __show_preferences(self, *args): preferences_window = PreferencesWindow(self.win) preferences_window.present() + def __new_bottle(self, *args): + self.win.show_add_view() + def __show_importer_view(self, widget=False, *args): self.win.main_leaf.set_visible_child(self.win.page_importer) From 8b6c6e3e3df764c6d8f50d6ac01b7f5b70a659e3 Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Thu, 16 Feb 2023 15:13:24 +0530 Subject: [PATCH 5/9] Add ShortcutsWindow --- bottles/frontend/ui/bottles.gresource.xml | 2 +- bottles/frontend/ui/help-overlay.blp | 29 +++++++++++++++++++++++ bottles/frontend/ui/meson.build | 1 + bottles/frontend/ui/window.blp | 5 ++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 bottles/frontend/ui/help-overlay.blp diff --git a/bottles/frontend/ui/bottles.gresource.xml b/bottles/frontend/ui/bottles.gresource.xml index 7e9f59021a..00915727f5 100644 --- a/bottles/frontend/ui/bottles.gresource.xml +++ b/bottles/frontend/ui/bottles.gresource.xml @@ -53,7 +53,7 @@ dialog-vmtouch.ui onboard.ui about.ui - + help-overlay.ui ../../../data/icons/symbolic/scalable/apps/bottles-steam-symbolic.svg diff --git a/bottles/frontend/ui/help-overlay.blp b/bottles/frontend/ui/help-overlay.blp new file mode 100644 index 0000000000..9ff164ada6 --- /dev/null +++ b/bottles/frontend/ui/help-overlay.blp @@ -0,0 +1,29 @@ +using Gtk 4.0; + +ShortcutsWindow help_overlay { + modal: true; + + ShortcutsSection { + section-name: "shortcuts"; + max-height: 10; + + ShortcutsGroup { + title: C_("shortcut window", "General"); + + ShortcutsShortcut { + title: C_("shortcut window", "Show Shortcuts"); + action-name: "win.show-help-overlay"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Quit"); + action-name: "app.quit"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "New Bottle"); + action-name: "app.new"; + } + } + } +} diff --git a/bottles/frontend/ui/meson.build b/bottles/frontend/ui/meson.build index 0663424bd4..cb53f63056 100644 --- a/bottles/frontend/ui/meson.build +++ b/bottles/frontend/ui/meson.build @@ -52,6 +52,7 @@ blueprints = custom_target('blueprints', 'task-entry.blp', 'window.blp', 'details-preferences.blp', + 'help-overlay.blp', ), output: '.', command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],) diff --git a/bottles/frontend/ui/window.blp b/bottles/frontend/ui/window.blp index 99789c7091..c4e99df26c 100644 --- a/bottles/frontend/ui/window.blp +++ b/bottles/frontend/ui/window.blp @@ -92,6 +92,11 @@ menu primary_menu { action: "app.help"; } + item { + label: _("_Keyboard Shortcuts"); + action: "win.show-help-overlay"; + } + item { label: _("About Bottles"); action: "app.about"; From ac9cf195d270bbea0a45118e04411ab311ecdb1e Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Thu, 16 Feb 2023 19:02:23 +0530 Subject: [PATCH 6/9] Add currently existing keyboard shortcuts to shortcuts window --- bottles/frontend/ui/help-overlay.blp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/bottles/frontend/ui/help-overlay.blp b/bottles/frontend/ui/help-overlay.blp index 9ff164ada6..bf7eeb8b92 100644 --- a/bottles/frontend/ui/help-overlay.blp +++ b/bottles/frontend/ui/help-overlay.blp @@ -10,6 +10,26 @@ ShortcutsWindow help_overlay { ShortcutsGroup { title: C_("shortcut window", "General"); + ShortcutsShortcut { + title: C_("shortcut window", "New Bottle"); + action-name: "app.new"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Import Bottle"); + action-name: "app.import"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Preferences"); + action-name: "app.preferences"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Documentation"); + action-name: "app.help"; + } + ShortcutsShortcut { title: C_("shortcut window", "Show Shortcuts"); action-name: "win.show-help-overlay"; @@ -20,10 +40,6 @@ ShortcutsWindow help_overlay { action-name: "app.quit"; } - ShortcutsShortcut { - title: C_("shortcut window", "New Bottle"); - action-name: "app.new"; - } } } } From 252334f861b72cca0ef37290c9b8f9b8d41a3abe Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Sat, 24 Jun 2023 11:50:20 +0530 Subject: [PATCH 7/9] Add keyboard shortcut to change view --- bottles/frontend/main.py | 8 ++++++++ bottles/frontend/ui/help-overlay.blp | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/bottles/frontend/main.py b/bottles/frontend/main.py index 3071de8f8d..183e17f431 100644 --- a/bottles/frontend/main.py +++ b/bottles/frontend/main.py @@ -92,6 +92,8 @@ def __init__(self): self.__create_action('preferences', self.__show_preferences, ['comma']) self.__create_action('help', self.__help, ['F1']) self.__create_action('new', self.__new_bottle, ['n']) + self.__create_action('switch_to_bottles_page', self.__show_bottles_view, ['1']) + self.__create_action('switch_to_library_page', self.__show_library_view, ['2']) self.__register_arguments() @@ -340,6 +342,12 @@ def __show_about_window(self, *_args): about_window.set_transient_for(self.win) about_window.present() + def __show_library_view(self, *_args): + self.win.stack_main.set_visible_child_name("page_library") + + def __show_bottles_view(self, *_args): + self.win.stack_main.set_visible_child_name("page_list") + def __create_action(self, name, callback, shortcuts=None, param=None): """Add an application action. diff --git a/bottles/frontend/ui/help-overlay.blp b/bottles/frontend/ui/help-overlay.blp index bf7eeb8b92..6132f6fc94 100644 --- a/bottles/frontend/ui/help-overlay.blp +++ b/bottles/frontend/ui/help-overlay.blp @@ -40,6 +40,15 @@ ShortcutsWindow help_overlay { action-name: "app.quit"; } + ShortcutsShortcut { + title: C_("shortcut window", "Switch to Bottles view"); + action-name: "app.switch_to_bottles_page"; + } + + ShortcutsShortcut { + title: C_("shortcut window", "Switch to Library view"); + action-name: "app.switch_to_library_page"; + } } } } From eb2bfa5c362029c7c51d52b9d180bd2cc27dace1 Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Sat, 24 Jun 2023 12:32:53 +0530 Subject: [PATCH 8/9] Create bottle when enter is pressed --- bottles/frontend/views/new.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bottles/frontend/views/new.py b/bottles/frontend/views/new.py index 3434e52010..aeda34d396 100644 --- a/bottles/frontend/views/new.py +++ b/bottles/frontend/views/new.py @@ -105,11 +105,14 @@ def __init__(self, window, **kwargs): # focus on the entry_name self.entry_name.grab_focus() + # Create bottle when pressing enter + self.entry_name.connect("entry-activated", self.create_bottle) + def __set_group(self, *_args) -> None: """ Checks the state of combo_environment and updates group_custom accordingly. """ self.group_custom.set_sensitive(self.check_custom.get_active()) - def __check_entry_name(self, *_args) -> None: + def __check_entry_name(self, *_args) -> bool: is_duplicate = self.entry_name.get_text() in self.manager.local_bottles is_invalid = is_duplicate or self.entry_name.get_text() == "" self.btn_create.set_sensitive(not is_invalid) @@ -117,8 +120,10 @@ def __check_entry_name(self, *_args) -> None: if is_invalid: self.entry_name.add_css_class("error") + return False else: self.entry_name.remove_css_class("error") + return True def __choose_env_recipe(self, *_args) -> None: """ @@ -164,6 +169,9 @@ def set_path(_dialog, response: Gtk.ResponseType) -> None: dialog.show() def create_bottle(self, *_args) -> None: + if not self.__check_entry_name(): + return + """ Starts creating the bottle. """ # set widgets states self.is_closable = False From 8d2e9903c5cdff309a71fe6261da2282eaa897eb Mon Sep 17 00:00:00 2001 From: Cyber Phantom Date: Sat, 24 Jun 2023 12:39:47 +0530 Subject: [PATCH 9/9] Add shortcut to go back to previous view --- bottles/frontend/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bottles/frontend/main.py b/bottles/frontend/main.py index 183e17f431..b26075cc26 100644 --- a/bottles/frontend/main.py +++ b/bottles/frontend/main.py @@ -94,6 +94,7 @@ def __init__(self): self.__create_action('new', self.__new_bottle, ['n']) self.__create_action('switch_to_bottles_page', self.__show_bottles_view, ['1']) self.__create_action('switch_to_library_page', self.__show_library_view, ['2']) + self.__create_action('go_back', self.__go_back, ['Left']) self.__register_arguments() @@ -348,6 +349,9 @@ def __show_library_view(self, *_args): def __show_bottles_view(self, *_args): self.win.stack_main.set_visible_child_name("page_list") + def __go_back(self, *_args): + self.win.main_leaf.navigate(Adw.NavigationDirection.BACK) + def __create_action(self, name, callback, shortcuts=None, param=None): """Add an application action.