Add ability to open runtime properties from app properties

This commit is contained in:
heliguy
2024-07-07 22:24:04 -04:00
parent 3dd63b9d90
commit e297fb3723
3 changed files with 263 additions and 245 deletions

View File

@@ -46,7 +46,7 @@ class PackagesPage(Adw.BreakpointBin):
def row_select_handler(self, list_box, row):
self.properties_page.set_properties(row.package)
# if self.packages_split.get_collapsed():
self.properties_page.nav_view.pop()
self.packages_split.set_show_content(True)
def filter_func(self, row):

View File

@@ -2,252 +2,255 @@ using Gtk 4.0;
using Adw 1;
template $PropertiesPage : Adw.NavigationPage {
title: "Properties";
Adw.ToastOverlay toast_overlay {
Adw.ToolbarView {
[top]
Adw.HeaderBar header_bar {
show-title: false;
[end]
MenuButton more_menu {
icon-name: "view-more-symbolic";
popover:
Popover {
styles ["menu"]
ListBox more_list {
ListBoxRow details {
Label {
label: _("Show Details in Store");
}
}
ListBoxRow reinstall {
Label {
label: _("Reinstall");
}
}
ListBoxRow copy_launch {
Label {
label: _("Copy Launch Command");
}
}
ListBoxRow view_snapshots {
Label {
label: _("View Snapshots");
}
}
}
}
;
}
}
ScrolledWindow scrolled_window {
Adw.Clamp {
Box {
margin-start: 12;
margin-end: 12;
margin-bottom: 12;
orientation: vertical;
halign: fill;
hexpand: true;
Image app_icon {
pixel-size: 100;
margin-top: 6;
margin-bottom: 18;
icon-name: "application-x-executable-symbolic";
styles["icon-dropshadow"]
}
Label name {
styles ["title-1"]
selectable: true;
wrap: true;
wrap-mode: word_char;
justify: center;
margin-bottom: 12;
margin-start: 6;
margin-end: 6;
}
Label description {
styles ["title-4"]
selectable: true;
wrap: true;
wrap-mode: word_char;
justify: center;
margin-start: 6;
margin-end: 6;
}
Box {
spacing: 6;
homogeneous: true;
margin-top: 18;
margin-bottom: 12;
halign: center;
Button open_app_button {
styles ["suggested-action", "pill"]
can-shrink: true;
label: _("Open");
}
Button uninstall_button {
styles ["pill"]
can-shrink: true;
label: _("Uninstall");
}
}
Box eol_box {
margin-bottom: 12;
styles ["card"]
Label status_label {
margin-top: 6;
margin-bottom: 7;
margin-start: 6;
margin-end: 6;
label: _("This package is End Of Life, and will not recieve any security updates");
styles ["heading", "error"]
halign: center;
hexpand: true;
wrap: true;
justify: center;
}
}
Box information {
orientation: vertical;
Adw.PreferencesGroup actions {
margin-bottom: 12;
Adw.ActionRow data_row {
title: _("User Data");
styles["property"]
[suffix]
Button open_data_button {
styles["flat"]
valign: center;
icon-name: "folder-open-symbolic";
tooltip-text: _("Open User Data");
}
[suffix]
Button trash_data_button {
styles["flat"]
valign: center;
icon-name: "user-trash-symbolic";
tooltip-text: _("Trash User Data");
}
[suffix]
Spinner data_spinner {
spinning: true;
}
}
Adw.ExpanderRow version_row {
title: _("Version");
styles ["property"]
[suffix]
Label mask_label {
label: _("Updates Disabled");
styles["warning"]
}
Adw.SwitchRow mask_row {
title: _("Disable Updates");
subtitle: _("Mask this package so it's never updated");
}
Adw.ActionRow downgrade_row {
title: _("Change Version");
subtitle: _("Upgrade or downgrade this package");
activatable: true;
Image {
icon-name: "right-large-symbolic";
title: "Outer Page";
Adw.NavigationView nav_view {
Adw.NavigationPage inner_nav_page {
title: "Inner Page";
Adw.ToastOverlay toast_overlay {
Adw.ToolbarView {
[top]
Adw.HeaderBar header_bar {
show-title: false;
[end]
MenuButton more_menu {
icon-name: "view-more-symbolic";
popover:
Popover {
styles ["menu"]
ListBox more_list {
ListBoxRow details {
Label {
label: _("Show Details in Store");
}
}
ListBoxRow reinstall {
Label {
label: _("Reinstall");
}
}
ListBoxRow copy_launch {
Label {
label: _("Copy Launch Command");
}
}
ListBoxRow view_snapshots {
Label {
label: _("View Snapshots");
}
}
}
}
Adw.ActionRow installed_size_row {
styles ["property"]
title: _("Installed Size");
;
}
}
ScrolledWindow scrolled_window {
Adw.Clamp {
Box {
margin-start: 12;
margin-end: 12;
margin-bottom: 12;
orientation: vertical;
halign: fill;
hexpand: true;
Image app_icon {
pixel-size: 100;
margin-top: 6;
margin-bottom: 18;
icon-name: "application-x-executable-symbolic";
styles["icon-dropshadow"]
}
Adw.ActionRow runtime_row {
styles ["property"]
title: _("Runtime");
activatable: true;
Image eol_package_package_status_icon {
icon-name: "error-symbolic";
tooltip-text: _("This package is End Of Life, and will not recieve any security updates");
Label name {
styles ["title-1"]
wrap: true;
wrap-mode: word_char;
justify: center;
margin-bottom: 12;
margin-start: 6;
margin-end: 6;
}
Label description {
styles ["title-4"]
wrap: true;
wrap-mode: word_char;
justify: center;
margin-start: 6;
margin-end: 6;
}
Box {
spacing: 6;
homogeneous: true;
margin-top: 18;
margin-bottom: 12;
halign: center;
Button open_app_button {
styles ["suggested-action", "pill"]
can-shrink: true;
label: _("Open");
}
Button uninstall_button {
styles ["pill"]
can-shrink: true;
label: _("Uninstall");
}
}
Box eol_box {
margin-bottom: 12;
styles ["card"]
Label status_label {
margin-top: 6;
margin-bottom: 7;
margin-start: 6;
margin-end: 6;
styles["error"]
}
Image {
icon-name: "right-large-symbolic";
label: _("This package is End Of Life, and will not recieve any security updates");
styles ["heading", "error"]
halign: center;
hexpand: true;
wrap: true;
justify: center;
}
}
Adw.SwitchRow pin_row {
title: _("Disable Automactic Removal");
subtitle: _("Pin this runtime to keep it installed");
}
}
Adw.PreferencesGroup package_info {
margin-bottom: 12;
title: _("Package Information");
Adw.ActionRow id_row {
styles ["property"]
title: _("Application ID");
}
Adw.ActionRow ref_row {
styles ["property"]
title: "Ref";
}
Adw.ActionRow arch_row {
styles ["property"]
title: _("Architecture");
}
Adw.ActionRow branch_row {
styles ["property"]
title: _("Branch");
}
Adw.ActionRow license_row {
styles ["property"]
title: _("License");
}
}
Adw.PreferencesGroup remote_info {
margin-bottom: 12;
title: _("Installation Information");
Adw.ActionRow sdk_row {
styles ["property"]
title: "SDK";
}
Adw.ActionRow origin_row {
styles ["property"]
title: _("Origin");
}
Adw.ActionRow collection_row {
styles ["property"]
title: _("Collection");
}
Adw.ActionRow installation_row {
styles ["property"]
title: _("Installation");
}
}
Adw.PreferencesGroup commit_info {
title: _("Commit Information");
Adw.ActionRow commit_row {
styles ["property"]
title: "Commit";
}
Adw.ActionRow parent_row {
styles ["property"]
title: _("Parent");
}
Adw.ActionRow subject_row {
styles ["property"]
title: _("Subject");
}
Adw.ActionRow date_row {
styles ["property"]
title: _("Date");
Box information {
orientation: vertical;
Adw.PreferencesGroup actions {
margin-bottom: 12;
Adw.ActionRow data_row {
title: _("User Data");
styles["property"]
[suffix]
Button open_data_button {
styles["flat"]
valign: center;
icon-name: "folder-open-symbolic";
tooltip-text: _("Open User Data");
}
[suffix]
Button trash_data_button {
styles["flat"]
valign: center;
icon-name: "user-trash-symbolic";
tooltip-text: _("Trash User Data");
}
[suffix]
Spinner data_spinner {
spinning: true;
}
}
Adw.ExpanderRow version_row {
title: _("Version");
styles ["property"]
[suffix]
Label mask_label {
label: _("Updates Disabled");
styles["warning"]
}
Adw.SwitchRow mask_row {
title: _("Disable Updates");
subtitle: _("Mask this package so it's never updated");
}
Adw.ActionRow downgrade_row {
title: _("Change Version");
subtitle: _("Upgrade or downgrade this package");
activatable: true;
Image {
icon-name: "right-large-symbolic";
}
}
}
Adw.ActionRow installed_size_row {
styles ["property"]
title: _("Installed Size");
}
Adw.ActionRow runtime_row {
styles ["property"]
title: _("Runtime");
activatable: true;
Image eol_package_package_status_icon {
icon-name: "error-symbolic";
tooltip-text: _("This package is End Of Life, and will not recieve any security updates");
margin-end: 6;
styles["error"]
}
Image {
icon-name: "right-large-symbolic";
}
}
Adw.SwitchRow pin_row {
title: _("Disable Automactic Removal");
subtitle: _("Pin this runtime to keep it installed");
}
}
Adw.PreferencesGroup package_info {
margin-bottom: 12;
title: _("Package Information");
Adw.ActionRow id_row {
styles ["property"]
title: _("Application ID");
}
Adw.ActionRow ref_row {
styles ["property"]
title: "Ref";
}
Adw.ActionRow arch_row {
styles ["property"]
title: _("Architecture");
}
Adw.ActionRow branch_row {
styles ["property"]
title: _("Branch");
}
Adw.ActionRow license_row {
styles ["property"]
title: _("License");
}
}
Adw.PreferencesGroup remote_info {
margin-bottom: 12;
title: _("Installation Information");
Adw.ActionRow sdk_row {
styles ["property"]
title: "SDK";
}
Adw.ActionRow origin_row {
styles ["property"]
title: _("Origin");
}
Adw.ActionRow collection_row {
styles ["property"]
title: _("Collection");
}
Adw.ActionRow installation_row {
styles ["property"]
title: _("Installation");
}
}
Adw.PreferencesGroup commit_info {
title: _("Commit Information");
Adw.ActionRow commit_row {
styles ["property"]
title: "Commit";
}
Adw.ActionRow parent_row {
styles ["property"]
title: _("Parent");
}
Adw.ActionRow subject_row {
styles ["property"]
title: _("Subject");
}
Adw.ActionRow date_row {
styles ["property"]
title: _("Date");
}
}
}
}
}

View File

@@ -6,6 +6,8 @@ import subprocess, os
class PropertiesPage(Adw.NavigationPage):
__gtype_name__ = 'PropertiesPage'
gtc = Gtk.Template.Child
nav_view = gtc()
inner_nav_page = gtc()
toast_overlay = gtc()
header_bar = gtc()
scrolled_window = gtc()
@@ -50,12 +52,19 @@ class PropertiesPage(Adw.NavigationPage):
def set_properties(self, package, refresh=False):
if package == self.package and not refresh:
# Do not update the ui if the same app row is clicked
print("skip")
return
self.package = package
self.set_title(_("{} Properties").format(package.info["name"]))
self.name.set_label(package.info["name"])
pkg_name = package.info["name"]
if pkg_name != "":
self.inner_nav_page.set_title(_("{} Properties").format(package.info["name"]))
self.name.set_visible(True)
self.name.set_label(pkg_name)
else:
self.name.set_visible(False)
self.inner_nav_page.set_title(_("Properties"))
pkg_description = package.info["description"]
self.description.set_visible(pkg_description != "")
self.description.set_label(pkg_description)
@@ -138,6 +147,11 @@ class PropertiesPage(Adw.NavigationPage):
except Exception as e:
self.toast_overlay.add_toast(ErrorToast(_("Could not trash data"), str(e)).toast)
def runtime_row_click_handler(self, *args):
new_page = self.__class__(self.main_window)
new_page.set_properties(self.package.dependant_runtime)
self.nav_view.push(new_page)
def __init__(self, main_window, **kwargs):
super().__init__(**kwargs)
@@ -167,4 +181,5 @@ class PropertiesPage(Adw.NavigationPage):
# Connections
self.open_data_button.connect("clicked", self.open_data_handler)
self.scrolled_window.get_vadjustment().connect("value-changed", lambda adjustment: self.header_bar.set_show_title(not adjustment.get_value() == 0))
self.trash_data_button.connect("clicked", self.trash_data_handler)
self.trash_data_button.connect("clicked", self.trash_data_handler)
self.runtime_row.connect("activated", self.runtime_row_click_handler)