def add_installed_games(self): """Syncs installed Steam games with Lutris""" installed_appids = [] for steamapps_path in self.steamapps_paths: for appmanifest_file in get_appmanifests(steamapps_path): app_manifest_path = os.path.join(steamapps_path, appmanifest_file) app_manifest = AppManifest(app_manifest_path) installed_appids.append(app_manifest.steamid) self.install_from_steam(app_manifest) db_games = get_games(filters={"runner": "steam"}) for db_game in db_games: steam_game = Game(db_game["id"]) appid = steam_game.config.game_level["game"]["appid"] if appid not in installed_appids: steam_game.remove(no_signal=True) db_appids = defaultdict(list) db_games = get_games(filters={"service": "steam"}) for db_game in db_games: db_appids[db_game["service_id"]].append(db_game["id"]) for appid in db_appids: game_ids = db_appids[appid] if len(game_ids) == 1: continue for game_id in game_ids: steam_game = Game(game_id) if not steam_game.playtime: steam_game.remove(no_signal=True) steam_game.delete()
class RemoveGameDialog(Dialog): def __init__(self, game_id, parent=None): super().__init__(parent=parent) self.set_size_request(640, 128) self.game = Game(game_id) container = Gtk.VBox(visible=True) self.get_content_area().add(container) title_label = Gtk.Label(visible=True) title_label.set_line_wrap(True) title_label.set_alignment(0, 0.5) title_label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) title_label.set_markup( _("<span font_desc='14'><b>Remove %s</b></span>") % gtk_safe(self.game.name)) container.pack_start(title_label, False, False, 4) self.delete_label = Gtk.Label(visible=True) self.delete_label.set_alignment(0, 0.5) self.delete_label.set_markup( _("Completely remove %s from the library?\nAll play time will be lost." ) % self.game) container.pack_start(self.delete_label, False, False, 4) button_box = Gtk.HBox(visible=True) button_box.set_margin_top(30) style_context = button_box.get_style_context() style_context.add_class("linked") cancel_button = Gtk.Button(_("Cancel"), visible=True) cancel_button.connect("clicked", self.on_close) button_box.add(cancel_button) self.remove_button = Gtk.Button(_("Remove"), visible=True) self.remove_button.connect("clicked", self.on_remove_clicked) button_box.add(self.remove_button) container.pack_end(button_box, False, False, 0) self.show() def on_close(self, _button): self.destroy() def on_remove_clicked(self, button): button.set_sensitive(False) self.game.delete() self.destroy()