mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Implement loading pages and mobile view
This commit is contained in:
@@ -14,129 +14,157 @@ template $SnapshotPage : Adw.BreakpointBin {
|
||||
}
|
||||
}
|
||||
|
||||
Adw.NavigationSplitView split_view {
|
||||
sidebar-width-fraction: 0.5;
|
||||
max-sidebar-width: 999999999;
|
||||
sidebar:
|
||||
Adw.NavigationPage sidebar_navpage {
|
||||
title: _("Snapshots");
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Adw.ToolbarView sidebar_tbv {
|
||||
[top]
|
||||
Adw.HeaderBar header_bar {
|
||||
[start]
|
||||
$SidebarButton {}
|
||||
[start]
|
||||
ToggleButton search_button {
|
||||
icon-name: "loupe-large-symbolic";
|
||||
tooltip-text: _("Search Packages");
|
||||
}
|
||||
[start]
|
||||
Button open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open Snapshots Folder");
|
||||
}
|
||||
[end]
|
||||
Button new_button {
|
||||
icon-name: "plus-large-symbolic";
|
||||
tooltip-text: _("New Snapshot");
|
||||
}
|
||||
[end]
|
||||
ToggleButton select_button {
|
||||
icon-name: "selection-mode-symbolic";
|
||||
tooltip-text: _("Select Packages");
|
||||
}
|
||||
}
|
||||
Stack stack {
|
||||
// Adw.StatusPage loading_snapshots {
|
||||
// title: _("Loading Snapshot");
|
||||
// description: _("This should only take a moment");
|
||||
// child:
|
||||
// Spinner {
|
||||
// spinning: true;
|
||||
// }
|
||||
// ;
|
||||
// }
|
||||
Adw.StatusPage no_snapshots {
|
||||
title: _("No Snapshots");
|
||||
description: _("Create a Snapshot to save the state of any Flatpak application");
|
||||
icon-name: "snapshots-alt-symbolic";
|
||||
Button status_new_button {
|
||||
styles ["suggested-action", "pill"]
|
||||
halign: center;
|
||||
Adw.ButtonContent {
|
||||
Adw.NavigationPage {
|
||||
title: _("Snapshots");
|
||||
Stack status_stack {
|
||||
Adw.NavigationSplitView split_view {
|
||||
sidebar-width-fraction: 0.5;
|
||||
max-sidebar-width: 999999999;
|
||||
sidebar:
|
||||
Adw.NavigationPage sidebar_navpage {
|
||||
title: _("Snapshots");
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Adw.ToolbarView sidebar_tbv {
|
||||
[top]
|
||||
Adw.HeaderBar header_bar {
|
||||
[start]
|
||||
$SidebarButton {}
|
||||
[start]
|
||||
ToggleButton search_button {
|
||||
icon-name: "loupe-large-symbolic";
|
||||
tooltip-text: _("Search Packages");
|
||||
}
|
||||
[start]
|
||||
Button open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open Snapshots Folder");
|
||||
}
|
||||
[end]
|
||||
Button new_button {
|
||||
icon-name: "plus-large-symbolic";
|
||||
label: _("New Snapshot");
|
||||
tooltip-text: _("New Snapshot");
|
||||
}
|
||||
[end]
|
||||
ToggleButton select_button {
|
||||
icon-name: "selection-mode-symbolic";
|
||||
tooltip-text: _("Select Packages");
|
||||
}
|
||||
}
|
||||
}
|
||||
Adw.StatusPage no_results {
|
||||
title: _("No Results Found");
|
||||
description: _("Try a different search");
|
||||
icon-name: "system-search-symbolic";
|
||||
}
|
||||
ScrolledWindow scrolled_window {
|
||||
Box {
|
||||
orientation: vertical;
|
||||
|
||||
Box active_box {
|
||||
orientation: vertical;
|
||||
|
||||
Label {
|
||||
label: _("Active Snapshots");
|
||||
halign: start;
|
||||
styles ["heading"]
|
||||
margin-top: 3;
|
||||
margin-bottom: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
Label {
|
||||
label: _("Snapshots of installed apps");
|
||||
halign: start;
|
||||
styles ["dim-label"]
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
ListBox active_listbox {
|
||||
styles ["navigation-sidebar"]
|
||||
valign: start;
|
||||
}
|
||||
Stack stack {
|
||||
// Adw.StatusPage loading_snapshots {
|
||||
// title: _("Loading Snapshot");
|
||||
// description: _("This should only take a moment");
|
||||
// child:
|
||||
// Spinner {
|
||||
// spinning: true;
|
||||
// }
|
||||
// ;
|
||||
// }
|
||||
Adw.StatusPage no_results {
|
||||
title: _("No Results Found");
|
||||
description: _("Try a different search");
|
||||
icon-name: "system-search-symbolic";
|
||||
}
|
||||
Box leftover_box {
|
||||
orientation: vertical;
|
||||
|
||||
Label {
|
||||
label: _("Leftover Snapshots");
|
||||
halign: start;
|
||||
styles ["heading"]
|
||||
margin-top: 3;
|
||||
margin-bottom: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
Label {
|
||||
label: _("Snapshots of apps that are no longer installed");
|
||||
halign: start;
|
||||
styles ["dim-label"]
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
ListBox leftover_listbox {
|
||||
styles ["navigation-sidebar"]
|
||||
valign: start;
|
||||
ScrolledWindow scrolled_window {
|
||||
Box {
|
||||
orientation: vertical;
|
||||
|
||||
Box active_box {
|
||||
orientation: vertical;
|
||||
|
||||
Label {
|
||||
label: _("Active Snapshots");
|
||||
halign: start;
|
||||
styles ["heading"]
|
||||
margin-top: 3;
|
||||
margin-bottom: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
Label {
|
||||
label: _("Snapshots of installed apps");
|
||||
halign: start;
|
||||
styles ["dim-label"]
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-bottom: 3;
|
||||
wrap: true;
|
||||
}
|
||||
ListBox active_listbox {
|
||||
styles ["navigation-sidebar"]
|
||||
valign: start;
|
||||
}
|
||||
}
|
||||
Box leftover_box {
|
||||
orientation: vertical;
|
||||
|
||||
Label {
|
||||
label: _("Leftover Snapshots");
|
||||
halign: start;
|
||||
styles ["heading"]
|
||||
margin-top: 3;
|
||||
margin-bottom: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
wrap: true;
|
||||
}
|
||||
Label {
|
||||
label: _("Snapshots of apps that are no longer installed");
|
||||
halign: start;
|
||||
styles ["dim-label"]
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-bottom: 3;
|
||||
wrap: true;
|
||||
}
|
||||
ListBox leftover_listbox {
|
||||
styles ["navigation-sidebar"]
|
||||
valign: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
Adw.ToolbarView no_snapshots {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
[start]
|
||||
$SidebarButton {}
|
||||
[start]
|
||||
Button status_open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open Snapshots Folder");
|
||||
}
|
||||
}
|
||||
Adw.ToastOverlay no_snapshots_toast {
|
||||
Adw.StatusPage {
|
||||
title: _("No Snapshots");
|
||||
description: _("Create a Snapshot to save the state of any Flatpak application");
|
||||
icon-name: "snapshots-alt-symbolic";
|
||||
Button status_new_button {
|
||||
styles ["suggested-action", "pill"]
|
||||
halign: center;
|
||||
Adw.ButtonContent {
|
||||
icon-name: "plus-large-symbolic";
|
||||
label: _("New Snapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
Adw.ToolbarView loading_view {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
[start]
|
||||
$SidebarButton {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class LeftoverSnapshotRow(Adw.ActionRow):
|
||||
__gtype_name__ = "LeftoverSnapshotRow"
|
||||
|
||||
def idle_stuff(self):
|
||||
self.set_title(self.folder.split('.')[-1])
|
||||
self.set_title(self.name)
|
||||
icon = Gtk.Image.new_from_icon_name("application-x-executable-symbolic")
|
||||
icon.set_icon_size(Gtk.IconSize.LARGE)
|
||||
self.add_prefix(icon)
|
||||
@@ -20,8 +20,9 @@ class LeftoverSnapshotRow(Adw.ActionRow):
|
||||
def __init__(self, folder, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.set_activatable(True)
|
||||
self.folder = folder
|
||||
self.set_activatable(True)
|
||||
self.name = self.folder.split('.')[-1]
|
||||
self.check_button = Gtk.CheckButton(visible=False)
|
||||
self.check_button.add_css_class("selection-mode")
|
||||
GLib.idle_add(lambda *_: self.idle_stuff())
|
||||
@@ -32,6 +33,7 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
gtc = Gtk.Template.Child
|
||||
|
||||
toast_overlay = gtc()
|
||||
no_snapshots_toast = gtc()
|
||||
active_box = gtc()
|
||||
active_listbox = gtc()
|
||||
leftover_box = gtc()
|
||||
@@ -42,6 +44,10 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
no_results = gtc()
|
||||
scrolled_window = gtc()
|
||||
open_button = gtc()
|
||||
status_open_button = gtc()
|
||||
new_button = gtc()
|
||||
status_stack = gtc()
|
||||
loading_view = gtc()
|
||||
|
||||
# Referred to in the main window
|
||||
# It is used to determine if a new page should be made or not
|
||||
@@ -97,8 +103,8 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
|
||||
if len(self.active_snapshot_paks) > 0:
|
||||
self.active_box.set_visible(True)
|
||||
first_row = self.active_listbox.get_row_at_index(0)
|
||||
self.active_listbox.select_row(first_row)
|
||||
# first_row = self.active_listbox.get_row_at_index(0)
|
||||
# self.active_listbox.select_row(first_row)
|
||||
else:
|
||||
self.active_box.set_visible(False)
|
||||
|
||||
@@ -111,43 +117,55 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
self.leftover_box.set_visible(True)
|
||||
if len(self.active_snapshot_paks) == 0:
|
||||
self.stack.set_visible_child(self.scrolled_window)
|
||||
first_row = self.leftover_listbox.get_row_at_index(0)
|
||||
self.leftover_listbox.select_row(first_row)
|
||||
# first_row = self.leftover_listbox.get_row_at_index(0)
|
||||
# self.leftover_listbox.select_row(first_row)
|
||||
else:
|
||||
self.leftover_box.set_visible(False)
|
||||
|
||||
def active_select_handler(self, listbox, row):
|
||||
def active_select_handler(self, listbox, row, should_show_content=True):
|
||||
self.leftover_listbox.select_row(None)
|
||||
self.list_page.set_snapshots(row.package.info["id"], row.get_title())
|
||||
self.list_page.set_snapshots(row.package.info["id"], row.package.info["name"])
|
||||
self.split_view.set_show_content(should_show_content)
|
||||
|
||||
def leftover_select_handler(self, listbox, row):
|
||||
def leftover_select_handler(self, listbox, row, should_show_content=True):
|
||||
self.active_listbox.select_row(None)
|
||||
self.list_page.set_snapshots(row.folder, row.get_title())
|
||||
self.list_page.set_snapshots(row.folder, row.name)
|
||||
self.split_view.set_show_content(should_show_content)
|
||||
|
||||
def start_loading(self):
|
||||
self.active_box.set_visible(True)
|
||||
self.active_listbox.remove_all()
|
||||
self.leftover_box.set_visible(True)
|
||||
self.leftover_listbox.remove_all()
|
||||
self.stack.set_visible_child(self.loading_snapshots)
|
||||
self.status_stack.set_visible_child(self.loading_view)
|
||||
|
||||
def select_first_row(self):
|
||||
if row := self.active_listbox.get_row_at_index(0):
|
||||
self.active_listbox.select_row(row)
|
||||
self.active_select_handler(None, row, False)
|
||||
elif row := self.leftover_listbox.get_row_at_index(0):
|
||||
self.leftover_listbox.select_row(row)
|
||||
self.leftover_select_handler(None, row, False)
|
||||
|
||||
def end_loading(self):
|
||||
def callback(*args):
|
||||
self.generate_active_list()
|
||||
self.generate_leftover_list()
|
||||
if (not self.active_box.get_visible()) and (not self.leftover_box.get_visible()):
|
||||
GLib.idle_add(lambda *_: self.stack.set_visible_child(self.no_snapshots))
|
||||
GLib.idle_add(lambda *_: self.status_stack.set_visible_child(self.no_snapshots))
|
||||
else:
|
||||
self.select_first_row()
|
||||
GLib.idle_add(lambda *_: self.stack.set_visible_child(self.scrolled_window))
|
||||
GLib.idle_add(lambda *_: self.status_stack.set_visible_child(self.split_view))
|
||||
|
||||
Gio.Task.new(None, None, callback).run_in_thread(self.sort_snapshots)
|
||||
|
||||
def open_snapshots_folder(self, button):
|
||||
def open_snapshots_folder(self, button, overlay):
|
||||
try:
|
||||
Gio.AppInfo.launch_default_for_uri(f"file://{self.snapshots_path}", None)
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Opened snapshots folder")))
|
||||
overlay.add_toast(Adw.Toast.new(_("Opened snapshots folder")))
|
||||
except Exception as e:
|
||||
self.toast_overlay.add_toast(ErrorToast(_("Could not open folder"), str(e)).toast)
|
||||
overlay.add_toast(ErrorToast(_("Could not open folder"), str(e)).toast)
|
||||
|
||||
def __init__(self, main_window, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -155,7 +173,6 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
# Extra Object Creation
|
||||
self.__class__.instance = self
|
||||
self.main_window = main_window
|
||||
self.loading_snapshots = LoadingStatus(_("Loading Snapshots"), _("This should only take a moment"))
|
||||
self.active_snapshot_paks = []
|
||||
# self.active_rows = []
|
||||
self.leftover_snapshots = []
|
||||
@@ -165,8 +182,9 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
# Connections
|
||||
self.active_listbox.connect("row-activated", self.active_select_handler)
|
||||
self.leftover_listbox.connect("row-activated", self.leftover_select_handler)
|
||||
self.open_button.connect("clicked", self.open_snapshots_folder)
|
||||
self.open_button.connect("clicked", self.open_snapshots_folder, self.toast_overlay)
|
||||
self.status_open_button.connect("clicked", self.open_snapshots_folder, self.no_snapshots_toast)
|
||||
|
||||
# Apply
|
||||
self.stack.add_child(self.loading_snapshots)
|
||||
self.loading_view.set_content(LoadingStatus(_("Loading Snapshots"), _("This should only take a moment")))
|
||||
self.split_view.set_content(self.list_page)
|
||||
|
||||
@@ -4,52 +4,44 @@ using Adw 1;
|
||||
template $SnapshotsListPage : Adw.NavigationPage {
|
||||
title: _("Snapshots List");
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Stack stack {
|
||||
Adw.ToolbarView toolbar_view {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
[start]
|
||||
Button open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open Snapshots Folder for this App");
|
||||
}
|
||||
Adw.ToolbarView toolbar_view {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
[start]
|
||||
Button open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open Snapshots Folder for this App");
|
||||
}
|
||||
ScrolledWindow {
|
||||
Adw.Clamp {
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-top: 12;
|
||||
margin-bottom: 12;
|
||||
ListBox listbox {
|
||||
valign: start;
|
||||
selection-mode: none;
|
||||
styles ["boxed-list"]
|
||||
Adw.PreferencesGroup {
|
||||
Adw.ActionRow {title: "test";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[bottom]
|
||||
ActionBar {
|
||||
[center]
|
||||
Button new_button {
|
||||
margin-top: 3;
|
||||
margin-bottom: 3;
|
||||
styles ["pill", "suggested-action"]
|
||||
Adw.ButtonContent {
|
||||
icon-name: "plus-large-symbolic";
|
||||
label: _("New Snapshot");
|
||||
}
|
||||
ScrolledWindow {
|
||||
Adw.Clamp {
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-top: 12;
|
||||
margin-bottom: 12;
|
||||
ListBox listbox {
|
||||
valign: start;
|
||||
selection-mode: none;
|
||||
styles ["boxed-list"]
|
||||
Adw.PreferencesGroup {
|
||||
Adw.ActionRow {title: "test";}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Adw.ToolbarView loading_view {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
show-title: false;
|
||||
[bottom]
|
||||
ActionBar {
|
||||
[center]
|
||||
Button new_button {
|
||||
margin-top: 3;
|
||||
margin-bottom: 3;
|
||||
styles ["pill", "suggested-action"]
|
||||
Adw.ButtonContent {
|
||||
icon-name: "plus-large-symbolic";
|
||||
label: _("New Snapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,7 @@ class SnapshotsListPage(Adw.NavigationPage):
|
||||
__gtype_name__ = "SnapshotsListPage"
|
||||
gtc = Gtk.Template.Child
|
||||
|
||||
stack = gtc()
|
||||
toolbar_view = gtc()
|
||||
loading_view = gtc()
|
||||
listbox = gtc()
|
||||
toast_overlay = gtc()
|
||||
open_button = gtc()
|
||||
@@ -30,14 +28,11 @@ class SnapshotsListPage(Adw.NavigationPage):
|
||||
for i, row in enumerate(self.snapshots_rows):
|
||||
self.listbox.append(row)
|
||||
self.listbox.get_row_at_index(i).set_activatable(False)
|
||||
|
||||
self.stack.set_visible_child(self.toolbar_view)
|
||||
|
||||
def set_snapshots(self, folder, title):
|
||||
if self.current_folder == folder:
|
||||
return
|
||||
|
||||
self.stack.set_visible_child(self.loading_view)
|
||||
|
||||
self.current_folder = folder
|
||||
self.set_title(_("{} Snapshots").format(title))
|
||||
self.snapshots_rows.clear()
|
||||
@@ -69,4 +64,3 @@ class SnapshotsListPage(Adw.NavigationPage):
|
||||
self.open_button.connect("clicked", self.open_snapshots_folder)
|
||||
|
||||
# Apply
|
||||
self.loading_view.set_content(LoadingStatus(_("Loading Snapshots"), _("This should only take a moment")))
|
||||
Reference in New Issue
Block a user