Get game from running games by default in game bar

This commit is contained in:
Mathieu Comandon 2020-10-18 21:38:02 -07:00
parent 3dc30a0ec2
commit 3d79919f72
3 changed files with 4 additions and 4 deletions

View file

@ -500,7 +500,7 @@ class Application(Gtk.Application):
def get_game_by_id(self, game_id):
for i in range(self.running_games.get_n_items()):
game = self.running_games.get_item(i)
if str(game.id) == game_id:
if str(game.id) == str(game_id):
return game
return None

View file

@ -432,7 +432,7 @@ class LutrisWindow(Gtk.ApplicationWindow): # pylint: disable=too-many-public-me
if game:
if self.game_bar:
self.game_bar.destroy()
self.game_bar = GameBar(game, self.game_actions)
self.game_bar = GameBar(game, self.game_actions, self.application)
self.revealer_box.pack_start(self.game_bar, True, True, 0)
elif self.game_bar:
self.game_bar.destroy()

View file

@ -13,7 +13,7 @@ from lutris.util.strings import gtk_safe
class GameBar(Gtk.Fixed):
play_button_position = (12, 42)
def __init__(self, db_game, game_actions):
def __init__(self, db_game, game_actions, application):
"""Create the game bar with a database row"""
super().__init__(visible=True)
GObject.add_emission_hook(Game, "game-start", self.on_game_state_changed)
@ -40,7 +40,7 @@ class GameBar(Gtk.Fixed):
if game:
game_id = game["id"]
if game_id:
self.game = Game(game_id)
self.game = application.get_game_by_id(game_id) or Game(game_id)
game_actions.set_game(self.game)
else:
self.game = Game()