games: Add collection object and model

This commit is contained in:
Jamie Gravendeel
2025-12-06 18:03:45 +01:00
parent fa9b94fd80
commit 27b2745c74
4 changed files with 37 additions and 0 deletions

34
cartridges/collections.py Normal file
View File

@@ -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)

View File

@@ -3,6 +3,7 @@ python.install_sources(
'__init__.py',
'__main__.py',
'application.py',
'collections.py',
'gamepads.py',
'games.py',
),