diff --git a/bottles/frontend/ui/bottle-details-page.blp b/bottles/frontend/ui/bottle-details-page.blp index e52e277249..5710e96a7c 100644 --- a/bottles/frontend/ui/bottle-details-page.blp +++ b/bottles/frontend/ui/bottle-details-page.blp @@ -140,338 +140,370 @@ Popover popover_exec_settings { } } -template $BottlesBottleDetailsPage: Adw.PreferencesPage { - Overlay drop_overlay { - visible: false; - - [overlay] - Adw.StatusPage { - icon-name: "system-run-symbolic"; - title: _("Drop files to execute them"); - - styles [ - "dragndrop_overlay", - ] +template $BottlesBottleDetailsPage: Adw.NavigationPage { + title: _("Details"); + tag: "details"; + + child: Adw.ToolbarView { + [top] + Adw.HeaderBar { + [end] + Box default_actions {} } - } - Adw.PreferencesGroup { - Box { - orientation: vertical; + content: Adw.PreferencesPage { + Overlay drop_overlay { + visible: false; - Label label_name { - halign: center; - justify: center; - wrap: true; - max-width-chars: 30; - label: _("My bottle"); - wrap-mode: word_char; - use-markup: false; + [overlay] + Adw.StatusPage { + icon-name: "system-run-symbolic"; + title: _("Drop files to execute them"); - styles [ - "title-1", - ] + styles [ + "dragndrop_overlay", + ] + } } - Box { - spacing: 6; - halign: center; + Adw.PreferencesGroup { + Box { + orientation: vertical; - Label label_arch { - label: _("Win64"); + Label label_name { + halign: center; + justify: center; + wrap: true; + max-width-chars: 30; + label: _("My bottle"); + wrap-mode: word_char; + use-markup: false; + + styles [ + "title-1", + ] + } - styles [ - "heading", - ] - } + Box { + spacing: 6; + halign: center; - Label { - label: "·"; - } + Label label_arch { + label: _("Win64"); - Label label_environment { - label: _("Environment"); + styles [ + "heading", + ] + } - styles [ - "heading", - ] - } + Label { + label: "·"; + } - Label { - label: "·"; - } + Label label_environment { + label: _("Environment"); - Label label_runner { - label: _("Runner"); + styles [ + "heading", + ] + } - styles [ - "heading", - ] - } + Label { + label: "·"; + } - Label dot_versioning { - label: "·"; - } + Label label_runner { + label: _("Runner"); - Grid grid_versioning { - tooltip-text: _("Versioning enabled for this bottle"); - halign: center; - valign: center; + styles [ + "heading", + ] + } - Image img_versioning { - tooltip-text: _("Versioning is active for this bottle."); - halign: center; - valign: center; - icon-name: "view-wrapped-symbolic"; - } + Label dot_versioning { + label: "·"; + } - Label label_state { - halign: center; - valign: center; - label: _("0"); + Grid grid_versioning { + tooltip-text: _("Versioning enabled for this bottle"); + halign: center; + valign: center; + + Image img_versioning { + tooltip-text: _("Versioning is active for this bottle."); + halign: center; + valign: center; + icon-name: "view-wrapped-symbolic"; + } + + Label label_state { + halign: center; + valign: center; + label: _("0"); + } + } } } } - } - } - - Adw.PreferencesGroup { - Box { - spacing: 6; - halign: center; - Button btn_execute { + Adw.PreferencesGroup { Box { spacing: 6; + halign: center; - Image { - icon-name: "media-playback-start-symbolic"; + Button btn_execute { + Box { + spacing: 6; + + Image { + icon-name: "media-playback-start-symbolic"; + } + + Label { + label: _("Run Executable…"); + } + } + + styles [ + "pill", + "suggested-action", + ] } - Label { - label: _("Run Executable…"); + Box { + MenuButton btn_exec_settings { + valign: center; + icon-name: "applications-system-symbolic"; + popover: popover_exec_settings; + + styles [ + "circular", + ] + } } } - - styles [ - "pill", - "suggested-action", - ] } - Box { - MenuButton btn_exec_settings { - valign: center; - icon-name: "applications-system-symbolic"; - popover: popover_exec_settings; + Adw.PreferencesGroup group_programs { + title: _("Programs"); - styles [ - "circular", - ] + Adw.ActionRow row_no_programs { + subtitle: _("Click \"Run Executable…\" to run an executable, \"Add Shortcuts…\" to add an executable to the Programs list, or \"Install Programs…\" to install programs curated by the community."); } - } - } - } - Adw.PreferencesGroup group_programs { - title: _("Programs"); + Adw.PreferencesRow bottom_bar { + activatable: false; + focusable: false; - Adw.ActionRow row_no_programs { - subtitle: _("Click \"Run Executable…\" to run an executable, \"Add Shortcuts…\" to add an executable to the Programs list, or \"Install Programs…\" to install programs curated by the community."); - } + Box { + Button add_shortcuts { + hexpand: true; - Adw.PreferencesRow bottom_bar { - activatable: false; - focusable: false; + Box { + halign: center; - Box { - Button add_shortcuts { - hexpand: true; + Image { + icon-name: "list-add-symbolic"; + } - Box { - halign: center; + Separator { + styles [ + "spacer" + ] + } - Image { - icon-name: "list-add-symbolic"; - } + Label { + label: _("Add Shortcuts…"); + } + } - Separator { styles [ - "spacer" + "flat" ] } - Label { - label: _("Add Shortcuts…"); - } - } + Separator {} - styles [ - "flat" - ] - } + Button install_programs { + hexpand: true; - Separator {} + Box { + halign: center; - Button install_programs { - hexpand: true; + Image { + icon-name: "folder-download-symbolic"; + } - Box { - halign: center; + Separator { + styles [ + "spacer" + ] + } - Image { - icon-name: "folder-download-symbolic"; - } + Label { + label: _("Install Programs…"); + } + } - Separator { styles [ - "spacer" + "flat" ] } - Label { - label: _("Install Programs…"); - } + styles [ + "linked" + ] } styles [ - "flat" + "bottom-bar" ] } - - styles [ - "linked" - ] } - styles [ - "bottom-bar" - ] - } - } + Adw.PreferencesGroup group_options { + title: _("Options"); - Adw.PreferencesGroup group_options { - title: _("Options"); + Adw.ActionRow row_preferences { + activatable: true; + title: _("Settings"); + subtitle: _("Configure bottle settings."); - Adw.ActionRow row_preferences { - activatable: true; - title: _("Settings"); - subtitle: _("Configure bottle settings."); + Image { + icon-name: "go-next-symbolic"; + } + } - Image { - icon-name: "go-next-symbolic"; - } - } + Adw.ActionRow row_dependencies { + activatable: true; + title: _("Dependencies"); + subtitle: _("Install dependencies for programs."); - Adw.ActionRow row_dependencies { - activatable: true; - title: _("Dependencies"); - subtitle: _("Install dependencies for programs."); + Image { + icon-name: "go-next-symbolic"; + } + } - Image { - icon-name: "go-next-symbolic"; - } - } + Adw.ActionRow row_snapshots { + activatable: true; + title: _("Snapshots"); + subtitle: _("Create and manage bottle states."); + + Image { + icon-name: "go-next-symbolic"; + } + } - Adw.ActionRow row_snapshots { - activatable: true; - title: _("Snapshots"); - subtitle: _("Create and manage bottle states."); + Adw.ActionRow row_taskmanager { + activatable: true; + title: _("Task Manager"); + subtitle: _("Manage running programs."); - Image { - icon-name: "go-next-symbolic"; + Image { + icon-name: "go-next-symbolic"; + } + } } - } - Adw.ActionRow row_taskmanager { - activatable: true; - title: _("Task Manager"); - subtitle: _("Manage running programs."); + Adw.PreferencesGroup group_utilities { + title: _("Tools"); - Image { - icon-name: "go-next-symbolic"; - } - } - } + Adw.ActionRow row_cmd { + activatable: true; + title: _("Command Line"); + subtitle: _("Run commands inside the Bottle."); - Adw.PreferencesGroup group_utilities { - title: _("Tools"); + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_cmd { - activatable: true; - title: _("Command Line"); - subtitle: _("Run commands inside the Bottle."); + Adw.ActionRow row_regedit { + activatable: true; + title: _("Registry Editor"); + subtitle: _("Edit the internal registry."); - Image { - icon-name: "external-link-symbolic"; - } - } + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_regedit { - activatable: true; - title: _("Registry Editor"); - subtitle: _("Edit the internal registry."); + Adw.ExpanderRow { + title: _("Legacy Wine Tools"); - Image { - icon-name: "external-link-symbolic"; - } - } + Adw.ActionRow row_explorer { + activatable: true; + title: _("Explorer"); - Adw.ExpanderRow { - title: _("Legacy Wine Tools"); + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_explorer { - activatable: true; - title: _("Explorer"); + Adw.ActionRow row_taskmanager_legacy { + activatable: true; + title: _("Task Manager"); - Image { - icon-name: "external-link-symbolic"; - } - } + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_taskmanager_legacy { - activatable: true; - title: _("Task Manager"); + Adw.ActionRow row_debug { + activatable: true; + title: _("Debugger"); - Image { - icon-name: "external-link-symbolic"; - } - } + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_debug { - activatable: true; - title: _("Debugger"); + Adw.ActionRow row_winecfg { + activatable: true; + title: _("Configuration"); - Image { - icon-name: "external-link-symbolic"; - } - } + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_winecfg { - activatable: true; - title: _("Configuration"); + Adw.ActionRow row_uninstaller { + activatable: true; + title: _("Uninstaller"); - Image { - icon-name: "external-link-symbolic"; - } - } + Image { + icon-name: "external-link-symbolic"; + } + } - Adw.ActionRow row_uninstaller { - activatable: true; - title: _("Uninstaller"); + Adw.ActionRow row_controlpanel { + activatable: true; + title: _("Control Panel"); - Image { - icon-name: "external-link-symbolic"; + Image { + icon-name: "external-link-symbolic"; + } + } } } + }; + }; +} - Adw.ActionRow row_controlpanel { - activatable: true; - title: _("Control Panel"); +Popover pop_tasks { + Box { + orientation: vertical; + spacing: 3; - Image { - icon-name: "external-link-symbolic"; - } + Box { + orientation: vertical; + + ListBox list_tasks { + selection-mode: none; + + styles [ + "content", + ] } } } diff --git a/bottles/frontend/ui/details.blp b/bottles/frontend/ui/details.blp deleted file mode 100644 index 98041d7370..0000000000 --- a/bottles/frontend/ui/details.blp +++ /dev/null @@ -1,34 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -template $DetailsView: Adw.NavigationPage { - title: _("Details"); - tag: "details"; - - child: Adw.ToolbarView { - [top] - Adw.HeaderBar { - [end] - Box default_actions {} - } - }; -} - -Popover pop_tasks { - Box { - orientation: vertical; - spacing: 3; - - Box { - orientation: vertical; - - ListBox list_tasks { - selection-mode: none; - - styles [ - "content", - ] - } - } - } -} diff --git a/bottles/frontend/ui/meson.build b/bottles/frontend/ui/meson.build index 0b0c8a7662..6107fc758c 100644 --- a/bottles/frontend/ui/meson.build +++ b/bottles/frontend/ui/meson.build @@ -10,7 +10,6 @@ blueprints = custom_target('blueprints', 'details-installers.blp', 'details-taskmanager.blp', 'details-versioning.blp', - 'details.blp', 'dialog-bottle-picker.blp', 'dialog-crash-report.blp', 'dialog-deps-check.blp', diff --git a/bottles/frontend/views/bottle_details_page.py b/bottles/frontend/views/bottle_details_page.py index 0eb549e4bd..7b432178f4 100644 --- a/bottles/frontend/views/bottle_details_page.py +++ b/bottles/frontend/views/bottle_details_page.py @@ -47,7 +47,7 @@ @Gtk.Template(resource_path="/com/usebottles/bottles/bottle-details-page.ui") -class BottlesBottleDetailsPage(Adw.PreferencesPage): +class BottlesBottleDetailsPage(Adw.NavigationPage): __gtype_name__ = "BottlesBottleDetailsPage" __registry = [] @@ -94,20 +94,23 @@ class BottlesBottleDetailsPage(Adw.PreferencesPage): row_no_programs = Gtk.Template.Child() bottom_bar = Gtk.Template.Child() drop_overlay = Gtk.Template.Child() + default_actions = Gtk.Template.Child() + list_tasks = Gtk.Template.Child() + pop_tasks = Gtk.Template.Child() # endregion content = Gdk.ContentFormats.new_for_gtype(Gdk.FileList) target = Gtk.DropTarget(formats=content, actions=Gdk.DragAction.COPY) - style_provider = Gtk.CssProvider() - - def __init__(self, details, config, **kwargs): + def __init__(self, window, config: Optional[BottleConfig] = None, **kwargs): super().__init__(**kwargs) # common variables and references - self.window = details.window - self.manager = details.window.manager - self.details = details + if config is None: + config = BottleConfig() + + self.window = window + self.manager = window.manager self.config = config self.show_hidden = False @@ -117,13 +120,8 @@ def __init__(self, details, config, **kwargs): self.target.connect("leave", self.on_leave) self.add_shortcuts.connect("clicked", self.add) - self.install_programs.connect("clicked", self.__change_page, "installers") self.btn_execute.connect("clicked", self.run_executable) self.popover_exec_settings.connect("closed", self.__run_executable_with_args) - self.row_preferences.connect("activated", self.__change_page, "preferences") - self.row_dependencies.connect("activated", self.__change_page, "dependencies") - self.row_snapshots.connect("activated", self.__change_page, "versioning") - self.row_taskmanager.connect("activated", self.__change_page, "taskmanager") self.row_winecfg.connect("activated", self.run_winecfg) self.row_debug.connect("activated", self.run_debug) self.row_explorer.connect("activated", self.run_explorer) @@ -147,19 +145,6 @@ def __init__(self, details, config, **kwargs): "clicked", open_doc_url, "flatpak/black-screen-or-silent-crash" ) - def __change_page(self, _widget, page_name): - """ - This function try to change the page based on user choice, if - the page is not available, it will show the "bottle" page. - """ - if page_name == "taskmanager": - self.details.view_taskmanager.update(config=self.config) - try: - self.stack_bottle.set_visible_child_name(page_name) - self.leaflet.navigate(Adw.NavigationDirection.FORWARD) - except: # pylint: disable=bare-except - pass - def on_drop(self, drop_target, value: Gdk.FileList, x, y, user_data=None): self.drop_overlay.set_visible(False) files: List[Gio.File] = value.get_files() diff --git a/bottles/frontend/views/details.py b/bottles/frontend/views/details.py deleted file mode 100644 index 2c01eb412e..0000000000 --- a/bottles/frontend/views/details.py +++ /dev/null @@ -1,142 +0,0 @@ -# details.py -# -# Copyright 2022 brombinmirko -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, in version 3 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - - -from gettext import gettext as _ -from typing import Optional - -from gi.repository import Gtk, Adw, GLib - -from bottles.backend.managers.queue import QueueManager -from bottles.backend.models.config import BottleConfig - -from bottles.backend.utils.threading import RunAsync -from bottles.frontend.utils.gtk import GtkUtils -from bottles.frontend.views.bottle_details_page import BottlesBottleDetailsPage -from bottles.frontend.views.bottle_installers import InstallersView -from bottles.frontend.views.bottle_dependencies import DependenciesView -from bottles.frontend.views.bottle_preferences import PreferencesView -from bottles.frontend.views.bottle_versioning import VersioningView -from bottles.frontend.views.bottle_taskmanager import TaskManagerView - - -@Gtk.Template(resource_path="/com/usebottles/bottles/details.ui") -class DetailsView(Adw.NavigationPage): - """ - This class is the starting point for all the pages concerning the - bottle (details, preferences, dependencies ..). - """ - - __gtype_name__ = "DetailsView" - __pages = {} - - # region Widgets - default_actions = Gtk.Template.Child() - list_tasks = Gtk.Template.Child() - pop_tasks = Gtk.Template.Child() - - # endregion - - def __init__(self, window, config: Optional[BottleConfig] = None, **kwargs): - super().__init__(**kwargs) - - # common variables and references - if config is None: - config = BottleConfig() - - self.window = window - self.manager = window.manager - self.versioning_manager = window.manager.versioning_manager - self.config = config - self.queue = QueueManager(add_fn=self.lock_back, end_fn=self.unlock_back) - - self.view_bottle = BottlesBottleDetailsPage(self, config) - self.view_installers = InstallersView(self, config) - self.view_dependencies = DependenciesView(self, config) - self.view_preferences = PreferencesView(self, config) - self.view_versioning = VersioningView(self, config) - self.view_taskmanager = TaskManagerView(self, config) - - self.default_actions.append(self.view_bottle.actions) - - # region signals - # endregion - - RunAsync(self.build_pages) - - def build_pages(self): - """ - This function build the pages list according to the - user settings (some pages are shown only if experimental - features are enabled). - """ - self.__pages = { - "preferences": { - "title": _("Settings"), - "description": "", - }, - "dependencies": { - "title": _("Dependencies"), - "description": "", - }, - "versioning": { - "title": _("Snapshots"), - "description": "", - }, - "installers": { - "title": _("Installers"), - "description": "", - }, - "taskmanager": { - "title": _("Task Manager"), - "description": "", - }, - } - - if self.config.Environment == "Steam": - del self.__pages["versioning"] - - def ui_update(): - toolbar_view = self.get_child() - toolbar_view.set_content(self.view_bottle) - - GLib.idle_add(ui_update) - - def set_config(self, config: BottleConfig): - """ - This function update widgets according to the bottle - configuration. It also temporarily disable the functions - connected to the widgets to avoid the bottle configuration - to be updated during this process. - """ - self.config = config - - # update widgets data with bottle configuration - self.view_bottle.set_config(config=config) - self.view_preferences.set_config(config=config) - self.view_taskmanager.set_config(config=config) - self.view_installers.update(config=config) - self.view_versioning.update(config=config) - - @GtkUtils.run_in_main_loop - def lock_back(self): ... - - @GtkUtils.run_in_main_loop - def unlock_back(self): ... - - def update_runner_label(self, runner: str): - self.view_bottle.label_runner.set_text(runner) diff --git a/bottles/frontend/views/meson.build b/bottles/frontend/views/meson.build index 9c8641dac1..6ff3b80ab4 100644 --- a/bottles/frontend/views/meson.build +++ b/bottles/frontend/views/meson.build @@ -6,7 +6,6 @@ bottles_sources = [ 'new_bottle_dialog.py', 'overview_list_page.py', 'library.py', - 'details.py', 'preferences.py', 'import_page.py', 'loading.py', diff --git a/bottles/frontend/views/overview_list_page.py b/bottles/frontend/views/overview_list_page.py index 46c0dee901..ee9dfe8016 100644 --- a/bottles/frontend/views/overview_list_page.py +++ b/bottles/frontend/views/overview_list_page.py @@ -115,7 +115,7 @@ def set_path(_dialog, response): def show_details(self, widget=None, config=None): if config is None: config = self.config - self.window.page_details.view_preferences.update_combo_components() + # self.window.page_details.view_preferences.update_combo_components() self.window.show_details_view(config=config) def disable(self): diff --git a/bottles/frontend/windows/window.py b/bottles/frontend/windows/window.py index 0e388eda8c..6d2883d491 100644 --- a/bottles/frontend/windows/window.py +++ b/bottles/frontend/windows/window.py @@ -36,7 +36,6 @@ from bottles.frontend.operation import TaskSyncer from bottles.frontend.params import APP_ID, BASE_ID, PROFILE from bottles.frontend.utils.gtk import GtkUtils -from bottles.frontend.views.details import DetailsView from bottles.frontend.views.import_page import BottlesImportPage from bottles.frontend.views.library import LibraryView from bottles.frontend.views.overview_list_page import BottlesOverviewListPage @@ -46,6 +45,7 @@ from bottles.frontend.windows.crash import CrashReportDialog from bottles.frontend.windows.depscheck import DependenciesCheckDialog from bottles.frontend.windows.onboard import OnboardDialog +from bottles.frontend.views.bottle_details_page import BottlesBottleDetailsPage logging = Logger() @@ -221,7 +221,7 @@ def set_manager(result: Manager, error=None): self.show_onboard_view() # Pages - self.page_details = DetailsView(self) + self.page_details = BottlesBottleDetailsPage(self) self.page_list = BottlesOverviewListPage(self, arg_bottle=self.arg_bottle) self.page_importer = BottlesImportPage(self) self.page_library = LibraryView(self)