Skip to content

Commit

Permalink
importer-view: Port to modern widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEvilSkeleton committed Jan 14, 2025
1 parent 997276a commit e44d7cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 39 deletions.
51 changes: 24 additions & 27 deletions bottles/frontend/importer-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.");
};
}
}
};
};
}

Expand Down
18 changes: 6 additions & 12 deletions bottles/frontend/importer_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -50,27 +49,27 @@ 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
"""

@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()
Expand All @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit e44d7cd

Please sign in to comment.