Use flatpak info command for the properties window

This commit is contained in:
heliguy
2024-04-02 05:06:20 -04:00
parent b5518e5042
commit c180df4ca1
3 changed files with 67 additions and 23 deletions

View File

@@ -3,7 +3,7 @@ using Adw 1;
template $PropertiesWindow: Adw.Dialog {
content-width: 350;
content-height: 600;
content-height: 999999;
Adw.ToolbarView main_toolbar_view {
[top]
@@ -39,6 +39,32 @@ template $PropertiesWindow: Adw.Dialog {
]
}
Button {
margin-top: 6;
styles [
"title-1",
"flat"
]
Label name {
wrap: true;
}
}
Button {
sensitive: true;
styles [
"title-4",
"flat"
]
Label description {
wrap: true;
}
}
Adw.PreferencesGroup upper {
Adw.ActionRow data_row {
title: _("Loading User Data");

View File

@@ -191,6 +191,31 @@ class myUtils:
sorted_array = sorted(data, key=lambda item: item[0].lower())
return sorted_array
def get_flatpak_info(self, ref, install_type):
output = subprocess.run(
[
"flatpak-spawn", "--host", "sh", "-c",
f"flatpak info {ref} --{install_type}"
],
capture_output=True,
text=True
).stdout
lines = output.strip().split("\n")
columns = lines[0].split("\t")
data = [columns]
for line in lines[1:]:
row = line.split(": ")
for i in range(len(row)):
row[i] = row[i].strip()
data.append(row)
info = {}
info["name"] = data[0][0]
for i in range(2, len(data)):
if data[i][0] == '':
continue
info[data[i][0]] = data[i][1]
return info
def get_dependent_runtimes(self):
paks = self.get_host_flatpaks()
dependent_runtimes = []

View File

@@ -30,6 +30,8 @@ class PropertiesWindow(Adw.Dialog):
eol_app_banner = Gtk.Template.Child()
eol_runtime_banner = Gtk.Template.Child()
mask_banner = Gtk.Template.Child()
description = Gtk.Template.Child()
name = Gtk.Template.Child()
def copy_item(self, to_copy, to_toast=None):
self.get_clipboard().set(to_copy)
@@ -82,31 +84,22 @@ class PropertiesWindow(Adw.Dialog):
self.view_apps.set_visible(True)
def generate_lower(self):
column_headers = [
_("Name"),
_("Description"),
_("App ID"),
_("Version"),
_("Branch"),
_("Arch"),
_("Origin"),
_("Installation"),
_("Ref"),
_("Active Commit"),
_("Latest Commit"),
_("Installed Size"),
_("Options"),
]
for i in range(len(column_headers)):
if self.current_flatpak[i] == "":
info = self.my_utils.get_flatpak_info(self.app_ref, self.install_type)
name_desc = info["name"].split(" - ")
self.name.set_label((name_desc[0]))
try:
self.description.set_label((name_desc[1]))
except:
pass
for key in info.keys():
if key == "name":
continue
row = Adw.ActionRow(
title=column_headers[i], tooltip_text=_("Copy"), activatable=True
title=GLib.markup_escape_text(key),
subtitle=GLib.markup_escape_text(info[key]),
activatable=True,
)
row.add_suffix(Gtk.Image.new_from_icon_name("edit-copy-symbolic"))
row.set_subtitle(GLib.markup_escape_text(self.current_flatpak[i]))
row.add_css_class("property")
row.connect(
"activated",