mirror of
https://github.com/lutris/lutris
synced 2024-10-02 22:14:23 +00:00
Provide a callback to initialize the edit-games-dialog before it is shown, to avoid the checkbox checking animation.
Still can't be an __init__ argument with the games- we need to add games to an already open window.
This commit is contained in:
parent
b24b0b72fc
commit
f861db3c0a
|
@ -159,8 +159,11 @@ class GameActions:
|
|||
|
||||
def on_edit_game_categories(self, _widget):
|
||||
"""Edit game categories"""
|
||||
dlg = self.application.show_window(EditGameCategoriesDialog, parent=self.window)
|
||||
dlg.add_games(self.get_games())
|
||||
|
||||
def add_games(window):
|
||||
window.add_games(self.get_games())
|
||||
|
||||
self.application.show_window(EditGameCategoriesDialog, update_function=add_games, parent=self.window)
|
||||
|
||||
|
||||
class MultiGameActions(GameActions):
|
||||
|
|
|
@ -361,11 +361,12 @@ class Application(Gtk.Application):
|
|||
return kwargs["game"].id
|
||||
return str(kwargs)
|
||||
|
||||
def show_window(self, window_class, **kwargs):
|
||||
def show_window(self, window_class, /, update_function=None, **kwargs):
|
||||
"""Instantiate a window keeping 1 instance max
|
||||
|
||||
Params:
|
||||
window_class (Gtk.Window): class to create the instance from
|
||||
update_function (Callable): Function to initialize or update the window (if possible before being shown)
|
||||
kwargs (dict): Additional arguments to pass to the instanciated window
|
||||
|
||||
Returns:
|
||||
|
@ -374,7 +375,10 @@ class Application(Gtk.Application):
|
|||
window_key = str(window_class.__name__) + self.get_window_key(**kwargs)
|
||||
if self.app_windows.get(window_key):
|
||||
self.app_windows[window_key].present()
|
||||
return self.app_windows[window_key]
|
||||
window_inst = self.app_windows[window_key]
|
||||
if update_function:
|
||||
update_function(window_inst)
|
||||
return window_inst
|
||||
if issubclass(window_class, Gtk.Dialog):
|
||||
if "parent" in kwargs:
|
||||
window_inst = window_class(**kwargs)
|
||||
|
@ -384,6 +388,8 @@ class Application(Gtk.Application):
|
|||
else:
|
||||
window_inst = window_class(application=self, **kwargs)
|
||||
window_inst.connect("destroy", self.on_app_window_destroyed, self.get_window_key(**kwargs))
|
||||
if update_function:
|
||||
update_function(window_inst)
|
||||
self.app_windows[window_key] = window_inst
|
||||
logger.debug("Showing window %s", window_key)
|
||||
window_inst.show()
|
||||
|
|
|
@ -31,7 +31,7 @@ class EditGameCategoriesDialog(SavableModelessDialog):
|
|||
self.vbox.pack_start(self._create_category_checkboxes(), True, True, 0)
|
||||
self.vbox.pack_start(self._create_add_category(), False, False, 0)
|
||||
|
||||
self.show_all()
|
||||
self.vbox.show_all()
|
||||
|
||||
def add_games(self, games: Sequence[Game]) -> None:
|
||||
def mark_category_checkbox(checkbox, included):
|
||||
|
|
Loading…
Reference in a new issue