Separate user and system data dirs for Flatpak
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from itertools import chain
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ class FlatpakSourceIterable(SourceIterable):
|
|||||||
"""Generator method producing games"""
|
"""Generator method producing games"""
|
||||||
|
|
||||||
icon_theme = Gtk.IconTheme.new()
|
icon_theme = Gtk.IconTheme.new()
|
||||||
icon_theme.add_search_path(str(self.source.locations.data["icons"]))
|
icon_theme.add_search_path(str(self.source.locations.system_data["icons"]))
|
||||||
|
icon_theme.add_search_path(str(self.source.locations.user_data["icons"]))
|
||||||
|
|
||||||
blacklist = (
|
blacklist = (
|
||||||
{"hu.kramo.Cartridges", "hu.kramo.Cartridges.Devel"}
|
{"hu.kramo.Cartridges", "hu.kramo.Cartridges.Devel"}
|
||||||
@@ -52,7 +54,10 @@ class FlatpakSourceIterable(SourceIterable):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
for entry in (self.source.locations.data["applications"]).iterdir():
|
for entry in chain(
|
||||||
|
(self.source.locations.system_data["applications"]).iterdir(),
|
||||||
|
(self.source.locations.user_data["applications"]).iterdir(),
|
||||||
|
):
|
||||||
if entry.suffix != ".desktop":
|
if entry.suffix != ".desktop":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -108,7 +113,8 @@ class FlatpakSourceIterable(SourceIterable):
|
|||||||
|
|
||||||
|
|
||||||
class FlatpakLocations(NamedTuple):
|
class FlatpakLocations(NamedTuple):
|
||||||
data: Location
|
system_data: Location
|
||||||
|
user_data: Location
|
||||||
|
|
||||||
|
|
||||||
class FlatpakSource(ExecutableFormatSource):
|
class FlatpakSource(ExecutableFormatSource):
|
||||||
@@ -126,15 +132,21 @@ class FlatpakSource(ExecutableFormatSource):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.locations = FlatpakLocations(
|
self.locations = FlatpakLocations(
|
||||||
Location(
|
Location(
|
||||||
schema_key="flatpak-location",
|
schema_key="flatpak-system-location",
|
||||||
candidates=(
|
candidates=("/var/lib/flatpak/",),
|
||||||
"/var/lib/flatpak/",
|
|
||||||
shared.data_dir / "flatpak",
|
|
||||||
),
|
|
||||||
paths={
|
paths={
|
||||||
"applications": LocationSubPath("exports/share/applications", True),
|
"applications": LocationSubPath("exports/share/applications", True),
|
||||||
"icons": LocationSubPath("exports/share/icons", True),
|
"icons": LocationSubPath("exports/share/icons", True),
|
||||||
},
|
},
|
||||||
invalid_subtitle=Location.DATA_INVALID_SUBTITLE,
|
invalid_subtitle=Location.DATA_INVALID_SUBTITLE,
|
||||||
)
|
),
|
||||||
|
Location(
|
||||||
|
schema_key="flatpak-user-location",
|
||||||
|
candidates=(shared.data_dir / "flatpak",),
|
||||||
|
paths={
|
||||||
|
"applications": LocationSubPath("exports/share/applications", True),
|
||||||
|
"icons": LocationSubPath("exports/share/icons", True),
|
||||||
|
},
|
||||||
|
invalid_subtitle=Location.DATA_INVALID_SUBTITLE,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -95,8 +95,10 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
retroarch_config_file_chooser_button = Gtk.Template.Child()
|
retroarch_config_file_chooser_button = Gtk.Template.Child()
|
||||||
|
|
||||||
flatpak_expander_row = Gtk.Template.Child()
|
flatpak_expander_row = Gtk.Template.Child()
|
||||||
flatpak_data_action_row = Gtk.Template.Child()
|
flatpak_system_data_action_row = Gtk.Template.Child()
|
||||||
flatpak_data_file_chooser_button = Gtk.Template.Child()
|
flatpak_system_data_file_chooser_button = Gtk.Template.Child()
|
||||||
|
flatpak_user_data_action_row = Gtk.Template.Child()
|
||||||
|
flatpak_user_data_file_chooser_button = Gtk.Template.Child()
|
||||||
flatpak_import_launchers_switch = Gtk.Template.Child()
|
flatpak_import_launchers_switch = Gtk.Template.Child()
|
||||||
|
|
||||||
desktop_switch = Gtk.Template.Child()
|
desktop_switch = Gtk.Template.Child()
|
||||||
|
|||||||
@@ -322,10 +322,22 @@ template $PreferencesWindow : Adw.PreferencesWindow {
|
|||||||
icon-name: "flatpak-source-symbolic";
|
icon-name: "flatpak-source-symbolic";
|
||||||
}
|
}
|
||||||
|
|
||||||
Adw.ActionRow flatpak_data_action_row {
|
Adw.ActionRow flatpak_system_data_action_row {
|
||||||
title: _("Install Location");
|
title: _("System Location");
|
||||||
|
|
||||||
Button flatpak_data_file_chooser_button {
|
Button flatpak_system_data_file_chooser_button {
|
||||||
|
icon-name: "folder-symbolic";
|
||||||
|
valign: center;
|
||||||
|
styles [
|
||||||
|
"flat"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Adw.ActionRow flatpak_user_data_action_row {
|
||||||
|
title: _("User Location");
|
||||||
|
|
||||||
|
Button flatpak_user_data_file_chooser_button {
|
||||||
icon-name: "folder-symbolic";
|
icon-name: "folder-symbolic";
|
||||||
valign: center;
|
valign: center;
|
||||||
styles [
|
styles [
|
||||||
|
|||||||
@@ -83,9 +83,12 @@
|
|||||||
<key name="flatpak" type="b">
|
<key name="flatpak" type="b">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="flatpak-location" type="s">
|
<key name="flatpak-system-location" type="s">
|
||||||
<default>"/var/lib/flatpak/"</default>
|
<default>"/var/lib/flatpak/"</default>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="flatpak-user-location" type="s">
|
||||||
|
<default>"~/.local/share/flatpak/"</default>
|
||||||
|
</key>
|
||||||
<key name="flatpak-import-launchers" type="b">
|
<key name="flatpak-import-launchers" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</key>
|
</key>
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
"--filesystem=~/.var/app/com.usebottles.bottles/data/bottles/:ro",
|
"--filesystem=~/.var/app/com.usebottles.bottles/data/bottles/:ro",
|
||||||
"--filesystem=~/.var/app/io.itch.itch/config/itch/:ro",
|
"--filesystem=~/.var/app/io.itch.itch/config/itch/:ro",
|
||||||
"--filesystem=~/.var/app/org.libretro.RetroArch/config/retroarch/:ro",
|
"--filesystem=~/.var/app/org.libretro.RetroArch/config/retroarch/:ro",
|
||||||
"--filesystem=/var/lib/flatpak:ro"
|
"--filesystem=/var/lib/flatpak/app:ro",
|
||||||
|
"--filesystem=/var/lib/flatpak/exports:ro",
|
||||||
|
"--filesystem=xdg-data/flatpak/app:ro",
|
||||||
|
"--filesystem=xdg-data/flatpak/exports:ro"
|
||||||
],
|
],
|
||||||
"cleanup" : [
|
"cleanup" : [
|
||||||
"/include",
|
"/include",
|
||||||
|
|||||||
Reference in New Issue
Block a user