mirror of
https://github.com/lutris/lutris
synced 2024-07-20 17:34:34 +00:00
Restore the ability to have single-game category windows (so you can compare side by side).
If you multi-select, we will have a single common multi-category dialog. This can lead to overlap, where a game categories are in two windows. This doesn't seem to cause any real problems. Also, move the game count into a subtitle so it fits better.
This commit is contained in:
parent
c9a2868731
commit
c859f3b7eb
|
@ -159,11 +159,18 @@ class GameActions:
|
|||
|
||||
def on_edit_game_categories(self, _widget):
|
||||
"""Edit game categories"""
|
||||
games = self.get_games()
|
||||
if len(games) == 1:
|
||||
# Individual games get individual separate windows
|
||||
self.application.show_window(EditGameCategoriesDialog, game=games[0], parent=self.window)
|
||||
else:
|
||||
|
||||
def add_games(window):
|
||||
window.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)
|
||||
# Multi-select means a common categories window for all of them; we can wind
|
||||
# up adding games to it if it's already open
|
||||
self.application.show_window(EditGameCategoriesDialog, update_function=add_games, parent=self.window)
|
||||
|
||||
|
||||
class MultiGameActions(GameActions):
|
||||
|
|
|
@ -13,8 +13,10 @@ from lutris.gui.dialogs import QuestionDialog, SavableModelessDialog
|
|||
class EditGameCategoriesDialog(SavableModelessDialog):
|
||||
"""Game category edit dialog."""
|
||||
|
||||
def __init__(self, parent):
|
||||
super().__init__(_("Categories"), parent=parent, border_width=10)
|
||||
def __init__(self, game=None, parent=None):
|
||||
title = game.name if game else _("Categories")
|
||||
|
||||
super().__init__(title, parent=parent, border_width=10)
|
||||
self.set_default_size(350, 250)
|
||||
|
||||
self.category_checkboxes = {}
|
||||
|
@ -31,6 +33,9 @@ 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)
|
||||
|
||||
if game:
|
||||
self.add_games([game])
|
||||
|
||||
self.vbox.show_all()
|
||||
|
||||
def add_games(self, games: Sequence[Game]) -> None:
|
||||
|
@ -61,8 +66,11 @@ class EditGameCategoriesDialog(SavableModelessDialog):
|
|||
if g.id not in self.game_ids:
|
||||
add_game(g)
|
||||
|
||||
title = self.games[0].name if len(self.games) == 1 else _("%d games") % len(self.games)
|
||||
self.set_title(title)
|
||||
if len(self.games) > 1:
|
||||
subtitle = _("%d games") % len(self.games)
|
||||
header_bar = self.get_header_bar()
|
||||
if header_bar:
|
||||
header_bar.set_subtitle(subtitle)
|
||||
|
||||
def _create_category_checkboxes(self):
|
||||
frame = Gtk.Frame()
|
||||
|
@ -70,10 +78,10 @@ class EditGameCategoriesDialog(SavableModelessDialog):
|
|||
|
||||
for category in self.categories:
|
||||
label = category
|
||||
checkbutton_option = Gtk.CheckButton(label)
|
||||
checkbutton_option.connect("toggled", self.on_checkbutton_toggled)
|
||||
self.checkbox_grid.attach_next_to(checkbutton_option, None, Gtk.PositionType.BOTTOM, 3, 1)
|
||||
self.category_checkboxes[category] = checkbutton_option
|
||||
checkbutton = Gtk.CheckButton(label)
|
||||
checkbutton.connect("toggled", self.on_checkbutton_toggled)
|
||||
self.checkbox_grid.attach_next_to(checkbutton, None, Gtk.PositionType.BOTTOM, 3, 1)
|
||||
self.category_checkboxes[category] = checkbutton
|
||||
|
||||
scrolledwindow.add(self.checkbox_grid)
|
||||
frame.add(scrolledwindow)
|
||||
|
|
Loading…
Reference in a new issue