games: Add collection object and model
This commit is contained in:
34
cartridges/collections.py
Normal file
34
cartridges/collections.py
Normal 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)
|
||||||
@@ -3,6 +3,7 @@ python.install_sources(
|
|||||||
'__init__.py',
|
'__init__.py',
|
||||||
'__main__.py',
|
'__main__.py',
|
||||||
'application.py',
|
'application.py',
|
||||||
|
'collections.py',
|
||||||
'gamepads.py',
|
'gamepads.py',
|
||||||
'games.py',
|
'games.py',
|
||||||
),
|
),
|
||||||
|
|||||||
1
data/icons/collection-symbolic.svg
Normal file
1
data/icons/collection-symbolic.svg
Normal 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 |
@@ -1,4 +1,5 @@
|
|||||||
cartridges/application.py
|
cartridges/application.py
|
||||||
|
cartridges/collections.py
|
||||||
cartridges/gamepads.py
|
cartridges/gamepads.py
|
||||||
cartridges/games.py
|
cartridges/games.py
|
||||||
cartridges/sources/__init__.py
|
cartridges/sources/__init__.py
|
||||||
|
|||||||
Reference in New Issue
Block a user