From eee4e3e2f269b6fa1dc5c50ca141b5e1dd3ce33a Mon Sep 17 00:00:00 2001 From: kramo Date: Sun, 14 Apr 2024 12:38:29 +0200 Subject: [PATCH] Style import preferences rows better --- cartridges/preferences.py | 14 +++++++++++--- data/gtk/preferences.blp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/cartridges/preferences.py b/cartridges/preferences.py index f9a6dff..6089259 100644 --- a/cartridges/preferences.py +++ b/cartridges/preferences.py @@ -21,6 +21,7 @@ import logging import re from pathlib import Path from shutil import rmtree +from sys import platform from typing import Any, Callable, Optional from gi.repository import Adw, Gio, GLib, Gtk @@ -330,9 +331,16 @@ class CartridgesPreferences(Adw.PreferencesDialog): ) if not action_row: continue - path = Path(shared.schema.get_string(location.schema_key)).expanduser() - # Remove the path prefix if picked via Flatpak portal - subtitle = re.sub("/run/user/\\d*/doc/.*/", "", str(path)) + + subtitle = str(Path(shared.schema.get_string(location.schema_key))) + + if platform == "linux": + # Remove the path prefix if picked via Flatpak portal + subtitle = re.sub("/run/user/\\d*/doc/.*/", "", subtitle) + + # Replace the home directory with "~" + subtitle = re.sub(f"^{str(shared.home)}", "~", subtitle) + action_row.set_subtitle(subtitle) def resolve_locations(self, source: Source) -> None: diff --git a/data/gtk/preferences.blp b/data/gtk/preferences.blp index 81f8be8..b604515 100644 --- a/data/gtk/preferences.blp +++ b/data/gtk/preferences.blp @@ -144,6 +144,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } } @@ -167,6 +171,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } Adw.SwitchRow lutris_import_steam_switch { @@ -198,6 +206,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } Adw.SwitchRow heroic_import_epic_switch { @@ -237,6 +249,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } } @@ -260,6 +276,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } } @@ -283,6 +303,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } } @@ -306,6 +330,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } } @@ -330,6 +358,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } Adw.ActionRow flatpak_user_data_action_row { @@ -344,6 +376,10 @@ template $CartridgesPreferences: Adw.PreferencesDialog { "flat" ] } + + styles [ + "property" + ] } Adw.SwitchRow flatpak_import_launchers_switch {