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',
),

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="#222" d="M1.5 2h2c.277 0 .5.223.5.5v12c0 .277-.223.5-.5.5h-2a.5.5 0 0 1-.5-.5v-12c0-.277.223-.5.5-.5m4 2h1c.277 0 .5.223.5.5v10c0 .277-.223.5-.5.5h-1a.5.5 0 0 1-.5-.5v-10c0-.277.223-.5.5-.5m3-1h1c.277 0 .5.223.5.5v11c0 .277-.223.5-.5.5h-1a.5.5 0 0 1-.5-.5v-11c0-.277.223-.5.5-.5m2.207-1.54.965-.26a.505.505 0 0 1 .613.355l3.363 12.558a.497.497 0 0 1-.355.61l-.965.261a.506.506 0 0 1-.613-.355L10.352 2.074a.5.5 0 0 1 .355-.613m0 0"/></svg>

After

Width:  |  Height:  |  Size: 534 B

View File

@@ -1,4 +1,5 @@
cartridges/application.py
cartridges/collections.py
cartridges/gamepads.py
cartridges/games.py
cartridges/sources/__init__.py