mirror of
https://github.com/lutris/lutris
synced 2024-09-05 23:46:21 +00:00
Improved duplicate-game dialog
Provide a suggested unique name, and also accept 'enter' to close the dialog and make the duplicate.
This commit is contained in:
parent
6cc69c35d3
commit
e7109ec65d
|
@ -292,6 +292,12 @@ class GameActions(BaseGameActions):
|
|||
|
||||
def on_game_duplicate(self, _widget):
|
||||
for game in self.games:
|
||||
for num in range(2, 999):
|
||||
initial_name = game.name + " " + str(num)
|
||||
|
||||
if not get_game_by_field(initial_name, "name"):
|
||||
break
|
||||
|
||||
duplicate_game_dialog = InputDialog(
|
||||
{
|
||||
"parent": self.window,
|
||||
|
@ -301,6 +307,7 @@ class GameActions(BaseGameActions):
|
|||
"Please enter the new name for the copy:"
|
||||
) % gtk_safe(game.name),
|
||||
"title": _("Duplicate game?"),
|
||||
"initial_value": initial_name
|
||||
}
|
||||
)
|
||||
result = duplicate_game_dialog.run()
|
||||
|
|
|
@ -315,14 +315,16 @@ class InputDialog(ModalDialog):
|
|||
self.user_value = ""
|
||||
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||
self.ok_button = self.add_default_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
self.ok_button.set_sensitive(False)
|
||||
self.set_title(dialog_settings["title"])
|
||||
label = Gtk.Label(visible=True)
|
||||
label.set_markup(dialog_settings["question"])
|
||||
self.get_content_area().pack_start(label, True, True, 12)
|
||||
self.entry = Gtk.Entry(visible=True)
|
||||
self.entry = Gtk.Entry(visible=True, activates_default=True)
|
||||
self.entry.connect("changed", self.on_entry_changed)
|
||||
self.get_content_area().pack_start(self.entry, True, True, 12)
|
||||
self.entry.set_text(dialog_settings.get("initial_value") or "")
|
||||
|
||||
def on_entry_changed(self, widget):
|
||||
self.user_value = widget.get_text()
|
||||
|
|
Loading…
Reference in a new issue