diff --git a/src/game.py b/src/game.py index ce76216..25694a9 100644 --- a/src/game.py +++ b/src/game.py @@ -70,9 +70,6 @@ class Game(Gtk.Box): self.update_values(data) - if allow_side_effects: - self.win.games[self.game_id] = self - self.set_play_icon() self.event_contoller_motion = Gtk.EventControllerMotion.new() diff --git a/src/main.py b/src/main.py index 9d5851e..262a1b9 100644 --- a/src/main.py +++ b/src/main.py @@ -56,6 +56,7 @@ class CartridgesApplication(Adw.Application): win = None def __init__(self): + shared.store = Store() super().__init__( 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 ) - # Create the games store ready to load games from disk - if not shared.store: - shared.store = Store() - shared.store.add_manager(FileManager(), False) - shared.store.add_manager(DisplayManager()) - + # Load games from disk + shared.store.add_manager(FileManager(), False) + shared.store.add_manager(DisplayManager()) self.load_games_from_disk() # Add rest of the managers for game imports diff --git a/src/preferences.py b/src/preferences.py index a1251c1..d42443f 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -212,7 +212,7 @@ class PreferencesWindow(Adw.PreferencesWindow): self.toast.dismiss() def remove_all_games(self, *_args): - for game in self.win.games.values(): + for game in shared.store.games.values(): if not game.removed: self.removed_games.add(game) diff --git a/src/store/managers/display_manager.py b/src/store/managers/display_manager.py index c8acf0d..7d3a8f0 100644 --- a/src/store/managers/display_manager.py +++ b/src/store/managers/display_manager.py @@ -17,7 +17,6 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -from src import shared from src.game import Game from src.game_cover import GameCover from src.store.managers.manager import Manager @@ -32,7 +31,6 @@ class DisplayManager(Manager): signals = {"update-ready"} def manager_logic(self, game: Game, _additional_data: dict) -> None: - shared.win.games[game.game_id] = game if game.get_parent(): game.get_parent().get_parent().remove(game) if game.get_parent(): diff --git a/src/window.py b/src/window.py index fd45339..a3d1df4 100644 --- a/src/window.py +++ b/src/window.py @@ -64,7 +64,6 @@ class CartridgesWindow(Adw.ApplicationWindow): hidden_search_entry = Gtk.Template.Child() hidden_search_button = Gtk.Template.Child() - games = {} game_covers = {} toasts = {} active_game = None @@ -118,7 +117,7 @@ class CartridgesWindow(Adw.ApplicationWindow): def set_library_child(self): 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: continue if game.hidden: