Various UI improvements

This commit is contained in:
heliguy4599
2024-10-10 22:39:08 -04:00
parent e7c1ba9217
commit 322a99c9c8
6 changed files with 91 additions and 62 deletions

View File

@@ -67,21 +67,6 @@ template $InstallPage : Adw.BreakpointBin {
Adw.LayoutSlot {
id: "pending_page";
}
[bottom-bar]
Box {
margin-top: 12;
margin-bottom: 14;
spacing: 6;
halign: center;
Image {
icon-name: "flatpak-symbolic";
icon-size: normal;
}
Label {
label: _("Pending Packages");
styles ["heading"]
}
}
}
}
[select_page]
@@ -93,3 +78,30 @@ template $InstallPage : Adw.BreakpointBin {
}
}
}
Revealer bottom_child {
reveal-child: false;
Box {
margin-top: 12;
margin-bottom: 14;
spacing: 12;
halign: center;
valign: center;
styles ["flat"]
[start]
Image {
icon-name: "flatpak-symbolic";
icon-size: normal;
}
[center]
Label bottom_label {
label: _("Pending Packages");
styles ["heading"]
}
[end]
Image {
icon-name: "right-large-symbolic";
icon-size: normal;
}
}
}

View File

@@ -20,6 +20,9 @@ class InstallPage(Adw.BreakpointBin):
status_stack = gtc()
loading_view = gtc()
installing_view = gtc()
bottom_sheet = gtc()
bottom_child = gtc()
bottom_label = gtc()
# Referred to in the main window
# It is used to determine if a new page should be made or not
@@ -54,17 +57,40 @@ class InstallPage(Adw.BreakpointBin):
if PackageInstallWorker.install(package_requests, self.installing_status, self.install_callback, self.install_error_callback):
self.status_stack.set_visible_child(self.installing_view)
def bottom_bar_visual_handler(self, is_added):
total = self.total_added_packages
if total == 0:
self.bottom_child.set_reveal_child(False)
self.bottom_sheet.set_bottom_bar(None)
elif total == 1:
self.bottom_label.set_label(_("{} Pending Package").format(1))
if is_added:
self.bottom_sheet.set_bottom_bar(self.bottom_child)
self.bottom_child.set_reveal_child(True)
else:
self.bottom_label.set_label(_("{} Pending Packages").format(total))
def package_added(self):
self.total_added_packages += 1
self.bottom_bar_visual_handler(True)
def package_removed(self):
self.total_added_packages -= 1
self.bottom_bar_visual_handler(False)
def __init__(self, main_window, **kwargs):
super().__init__(**kwargs)
self.instance = self
# Extra Object Creation
self.installing_status = LoadingStatus(_("Installing Packages"), _("This could take a while"), True, PackageInstallWorker.cancel)
self.total_added_packages = 0
# Connections
# Apply
self.select_page.results_page.pending_page = self.pending_page
self.select_page.results_page.install_page = self
self.loading_view.set_content(LoadingStatus(_("Loading Installation Options"), _("This should only take a moment")))
self.installing_status.button.set_label(_("Cancel"))
self.installing_view.set_content(self.installing_status)

View File

@@ -88,6 +88,9 @@ class PendingPage(Adw.NavigationPage):
if len(self.added_packages) == 0:
self.stack.set_visible_child(self.none_pending)
install_page = HostInfo.main_window.pages[HostInfo.main_window.install_row]
install_page.package_removed()
def on_install(self, *args):
package_requests = []
for key, group in self.groups.items():

View File

