diff --git a/bottles/frontend/importer-view.blp b/bottles/frontend/importer-view.blp index 19bacbee2b..3dd9b43f5b 100644 --- a/bottles/frontend/importer-view.blp +++ b/bottles/frontend/importer-view.blp @@ -5,18 +5,9 @@ template $ImporterView: Adw.NavigationPage { title: _("Import"); tag: "import"; - child: Box { - orientation: vertical; - - HeaderBar headerbar { - title-widget: Adw.WindowTitle window_title {}; - - [start] - Button btn_back { - tooltip-text: _("Go Back"); - icon-name: "go-previous-symbolic"; - } - + child: Adw.ToolbarView { + [top] + Adw.HeaderBar { [end] Box box_actions { MenuButton btn_import_backup { @@ -32,24 +23,30 @@ template $ImporterView: Adw.NavigationPage { } } - Adw.PreferencesPage { - Adw.StatusPage status_page { - vexpand: true; - icon-name: "document-save-symbolic"; - title: _("No Prefixes Found"); - description: _("No external prefixes were found. Does Bottles have access to them?\nUse the icon on the top to import a bottle from a backup."); - } + content: Stack stack { + StackPage { + name: "importer-page"; + child: Adw.PreferencesPage { + Adw.PreferencesGroup group_prefixes { - Adw.PreferencesGroup group_prefixes { - visible: false; + ListBox list_prefixes { + styles [ + "boxed-list", + ] + } + } + }; + } - ListBox list_prefixes { - styles [ - "boxed-list", - ] - } + StackPage { + name: "empty-page"; + child: Adw.StatusPage { + icon-name: "document-save-symbolic"; + title: _("No Prefixes Found"); + description: _("No external prefixes were found. Does Bottles have access to them? Use the icon on the top to import a bottle from a backup."); + }; } - } + }; }; } diff --git a/bottles/frontend/importer_view.py b/bottles/frontend/importer_view.py index aaa4954071..f6186abab0 100644 --- a/bottles/frontend/importer_view.py +++ b/bottles/frontend/importer_view.py @@ -35,9 +35,8 @@ class ImporterView(Adw.NavigationPage): btn_find_prefixes = Gtk.Template.Child() btn_import_config = Gtk.Template.Child() btn_import_full = Gtk.Template.Child() - btn_back = Gtk.Template.Child() group_prefixes = Gtk.Template.Child() - status_page = Gtk.Template.Child() + stack = Gtk.Template.Child() # endregion @@ -50,12 +49,13 @@ def __init__(self, window, **kwargs): self.import_manager = window.manager.import_manager # connect signals - self.btn_back.connect("clicked", self.go_back) self.btn_find_prefixes.connect("clicked", self.__find_prefixes) self.btn_import_full.connect("clicked", self.__import_full_bck) self.btn_import_config.connect("clicked", self.__import_config_bck) - def __find_prefixes(self, widget): + self.__find_prefixes() + + def __find_prefixes(self, *args): """ This function remove all entries from the list_prefixes, ask the manager to find all prefixes in the system and add them to the list @@ -63,14 +63,13 @@ def __find_prefixes(self, widget): @GtkUtils.run_in_main_loop def update(result, error=False): - widget.set_sensitive(True) if result.ok: wineprefixes = result.data.get("wineprefixes") if len(wineprefixes) == 0: + self.stack.set_visible_child_name("empty-page") return - self.status_page.set_visible(False) - self.group_prefixes.set_visible(True) + self.stack.set_visible_child_name("importer-page") while self.list_prefixes.get_first_child(): _w = self.list_prefixes.get_first_child() @@ -79,8 +78,6 @@ def update(result, error=False): for prefix in result.data.get("wineprefixes"): self.list_prefixes.append(ImporterRow(self, prefix)) - widget.set_sensitive(False) - RunAsync(self.import_manager.search_wineprefixes, callback=update) @GtkUtils.run_in_main_loop @@ -162,6 +159,3 @@ def set_path(_dialog, response): dialog.set_modal(True) dialog.connect("response", set_path) dialog.show() - - def go_back(self, *_args): - self.window.main_leaf.navigate(Adw.NavigationDirection.BACK)