mirror of
https://github.com/lutris/lutris
synced 2024-09-15 22:09:55 +00:00
Update view when game is updated or removed
This commit is contained in:
parent
a9bb315513
commit
4722fb36a8
|
@ -235,4 +235,4 @@ class GameActions:
|
|||
|
||||
def on_remove_game(self, *_args):
|
||||
"""Callback that present the uninstall dialog to the user"""
|
||||
UninstallGameDialog(game_id=self.game.id, callback=self.window.update_store, parent=self.window)
|
||||
UninstallGameDialog(game_id=self.game.id, parent=self.window)
|
||||
|
|
|
@ -4,7 +4,7 @@ from gi.repository import Gtk, Pango
|
|||
|
||||
from lutris.database.games import get_games
|
||||
from lutris.game import Game
|
||||
from lutris.gui.dialogs import Dialog, NoticeDialog, QuestionDialog
|
||||
from lutris.gui.dialogs import Dialog, QuestionDialog
|
||||
from lutris.util.jobs import AsyncCall
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import gtk_safe, human_size
|
||||
|
@ -12,11 +12,10 @@ from lutris.util.system import get_disk_size, is_removeable, reverse_expanduser
|
|||
|
||||
|
||||
class UninstallGameDialog(Dialog):
|
||||
def __init__(self, game_id, callback, parent=None):
|
||||
def __init__(self, game_id, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.set_size_request(640, 128)
|
||||
self.game = Game(game_id)
|
||||
self.callback = callback
|
||||
self.delete_files = False
|
||||
container = Gtk.VBox(visible=True)
|
||||
self.get_content_area().add(container)
|
||||
|
@ -95,10 +94,5 @@ class UninstallGameDialog(Dialog):
|
|||
self.folder_label.set_markup("Uninstalling game and deleting files...")
|
||||
else:
|
||||
self.folder_label.set_markup("Uninstalling game...")
|
||||
AsyncCall(self.game.remove, self.delete_cb, self.delete_files)
|
||||
|
||||
def delete_cb(self, result, error):
|
||||
if error:
|
||||
logger.error(error)
|
||||
NoticeDialog("Something went wrong while deleting the game")
|
||||
self.game.remove(self.delete_files)
|
||||
self.destroy()
|
||||
|
|
|
@ -119,7 +119,8 @@ class LutrisWindow(Gtk.ApplicationWindow): # pylint: disable=too-many-public-me
|
|||
GObject.add_emission_hook(BaseService, "service-logout", self.on_service_logout)
|
||||
GObject.add_emission_hook(BaseService, "service-games-load", self.on_service_games_updating)
|
||||
GObject.add_emission_hook(BaseService, "service-games-loaded", self.on_service_games_updated)
|
||||
GObject.add_emission_hook(Game, "game-installed", self.on_game_collection_changed)
|
||||
GObject.add_emission_hook(Game, "game-updated", self.on_game_collection_changed)
|
||||
GObject.add_emission_hook(Game, "game-removed", self.on_game_collection_changed)
|
||||
|
||||
def _init_actions(self):
|
||||
Action = namedtuple("Action", ("callback", "type", "enabled", "default", "accel"))
|
||||
|
@ -434,7 +435,6 @@ class LutrisWindow(Gtk.ApplicationWindow): # pylint: disable=too-many-public-me
|
|||
self.game_store.store.clear()
|
||||
for child in self.blank_overlay.get_children():
|
||||
child.destroy()
|
||||
|
||||
games = self.get_games_from_filters()
|
||||
self.view.service = self.service.id if self.service else None
|
||||
GLib.idle_add(self.update_revealer)
|
||||
|
@ -770,6 +770,7 @@ class LutrisWindow(Gtk.ApplicationWindow): # pylint: disable=too-many-public-me
|
|||
"""Simple method used to refresh the view"""
|
||||
logger.debug("Game collection changed")
|
||||
self.emit("view-updated")
|
||||
return True
|
||||
|
||||
def on_game_activated(self, view, game_id):
|
||||
"""Handles view activations (double click, enter press)"""
|
||||
|
|
|
@ -23,7 +23,7 @@ class GameGridView(Gtk.IconView, GameView):
|
|||
self.set_column_spacing(6)
|
||||
self.set_pixbuf_column(COL_ICON)
|
||||
self.set_item_padding(1)
|
||||
self.cell_width = (max(service_media.size[0], self.min_width))
|
||||
self.cell_width = max(service_media.size[0], self.min_width)
|
||||
if hide_text:
|
||||
self.cell_renderer = None
|
||||
else:
|
||||
|
|
|
@ -9,7 +9,6 @@ from gi.repository.GdkPixbuf import Pixbuf
|
|||
from lutris import settings
|
||||
from lutris.database import sql
|
||||
from lutris.database.games import get_games
|
||||
from lutris.game import Game
|
||||
from lutris.gui.views.media_loader import MediaLoader
|
||||
from lutris.gui.views.store_item import StoreItem
|
||||
from lutris.gui.widgets.utils import get_pixbuf
|
||||
|
@ -96,8 +95,6 @@ class GameStore(GObject.Object):
|
|||
self.media_loader = MediaLoader()
|
||||
self.media_loader.connect("icon-loaded", self.on_icon_loaded)
|
||||
|
||||
GObject.add_emission_hook(Game, "game-updated", self.on_game_updated)
|
||||
GObject.add_emission_hook(Game, "game-removed", self.on_game_updated)
|
||||
GObject.add_emission_hook(BaseService, "service-games-loaded", self.on_service_games_updated)
|
||||
|
||||
@property
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
# Standard Library
|
||||
from gettext import gettext as _
|
||||
|
||||
# Third Party Libraries
|
||||
from gi.repository import GObject, Gtk, Pango
|
||||
from gi.repository import Gtk, Pango
|
||||
|
||||
|
||||
class GridViewCellRendererText(Gtk.CellRendererText):
|
||||
|
||||
"""CellRendererText adjusted for grid view display, removes extra padding"""
|
||||
|
||||
def __init__(self, width, *args, **kwargs):
|
||||
|
@ -15,43 +10,4 @@ class GridViewCellRendererText(Gtk.CellRendererText):
|
|||
self.props.wrap_mode = Pango.WrapMode.WORD
|
||||
self.props.xalign = 0.5
|
||||
self.props.yalign = 0
|
||||
self.props.width = width
|
||||
self.props.wrap_width = width
|
||||
|
||||
|
||||
class CellRendererButton(Gtk.CellRenderer):
|
||||
value = GObject.Property(
|
||||
type=str,
|
||||
nick="value",
|
||||
blurb="what data to render",
|
||||
flags=(GObject.PARAM_READWRITE | GObject.PARAM_CONSTRUCT),
|
||||
)
|
||||
|
||||
def __init__(self, layout):
|
||||
Gtk.CellRenderer.__init__(self)
|
||||
self.layout = layout
|
||||
|
||||
@staticmethod
|
||||
def do_get_size(widget, cell_area=None): # pylint: disable=arguments-differ,unused-argument
|
||||
height = 20
|
||||
max_width = 100
|
||||
if cell_area:
|
||||
return (
|
||||
cell_area.x,
|
||||
cell_area.y,
|
||||
max(cell_area.width, max_width),
|
||||
cell_area.height,
|
||||
)
|
||||
return 0, 0, max_width, height
|
||||
|
||||
def do_render(self, cr, widget, bg_area, cell_area, flags): # pylint: disable=arguments-differ,unused-argument
|
||||
context = widget.get_style_context()
|
||||
context.save()
|
||||
context.add_class(Gtk.STYLE_CLASS_BUTTON)
|
||||
self.layout.set_markup(_("Install"))
|
||||
(x, y, w, h) = self.do_get_size(widget, cell_area)
|
||||
h -= 4
|
||||
# Gtk.render_background(context, cr, x, y, w, h)
|
||||
Gtk.render_frame(context, cr, x, y, w - 2, h + 4)
|
||||
Gtk.render_layout(context, cr, x + 10, y, self.layout)
|
||||
context.restore()
|
||||
|
|
Loading…
Reference in a new issue