Ejemplo n.º 1
0
 def get_api_games(self):
     """Return games from the lutris API"""
     if not self.filters.get("text"):
         api_games = api.get_bundle("featured")
     else:
         api_games = api.search_games(self.filters["text"])
     return api_games
Ejemplo n.º 2
0
    def update_search_results(self):
        if not self.text_query:
            return
        api_games = api.search_games(self.text_query)
        total_count = api_games.get("count", 0)
        count = len(api_games.get('results', []))

        if not count:
            self.result_label.set_markup(_("No results"))
        elif count == total_count:
            self.result_label.set_markup(_(f"Showing <b>{count}</b> results"))
        else:
            self.result_label.set_markup(
                _(f"<b>{total_count}</b> results, only displaying first {count}"
                  ))
        for row in self.listbox.get_children():
            row.destroy()
        for game in api_games.get("results", []):
            platforms = ",".join(
                gtk_safe(platform["name"]) for platform in game["platforms"])
            year = game['year'] or ""
            if platforms and year:
                platforms = ", " + platforms

            row = self.build_row("", gtk_safe(game['name']),
                                 f"{year}{platforms}")
            row.api_info = game
            self.listbox.add(row)
        self.listbox.show()
Ejemplo n.º 3
0
 def on_game_searched(self, panel, query):
     """Called when the game-searched event is emitted"""
     # logger.info("Searching for :%s" % query)
     self.view.destroy()
     self.game_store = self.get_store(api.search_games(query) if query else None)
     self.game_store.set_icon_type(self.icon_type)
     self.game_store.load(from_search=bool(query))
     self.switch_view(self.get_view_type())
     self.invalidate_game_filter()
     return True
Ejemplo n.º 4
0
 def get_api_games(self):
     """Return games from the lutris API"""
     if not self.filters.get("text"):
         return []
     api_games = api.search_games(self.filters["text"])
     if "icon" in self.icon_type:
         GLib.idle_add(self.load_icons, {g["slug"]: g["icon_url"] for g in api_games}, LutrisIcon)
     else:
         GLib.idle_add(self.load_icons, {g["slug"]: g["banner_url"] for g in api_games}, LutrisBanner)
     return api_games
Ejemplo n.º 5
0
 def search_games(self, query):
     """Search for games from the website API"""
     logger.debug("%s search for :%s", self.search_mode, query)
     self.search_terms = query
     self.view.destroy()
     self.game_store = self.get_store(api.search_games(query) if query else None)
     self.game_store.set_icon_type(self.icon_type)
     self.game_store.load(from_search=bool(query))
     self.game_store.filter_text = self.search_entry.props.text
     self.switch_view(self.get_view_type())
     self.invalidate_game_filter()
Ejemplo n.º 6
0
 def search_games(self, query):
     """Search for games from the website API"""
     logger.debug("%s search for :%s", self.search_mode, query)
     self.search_terms = query
     self.view.destroy()
     self.game_store = self.get_store(api.search_games(query) if query else None)
     self.game_store.set_icon_type(self.icon_type)
     self.game_store.load(from_search=bool(query))
     self.game_store.filter_text = self.search_entry.props.text
     self.switch_view(self.get_view_type())
     self.invalidate_game_filter()
Ejemplo n.º 7
0
 def get_api_games(self):
     """Return games from the lutris API"""
     if not self.filters.get("text"):
         return []
     api_games = api.search_games(self.filters["text"])
     if "icon" in self.icon_type:
         api_field = "icon_url"
         _service_media = LutrisIcon
     else:
         api_field = "banner_url"
         _service_media = LutrisBanner
     AsyncCall(download_icons, self.icons_download_cb,
               {g["slug"]: g[api_field]
                for g in api_games}, _service_media())
     return api_games