Removed win.games

This commit is contained in:
GeoffreyCoulaud
2023-07-01 02:56:40 +02:00
parent b3c2437618
commit 8d082ab158
5 changed files with 6 additions and 14 deletions

View File

@@ -70,9 +70,6 @@ class Game(Gtk.Box):
self.update_values(data) self.update_values(data)
if allow_side_effects:
self.win.games[self.game_id] = self
self.set_play_icon() self.set_play_icon()
self.event_contoller_motion = Gtk.EventControllerMotion.new() self.event_contoller_motion = Gtk.EventControllerMotion.new()

View File

@@ -56,6 +56,7 @@ class CartridgesApplication(Adw.Application):
win = None win = None
def __init__(self): def __init__(self):
shared.store = Store()
super().__init__( super().__init__(
application_id=shared.APP_ID, flags=Gio.ApplicationFlags.FLAGS_NONE application_id=shared.APP_ID, flags=Gio.ApplicationFlags.FLAGS_NONE
) )
@@ -82,12 +83,9 @@ class CartridgesApplication(Adw.Application):
"is-maximized", self.win, "maximized", Gio.SettingsBindFlags.DEFAULT "is-maximized", self.win, "maximized", Gio.SettingsBindFlags.DEFAULT
) )
# Create the games store ready to load games from disk # Load games from disk
if not shared.store: shared.store.add_manager(FileManager(), False)
shared.store = Store() shared.store.add_manager(DisplayManager())
shared.store.add_manager(FileManager(), False)
shared.store.add_manager(DisplayManager())
self.load_games_from_disk() self.load_games_from_disk()
# Add rest of the managers for game imports # Add rest of the managers for game imports

View File

@@ -212,7 +212,7 @@ class PreferencesWindow(Adw.PreferencesWindow):
self.toast.dismiss() self.toast.dismiss()
def remove_all_games(self, *_args): def remove_all_games(self, *_args):
for game in self.win.games.values(): for game in shared.store.games.values():
if not game.removed: if not game.removed:
self.removed_games.add(game) self.removed_games.add(game)

View File

@@ -17,7 +17,6 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from src import shared
from src.game import Game from src.game import Game
from src.game_cover import GameCover from src.game_cover import GameCover
from src.store.managers.manager import Manager from src.store.managers.manager import Manager
@@ -32,7 +31,6 @@ class DisplayManager(Manager):
signals = {"update-ready"} signals = {"update-ready"}
def manager_logic(self, game: Game, _additional_data: dict) -> None: def manager_logic(self, game: Game, _additional_data: dict) -> None:
shared.win.games[game.game_id] = game
if game.get_parent(): if game.get_parent():
game.get_parent().get_parent().remove(game) game.get_parent().get_parent().remove(game)
if game.get_parent(): if game.get_parent():

View File

@@ -64,7 +64,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
hidden_search_entry = Gtk.Template.Child() hidden_search_entry = Gtk.Template.Child()
hidden_search_button = Gtk.Template.Child() hidden_search_button = Gtk.Template.Child()
games = {}
game_covers = {} game_covers = {}
toasts = {} toasts = {}
active_game = None active_game = None
@@ -118,7 +117,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
def set_library_child(self): def set_library_child(self):
child, hidden_child = self.notice_empty, self.hidden_notice_empty child, hidden_child = self.notice_empty, self.hidden_notice_empty
for game in self.games.values(): for game in shared.store.games.values():
if game.removed or game.blacklisted: if game.removed or game.blacklisted:
continue continue
if game.hidden: if game.hidden: