def on_unhide_game(self, _widget): """Removes a game from the list of hidden games""" game = Game(self.window.view.selected_game.id) # Remove the ID to unhide and save it ignores = pga.get_hidden_ids() ignores.remove(game.id) pga.set_hidden_ids(ignores)
def on_hide_game(self, _widget): """Add a game to the list of hidden games""" game = Game(self.window.view.selected_game.id) # Append the new hidden ID and save it ignores = pga.get_hidden_ids() + [game.id] pga.set_hidden_ids(ignores) # Update the GUI if not self.window.show_hidden_games: self.window.game_store.remove_game(game.id)
def hidden_state_change(self, action, value): """Hides or shows the hidden games""" action.set_state(value) # Add or remove hidden games ignores = pga.get_hidden_ids() settings.write_setting("show_hidden_games", str(self.show_hidden_games).lower(), section="lutris") # If we have to show the hidden games now, we need to add them back to # the view. If we need to hide them, we just remove them from the view if value: self.game_store.add_games_by_ids(ignores) else: for game_id in ignores: self.game_store.remove_game(game_id)
def __init__( self, games, icon_type, filter_installed, sort_key, sort_ascending, show_hidden_games, show_installed_first=False, ): super(GameStore, self).__init__() self.games = games or pga.get_games( show_installed_first=show_installed_first) if not show_hidden_games: # Check if the PGA contains game IDs that the user does not # want to see self.games = [ game for game in self.games if game["id"] not in pga.get_hidden_ids() ] self.search_mode = False self.games_to_refresh = set() self.icon_type = icon_type self.filter_installed = filter_installed self.show_installed_first = show_installed_first self.filter_text = None self.filter_runner = None self.filter_platform = None self.store = Gtk.ListStore( int, str, str, Pixbuf, str, str, str, str, int, str, bool, int, str, float, str, ) sort_col = COL_NAME if show_installed_first: sort_col = COL_INSTALLED self.store.set_sort_column_id(sort_col, Gtk.SortType.DESCENDING) else: self.store.set_sort_column_id(sort_col, Gtk.SortType.ASCENDING) self.prevent_sort_update = False # prevent recursion with signals self.modelfilter = self.store.filter_new() self.modelfilter.set_visible_func(self.filter_view) try: self.modelsort = Gtk.TreeModelSort.sort_new_with_model( self.modelfilter) except AttributeError: # Apparently some API breaking changes on GTK minor versions. self.modelsort = Gtk.TreeModelSort.new_with_model(self.modelfilter) # pylint: disable=no-member # NOQA self.modelsort.connect("sort-column-changed", self.on_sort_column_changed) self.modelsort.set_sort_func(sort_col, sort_func, sort_col) self.sort_view(sort_key, sort_ascending) self.medias = {"banner": {}, "icon": {}} self.banner_misses = set() self.icon_misses = set() self.media_loaded = False self.connect("media-loaded", self.on_media_loaded) self.connect("icon-loaded", self.on_icon_loaded)
def is_game_hidden(game): """Returns whether a game is on the list of hidden games""" return game.id in pga.get_hidden_ids()