mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-15 00:34:42 +09:00
Use flatpak info command for the properties window
This commit is contained in:
@@ -3,7 +3,7 @@ using Adw 1;
|
|||||||
|
|
||||||
template $PropertiesWindow: Adw.Dialog {
|
template $PropertiesWindow: Adw.Dialog {
|
||||||
content-width: 350;
|
content-width: 350;
|
||||||
content-height: 600;
|
content-height: 999999;
|
||||||
|
|
||||||
Adw.ToolbarView main_toolbar_view {
|
Adw.ToolbarView main_toolbar_view {
|
||||||
[top]
|
[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.PreferencesGroup upper {
|
||||||
Adw.ActionRow data_row {
|
Adw.ActionRow data_row {
|
||||||
title: _("Loading User Data");
|
title: _("Loading User Data");
|
||||||
|
|||||||
@@ -191,6 +191,31 @@ class myUtils:
|
|||||||
sorted_array = sorted(data, key=lambda item: item[0].lower())
|
sorted_array = sorted(data, key=lambda item: item[0].lower())
|
||||||
return sorted_array
|
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):
|
def get_dependent_runtimes(self):
|
||||||
paks = self.get_host_flatpaks()
|
paks = self.get_host_flatpaks()
|
||||||
dependent_runtimes = []
|
dependent_runtimes = []
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ class PropertiesWindow(Adw.Dialog):
|
|||||||
eol_app_banner = Gtk.Template.Child()
|
eol_app_banner = Gtk.Template.Child()
|
||||||
eol_runtime_banner = Gtk.Template.Child()
|
eol_runtime_banner = Gtk.Template.Child()
|
||||||
mask_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):
|
def copy_item(self, to_copy, to_toast=None):
|
||||||
self.get_clipboard().set(to_copy)
|
self.get_clipboard().set(to_copy)
|
||||||
if to_toast:
|
if to_toast:
|
||||||
@@ -82,31 +84,22 @@ class PropertiesWindow(Adw.Dialog):
|
|||||||
self.view_apps.set_visible(True)
|
self.view_apps.set_visible(True)
|
||||||
|
|
||||||
def generate_lower(self):
|
def generate_lower(self):
|
||||||
column_headers = [
|
info = self.my_utils.get_flatpak_info(self.app_ref, self.install_type)
|
||||||
_("Name"),
|
name_desc = info["name"].split(" - ")
|
||||||
_("Description"),
|
self.name.set_label((name_desc[0]))
|
||||||
_("App ID"),
|
try:
|
||||||
_("Version"),
|
self.description.set_label((name_desc[1]))
|
||||||
_("Branch"),
|
except:
|
||||||
_("Arch"),
|
pass
|
||||||
_("Origin"),
|
for key in info.keys():
|
||||||
_("Installation"),
|
if key == "name":
|
||||||
_("Ref"),
|
|
||||||
_("Active Commit"),
|
|
||||||
_("Latest Commit"),
|
|
||||||
_("Installed Size"),
|
|
||||||
_("Options"),
|
|
||||||
]
|
|
||||||
|
|
||||||
for i in range(len(column_headers)):
|
|
||||||
if self.current_flatpak[i] == "":
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
row = Adw.ActionRow(
|
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.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.add_css_class("property")
|
||||||
row.connect(
|
row.connect(
|
||||||
"activated",
|
"activated",
|
||||||
|
|||||||
Reference in New Issue
Block a user