Exemplo n.º 1
0
 def on_game_activated(self, view, game_id):
     """Handles view activations (double click, enter press)"""
     if self.service:
         logger.debug("Looking up %s game %s", self.service.id, game_id)
         db_game = games_db.get_game_for_service(self.service.id, game_id)
         if self.service.id == "lutris":
             if not db_game or not db_game["installed"]:
                 self.service.install(game_id)
                 return
             game_id = db_game["id"]
         else:
             if db_game and db_game["installed"]:
                 game_id = db_game["id"]
             else:
                 service_game = ServiceGameCollection.get_game(
                     self.service.id, game_id)
                 if not service_game:
                     logger.error("No game %s found for %s", game_id,
                                  self.service.id)
                     return
                 game_id = self.service.install(service_game)
     if game_id:
         game = Game(game_id)
         if game.is_installed:
             game.emit("game-launch")
         else:
             game.emit("game-install")
Exemplo n.º 2
0
 def on_game_activated(self, view, game_id):
     """Handles view activations (double click, enter press)"""
     if self.service:
         if self.service.id != "lutris":
             db_game = games_db.get_game_for_service(
                 self.service.id, game_id)
             if db_game:
                 game_id = db_game["id"]
             else:
                 db_game = ServiceGameCollection.get_game(
                     self.service.id, game_id)
                 if db_game:
                     game_id = self.service.install(db_game)
                 else:
                     game_id = self.service.install(game_id)
         else:
             db_game = games_db.get_game_by_field(game_id)
             if not db_game:
                 self.service.install(game_id)
                 return
             if db_game["installed"] != 1:
                 self.service.install(game_id)
                 return
             game_id = db_game["id"]
     if game_id:
         game = Game(game_id)
         game.emit("game-launch")
Exemplo n.º 3
0
    def popup_contextual_menu(self, view, event):
        """Contextual menu."""
        if event.button != Gdk.BUTTON_SECONDARY:
            return
        view.current_path = view.get_path_at_pos(event.x, event.y)
        if view.current_path:
            view.select()
            _iter = self.get_model().get_iter(view.current_path[0])
            if not _iter:
                return
            selected_id = self.get_selected_id(_iter)
            game_row = self.game_store.get_row_by_id(selected_id)
            game_id = None
            if self.service:
                game = get_game_for_service(self.service, game_row[COL_ID])
                if game:
                    game_id = game["id"]
            else:
                game_id = game_row[COL_ID]
            if not game_id:
                return
            game = Game(game_id)
            game_actions = GameActions()
            game_actions.set_game(game=game)

            self.contextual_menu.popup(event, game_actions)
Exemplo n.º 4
0
    def __init__(self, db_game, game_actions, application):
        """Create the game bar with a database row"""
        super().__init__(orientation=Gtk.Orientation.VERTICAL,
                         visible=True,
                         margin_top=12,
                         margin_left=12,
                         margin_bottom=12,
                         margin_right=12,
                         spacing=6)
        self.game_start_hook_id = GObject.add_emission_hook(
            Game, "game-start", self.on_game_state_changed)
        self.game_started_hook_id = GObject.add_emission_hook(
            Game, "game-started", self.on_game_state_changed)
        self.game_stopped_hook_id = GObject.add_emission_hook(
            Game, "game-stopped", self.on_game_state_changed)
        self.game_updated_hook_id = GObject.add_emission_hook(
            Game, "game-updated", self.on_game_state_changed)
        self.game_removed_hook_id = GObject.add_emission_hook(
            Game, "game-removed", self.on_game_state_changed)
        self.game_installed_hook_id = GObject.add_emission_hook(
            Game, "game-installed", self.on_game_state_changed)
        self.connect("destroy", self.on_destroy)

        self.set_margin_bottom(12)
        self.game_actions = game_actions
        self.db_game = db_game
        self.service = None
        if db_game.get("service"):
            try:
                self.service = services.SERVICES[db_game["service"]]()
            except KeyError:
                pass

        game_id = None
        if "service_id" in db_game:
            self.appid = db_game["service_id"]
            game_id = db_game["id"]
        elif self.service:
            self.appid = db_game["appid"]
            if self.service.id == "lutris":
                game = get_game_by_field(self.appid, field="slug")
            else:
                game = get_game_for_service(self.service.id, self.appid)
            if game:
                game_id = game["id"]
        if game_id:
            self.game = application.get_game_by_id(game_id) or Game(game_id)
        else:
            self.game = Game()
            self.game.name = db_game["name"]
            self.game.slug = db_game["slug"]
            self.game.appid = self.appid
            self.game.service = self.service.id if self.service else None
        game_actions.set_game(self.game)
        self.update_view()
Exemplo n.º 5
0
 def on_game_activated(self, view, game_id):
     """Handles view activations (double click, enter press)"""
     if self.service:
         db_game = games_db.get_game_for_service(self.service.id, game_id)
         if db_game:
             game_id = db_game["id"]
         else:
             db_game = ServiceGameCollection.get_game(
                 self.service.id, game_id)
             self.service.install(db_game)
             return
     game = Game(game_id)
     if game.is_installed:
         logger.info("Game is installed")
     game.emit("game-launch")
Exemplo n.º 6
0
    def __init__(self, db_game, game_actions, application):
        """Create the game bar with a database row"""
        super().__init__(visible=True)
        GObject.add_emission_hook(Game, "game-start",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-started",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-stopped",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-updated",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-removed",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-installed",
                                  self.on_game_state_changed)

        self.set_margin_bottom(12)
        self.game_actions = game_actions
        self.db_game = db_game
        self.service = None
        if db_game.get("service"):
            try:
                self.service = services.get_services()[db_game["service"]]()
            except KeyError:
                logger.warning("Non existent service '%s'", db_game["service"])

        game_id = None
        if "service_id" in db_game:
            self.appid = db_game["service_id"]
            game_id = db_game["id"]
        elif self.service:
            self.appid = db_game["appid"]
            if self.service.id == "lutris":
                game = get_game_by_field(self.appid, field="slug")
            else:
                game = get_game_for_service(self.service.id, self.appid)
            if game:
                game_id = game["id"]
        if game_id:
            self.game = application.get_game_by_id(game_id) or Game(game_id)
            game_actions.set_game(self.game)
        else:
            self.game = Game()
        self.game_name = db_game["name"]
        self.game_slug = db_game["slug"]
        self.update_view()
Exemplo n.º 7
0
    def __init__(self, db_game, game_actions):
        """Create the game bar with a database row"""
        super().__init__(visible=True)
        GObject.add_emission_hook(Game, "game-start",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-started",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-stopped",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-updated",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-removed",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-installed",
                                  self.on_game_state_changed)

        self.set_margin_bottom(12)
        self.game_actions = game_actions
        self.db_game = db_game
        if db_game.get("service"):
            self.service = services.get_services()[db_game["service"]]()
        else:
            self.service = None
        game_id = None
        if "service_id" in db_game:
            self.appid = db_game["service_id"]
            game_id = db_game["id"]
        elif self.service:
            self.appid = db_game["appid"]
            game = get_game_for_service(self.service.id, self.appid)
            if game:
                game_id = game["id"]
        if game_id:
            self.game = Game(game_id)
        else:
            self.game = Game()
        self.game_name = db_game["name"]
        self.game_slug = db_game["slug"]

        if self.game:
            game_actions.set_game(self.game)
        self.update_view()