From 27b2745c74e14cc8007aad9b3a25bfcad835a9b6 Mon Sep 17 00:00:00 2001 From: Jamie Gravendeel Date: Sat, 6 Dec 2025 18:03:45 +0100 Subject: [PATCH] games: Add collection object and model --- cartridges/collections.py | 34 ++++++++++++++++++++++++++++++ cartridges/meson.build | 1 + data/icons/collection-symbolic.svg | 1 + po/POTFILES.in | 1 + 4 files changed, 37 insertions(+) create mode 100644 cartridges/collections.py create mode 100644 data/icons/collection-symbolic.svg diff --git a/cartridges/collections.py b/cartridges/collections.py new file mode 100644 index 0000000..5564106 --- /dev/null +++ b/cartridges/collections.py @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: Copyright 2025 Jamie Gravendeel + +from typing import Any + +from gi.repository import Gio, GObject + + +class Collection(GObject.Object): + """Collection data class.""" + + __gtype_name__ = __qualname__ + + name = GObject.Property(type=str) + icon = GObject.Property(type=str, default="collection") + game_ids = GObject.Property(type=object) + removed = GObject.Property(type=bool, default=False) + + icon_name = GObject.Property(type=str) + + def __init__(self, **kwargs: Any): + super().__init__(**kwargs) + + self.game_ids = [] + self.bind_property( + "icon", + self, + "icon-name", + GObject.BindingFlags.SYNC_CREATE, + lambda _, name: f"{name}-symbolic", + ) + + +model = Gio.ListStore.new(Collection) diff --git a/cartridges/meson.build b/cartridges/meson.build index d16f82f..e9f78fd 100644 --- a/cartridges/meson.build +++ b/cartridges/meson.build @@ -3,6 +3,7 @@ python.install_sources( '__init__.py', '__main__.py', 'application.py', + 'collections.py', 'gamepads.py', 'games.py', ), diff --git a/data/icons/collection-symbolic.svg b/data/icons/collection-symbolic.svg new file mode 100644 index 0000000..b50f5b0 --- /dev/null +++ b/data/icons/collection-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/po/POTFILES.in b/po/POTFILES.in index 47b0c73..c5dd04f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,4 +1,5 @@ cartridges/application.py +cartridges/collections.py cartridges/gamepads.py cartridges/games.py cartridges/sources/__init__.py