@@ -9,21 +9,15 @@ template $ResultsPage : Adw.NavigationPage {
[top]
Adw.Clamp {
maximum-size: 577;
Box {
margin-top: 3;
margin-bottom: 3;
margin-start: 6;
margin-end: 6;
styles ["linked"]
Gtk.SearchEntry search_entry {
search-delay: 700;
halign: fill;
hexpand: true;
placeholder-text: _("Search for Packages");
}
Button search_apply_button {
icon-name: "right-large-symbolic";
}
margin-top: 3;
margin-bottom: 3;
margin-start: 6;
margin-end: 6;
SearchEntry search_entry {
search-delay: 500;
halign: fill;
// hexpand: true;
placeholder-text: _("Search for Packages");
}
}
Stack stack {
@@ -37,15 +31,6 @@ template $ResultsPage : Adw.NavigationPage {
title: _("Too Many Results");
description: _("Try being more specific with your search");
}
// Adw.StatusPage loading {
// title: _("Searching");
// description: _("This should only take a moment");
// child:
// Spinner {
// spinning: true;
// }
// ;
// }
ScrolledWindow results_view {
Adw.Clamp {
ListBox results_list {

View File

@@ -8,19 +8,19 @@ import subprocess
class AddedPackage:
def __eq__(self, other):
return (
self.name == other.name and \
self.app_id == other.app_id and \
self.branch == other.branch and \
self.version == other.version and \
self.remote == other.remote and \
self.installation == other.installation
self.name == other.name
and self.app_id == other.app_id
and self.branch == other.branch
and self.version == other.version
and self.remote == other.remote
and self.installation == other.installation
)
def is_similar(self, other):
return (
self.app_id == other.app_id and \
self.branch == other.branch and \
self.version == other.version
self.app_id == other.app_id
and self.branch == other.branch
and self.version == other.version
)
def __init__(self, name, app_id, branch, version, remote, installation):
@@ -35,16 +35,15 @@ class AddedPackage:
class ResultsPage(Adw.NavigationPage):
__gtype_name__ = "ResultsPage"
gtc = Gtk.Template.Child
search_entry = gtc()
search_apply_button = gtc()
results_list = gtc()
stack = gtc()
new_search = gtc()
too_many = gtc()
results_view= gtc()
no_results = gtc()
def show_remote(self, row, remote, installation, nav_view=None):
self.remote = remote
self.installation = installation
@@ -56,7 +55,9 @@ class ResultsPage(Adw.NavigationPage):
def add_package_row(self, row):
self.pending_page.add_package_row(row)
if not self.install_page is None:
self.install_page.package_added()
def on_search(self, *args):
self.packages.clear()
self.stack.set_visible_child(self.loading)
@@ -116,11 +117,7 @@ class ResultsPage(Adw.NavigationPage):
except subprocess.CalledProcessError as cpe:
print(cpe)
def callback(*args):
pass
Gio.Task.new(None, None, callback).run_in_thread(thread)
Gio.Task().run_in_thread(thread)
def on_back(self, *args):
self.results_list.remove_all()
@@ -135,10 +132,10 @@ class ResultsPage(Adw.NavigationPage):
self.packages = []
self.pending_page = None
self.loading = LoadingStatus(_("Searching"), _("This should only take a moment"))
self.install_page = None
# Connections
self.search_entry.connect("activate", self.on_search)
self.search_apply_button.connect("clicked", self.on_search)
self.search_entry.connect("search-changed", self.on_search)
# Apply
self.stack.add_child(self.loading)

View File

@@ -25,7 +25,7 @@ class SnapshotsListPage(Adw.NavigationPage):
row = SnapshotBox(self, snapshot, folder, self.toast_overlay)
row.apply_button.set_sensitive(not is_leftover)
row.apply_button.set_tooltip_text(_("This App is not Installed"))
row.apply_button.set_tooltip_text(_("App not Installed"))
self.snapshots_rows.append(row)
def callback(self, *args):
@@ -47,11 +47,17 @@ class SnapshotsListPage(Adw.NavigationPage):
self.set_title(package_or_folder)
folder = package_or_folder
self.new_button.set_sensitive(False)
self.new_button.set_tooltip_text(_("App not Installed"))
else:
folder = package_or_folder.info["id"]
self.set_title(_("{} Snapshots").format(package_or_folder.info["name"]))
self.new_button.set_sensitive(os.path.exists(package_or_folder.data_path))
if os.path.exists(package_or_folder.data_path):
self.new_button.set_sensitive(True)
self.new_button.set_tooltip_text(None)
else:
self.new_button.set_sensitive(False)
self.new_button.set_tooltip_text(_("No Data Found to Snapshot"))
self.current_folder = folder
self.snapshots_rows.clear()
self.listbox.remove_all()