Flatpak source cleanups

This commit is contained in:
kramo
2023-06-30 21:13:06 +02:00
parent fccf302c4b
commit 07960182c7
4 changed files with 29 additions and 3 deletions

View File

@@ -216,6 +216,20 @@ template $PreferencesWindow : Adw.PreferencesWindow {
}
}
}
Adw.ExpanderRow flatpak_expander_row {
title: _("Flatpak Games");
show-enable-switch: true;
Adw.ActionRow flatpak_data_action_row {
title: _("Install Location");
Button flatpak_config_file_chooser_button {
icon-name: "folder-symbolic";
valign: center;
}
}
}
}
}

View File

@@ -46,7 +46,7 @@ class FlatpakSourceIterator(SourceIterator):
with entry.open("r", encoding="utf-8") as open_file:
string = open_file.read()
desktop_values = {"Name": None, "Icon": None}
desktop_values = {"Name": None, "Icon": None, "Categories": None}
for key in desktop_values:
if regex := re.findall(f"{key}=(.*)\n", string):
desktop_values[key] = regex[0]
@@ -54,6 +54,12 @@ class FlatpakSourceIterator(SourceIterator):
if not desktop_values["Name"]:
continue
if not desktop_values["Categories"]:
continue
if not "Game" in desktop_values["Categories"].split(";"):
continue
values = {
"source": self.source.id,
"added": added_time,
@@ -67,8 +73,10 @@ class FlatpakSourceIterator(SourceIterator):
additional_data = {}
if icon_name := desktop_values["Icon"]:
if icon_path := IconTheme.getIconPath(icon_name):
if icon_path := IconTheme.getIconPath(icon_name, 512):
additional_data = {"local_image_path": Path(icon_path)}
else:
print(":(")
# Produce game
yield (game, additional_data)

View File

@@ -223,7 +223,7 @@ class CartridgesApplication(Adw.Application):
if shared.schema.get_boolean("bottles"):
importer.add_source(BottlesSource())
if not shared.schema.get_boolean("flatpak"):
if shared.schema.get_boolean("flatpak"):
importer.add_source(FlatpakSource())
if shared.schema.get_boolean("itch"):

View File

@@ -80,6 +80,10 @@ class PreferencesWindow(Adw.PreferencesWindow):
legendary_config_action_row = Gtk.Template.Child()
legendary_config_file_chooser_button = Gtk.Template.Child()
flatpak_expander_row = Gtk.Template.Child()
flatpak_data_action_row = Gtk.Template.Child()
flatpak_config_file_chooser_button = Gtk.Template.Child()
sgdb_key_group = Gtk.Template.Child()
sgdb_key_entry_row = Gtk.Template.Child()
sgdb_switch = Gtk.Template.Child()