🐛 Fixed UI not updating on some game actions
This commit is contained in:
@@ -17,20 +17,21 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from gi.repository import Adw, Gio, GLib, Gtk
|
from gi.repository import Adw, Gio, GLib, Gtk
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from requests.exceptions import HTTPError, SSLError
|
||||||
|
|
||||||
# TODO use SGDBHelper
|
|
||||||
from src import shared
|
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.utils.create_dialog import create_dialog
|
from src.utils.create_dialog import create_dialog
|
||||||
from src.utils.save_cover import resize_cover, save_cover
|
from src.utils.save_cover import resize_cover, save_cover
|
||||||
from src.utils.steamgriddb import SGDBSave
|
from src.utils.steamgriddb import SGDBError, SGDBHelper
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path=shared.PREFIX + "/gtk/details_window.ui")
|
@Gtk.Template(resource_path=shared.PREFIX + "/gtk/details_window.ui")
|
||||||
@@ -202,9 +203,20 @@ class DetailsWindow(Adw.Window):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.game.save()
|
self.game.save()
|
||||||
|
self.game.update()
|
||||||
|
|
||||||
|
# Try to get a cover if none is present
|
||||||
|
# TODO inform the user
|
||||||
|
# TODO wrap in a task and mark loading
|
||||||
if not self.game_cover.get_pixbuf():
|
if not self.game_cover.get_pixbuf():
|
||||||
SGDBSave({self.game})
|
print("test 1212")
|
||||||
|
sgdb = SGDBHelper()
|
||||||
|
try:
|
||||||
|
sgdb.conditionaly_update_cover(self.game)
|
||||||
|
except SGDBError as error:
|
||||||
|
logging.error("Could not update cover", exc_info=error)
|
||||||
|
except (HTTPError, SSLError, ConnectionError):
|
||||||
|
logging.warning("Could not connect to SteamGridDB")
|
||||||
|
|
||||||
self.game_cover.pictures.remove(self.cover)
|
self.game_cover.pictures.remove(self.cover)
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ class Game(Gtk.Box):
|
|||||||
def launch(self):
|
def launch(self):
|
||||||
self.last_played = int(time())
|
self.last_played = int(time())
|
||||||
self.save()
|
self.save()
|
||||||
|
self.update()
|
||||||
|
|
||||||
string = (
|
string = (
|
||||||
self.executable
|
self.executable
|
||||||
@@ -206,6 +207,7 @@ class Game(Gtk.Box):
|
|||||||
def toggle_hidden(self, toast=True):
|
def toggle_hidden(self, toast=True):
|
||||||
self.hidden = not self.hidden
|
self.hidden = not self.hidden
|
||||||
self.save()
|
self.save()
|
||||||
|
self.update()
|
||||||
|
|
||||||
if self.win.stack.get_visible_child() == self.win.details_view:
|
if self.win.stack.get_visible_child() == self.win.details_view:
|
||||||
self.win.on_go_back_action()
|
self.win.on_go_back_action()
|
||||||
@@ -221,6 +223,7 @@ class Game(Gtk.Box):
|
|||||||
# Add "removed=True" to the game properties so it can be deleted on next init
|
# Add "removed=True" to the game properties so it can be deleted on next init
|
||||||
self.removed = True
|
self.removed = True
|
||||||
self.save()
|
self.save()
|
||||||
|
self.update()
|
||||||
|
|
||||||
if self.win.stack.get_visible_child() == self.win.details_view:
|
if self.win.stack.get_visible_child() == self.win.details_view:
|
||||||
self.win.on_go_back_action()
|
self.win.on_go_back_action()
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
for game in self.removed_games:
|
for game in self.removed_games:
|
||||||
game.removed = False
|
game.removed = False
|
||||||
game.save()
|
game.save()
|
||||||
|
game.update()
|
||||||
|
|
||||||
self.removed_games = set()
|
self.removed_games = set()
|
||||||
self.toast.dismiss()
|
self.toast.dismiss()
|
||||||
@@ -256,6 +257,7 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
|
|
||||||
game.removed = True
|
game.removed = True
|
||||||
game.save()
|
game.save()
|
||||||
|
game.update()
|
||||||
|
|
||||||
if self.win.stack.get_visible_child() == self.win.details_view:
|
if self.win.stack.get_visible_child() == self.win.details_view:
|
||||||
self.win.on_go_back_action()
|
self.win.on_go_back_action()
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
elif undo == "remove":
|
elif undo == "remove":
|
||||||
game.removed = False
|
game.removed = False
|
||||||
game.save()
|
game.save()
|
||||||
|
game.update()
|
||||||
|
|
||||||
self.toasts[(game, undo)].dismiss()
|
self.toasts[(game, undo)].dismiss()
|
||||||
self.toasts.pop((game, undo))
|
self.toasts.pop((game, undo))
|
||||||
|
|||||||
Reference in New Issue
Block a user