Begin changing to proper loading pages

This commit is contained in:
Heliguy
2024-09-01 00:04:36 -04:00
parent 619b8225f7
commit 1594207fdb
6 changed files with 87 additions and 22 deletions

View File

@@ -0,0 +1,36 @@
using Gtk 4.0;
using Adw 1;
template $LoadingStatus : ScrolledWindow {
Box {
orientation: vertical;
valign: center;
halign: fill;
spacing: 12;
margin-start: 12;
margin-end: 12;
margin-top: 12;
margin-bottom: 12;
Spinner {
height-request: 30;
spinning: true;
}
Label title_label {
label: "No Title Set";
wrap: true;
justify: center;
styles ["title-1"]
}
Label description_label {
label: "No Description Set";
wrap: true;
justify: center;
styles ["description", "body"]
}
Button button {
label: "No Label Set";
styles ["pill"]
halign: center;
}
}
}

21
src/gtk/loading_status.py Normal file
View File

@@ -0,0 +1,21 @@
from gi.repository import Adw, Gtk, GLib, Gio
from .host_info import HostInfo
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/gtk/loading_status.ui")
class LoadingStatus(Gtk.ScrolledWindow):
__gtype_name__ = 'LoadingStatus'
gtc = Gtk.Template.Child
title_label = gtc()
description_label = gtc()
button = gtc()
def __init__(self, title, description, on_cancel=None, **kwargs):
super().__init__(**kwargs)
self.title_label.set_label(GLib.markup_escape_text(title))
self.description_label.set_label(GLib.markup_escape_text(description))
if on_cancel is None:
self.button.set_visible(False)
else:
self.button.connect("clicked", on_cancel)

View File

@@ -6,6 +6,7 @@ blueprints = custom_target('blueprints',
input: files(
'packages_page/app_row.blp',
'gtk/help-overlay.blp',
'gtk/loading_status.blp',
'main_window/window.blp',
'packages_page/packages_page.blp',
'packages_page/filters_page.blp',
@@ -70,6 +71,7 @@ warehouse_sources = [
'host_info.py',
'gtk/error_toast.py',
'gtk/sidebar_button.py',
'gtk/loading_status.py',
'main_window/window.py',
'packages_page/app_row.py',
'packages_page/uninstall_dialog.py',

View File

@@ -53,29 +53,29 @@ template $PackagesPage : Adw.BreakpointBin {
}
}
Stack status_stack {
Adw.StatusPage loading_packages {
title: _("Loading Packages");
description: _("This should only take a moment");
child:
Spinner {
spinning: true;
}
;
}
// Adw.StatusPage loading_packages {
// title: _("Loading Packages");
// description: _("This should only take a moment");
// child:
// Spinner {
// spinning: true;
// }
// ;
// }
ScrolledWindow scrolled_window {
ListBox packages_list_box {
styles ["navigation-sidebar"]
}
}
Adw.StatusPage uninstalling {
title: _("Uninstalling Packages");
description: _("This should only take a moment");
child:
Spinner {
spinning: true;
}
;
}
// Adw.StatusPage uninstalling {
// title: _("Uninstalling Packages");
// description: _("This should only take a moment");
// child:
// Spinner {
// spinning: true;
// }
// ;
// }
Adw.StatusPage no_filter_results {
title: _("No Packages Match Filters");
description: _("No installed package matches all of the currently applied filters");
@@ -165,4 +165,4 @@ Popover copy_pop {
halign: start;
}
}
}
}

View File

@@ -6,6 +6,7 @@ from .properties_page import PropertiesPage
from .filters_page import FiltersPage
from .sidebar_button import SidebarButton
from .uninstall_dialog import UninstallDialog
from .loading_status import LoadingStatus
import subprocess, os
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/packages_page/packages_page.ui")
@@ -16,8 +17,8 @@ class PackagesPage(Adw.BreakpointBin):
packages_toast_overlay = gtc()
status_stack = gtc()
scrolled_window = gtc()
uninstalling = gtc()
loading_packages = gtc()
# uninstalling = gtc()
# loading_packages = gtc()
no_filter_results = gtc()
reset_filters_button = gtc()
no_packages = gtc()
@@ -303,6 +304,8 @@ class PackagesPage(Adw.BreakpointBin):
# Extra Object Creation
self.main_window = main_window
self.loading_packages = LoadingStatus(_("Loading Packages"), _("This should only take a moment"))
self.uninstalling = LoadingStatus(_("Uninstalling Packages"), _("This should only take a moment"))
self.properties_page = PropertiesPage(main_window, self)
self.filters_page = FiltersPage(main_window, self)
self.filter_settings = Gio.Settings.new("io.github.flattool.Warehouse.filter")
@@ -313,6 +316,8 @@ class PackagesPage(Adw.BreakpointBin):
# Apply
# self.set_status("loading_packages")
self.status_stack.add_child(self.loading_packages)
self.status_stack.add_child(self.uninstalling)
self.packages_list_box.set_filter_func(self.filter_func)
self.packages_list_box.set_sort_func(self.sort_func)
self.content_stack.add_child(self.properties_page)
@@ -332,4 +337,4 @@ class PackagesPage(Adw.BreakpointBin):
self.select_all_button.connect("clicked", self.select_all_handler)
self.copy_menu.connect("row-activated", self.selection_copy)
self.uninstall_button.connect("clicked", self.selection_uninstall)
self.uninstall_button.connect("clicked", self.selection_uninstall)

View File

@@ -3,6 +3,7 @@
<gresource prefix="/io/github/flattool/Warehouse">
<file>../data/style.css</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">gtk/loading_status.ui</file>
<file preprocess="xml-stripblanks">packages_page/app_row.ui</file>
<file preprocess="xml-stripblanks">main_window/window.ui</file>
<file preprocess="xml-stripblanks">packages_page/packages_page.ui</file>