Exemple #1
0
 def on_browse_files(self, _widget):
     """Callback to open a game folder in the file browser"""
     path = self.game.get_browse_dir()
     if path and os.path.exists(path):
         open_uri("file://%s" % path)
     else:
         dialogs.NoticeDialog("Can't open %s \nThe folder doesn't exist." %
                              path)
 def on_browse_files(self, _widget):
     """Callback to open a game folder in the file browser"""
     path = self.game.get_browse_dir()
     if not path:
         dialogs.NoticeDialog("This game has no installation directory")
     elif path_exists(path):
         open_uri("file://%s" % path)
     else:
         dialogs.NoticeDialog("Can't open %s \nThe folder doesn't exist." %
                              path)
Exemple #3
0
 def on_open_downloads_clicked(_widget):
     open_uri("http://lutris.net")
Exemple #4
0
 def on_folder_clicked(_widget):
     open_uri("file://" + settings.RUNNER_DIR)
Exemple #5
0
 def on_view_game(self, _widget):
     """Callback to open a game on lutris.net"""
     open_uri("https://lutris.net/games/%s" % self.game.slug)
    def _init_actions(self):
        Action = namedtuple(
            "Action", ("callback", "type", "enabled", "default", "accel"))
        Action.__new__.__defaults__ = (None, None, True, None, None)

        actions = {
            "browse-games":
            Action(lambda *x: open_uri("https://lutris.net/games/")),
            "register-account":
            Action(lambda *x: open_uri("https://lutris.net/user/register/")),
            "disconnect":
            Action(self.on_disconnect),
            "connect":
            Action(self.on_connect),
            "synchronize":
            Action(lambda *x: self.sync_library()),
            "sync-local":
            Action(lambda *x: self.open_sync_dialog()),
            "add-game":
            Action(self.on_add_game_button_clicked),
            "preferences":
            Action(self.on_preferences_activate),
            "manage-runners":
            Action(self.on_manage_runners),
            "about":
            Action(self.on_about_clicked),
            "show-installed-only":
            Action(
                self.on_show_installed_state_change,
                type="b",
                default=self.filter_installed,
                accel="<Primary>h",
            ),
            "show-installed-first":
            Action(
                self.on_show_installed_first_state_change,
                type="b",
                default=self.show_installed_first,
            ),
            "toggle-viewtype":
            Action(self.on_toggle_viewtype),
            "icon-type":
            Action(self.on_icontype_state_change,
                   type="s",
                   default=self.icon_type),
            "view-sorting":
            Action(self.on_view_sorting_state_change,
                   type="s",
                   default=self.view_sorting),
            "view-sorting-ascending":
            Action(
                self.on_view_sorting_direction_change,
                type="b",
                default=self.view_sorting_ascending,
            ),
            "use-dark-theme":
            Action(self.on_dark_theme_state_change,
                   type="b",
                   default=self.use_dark_theme),
            "show-tray-icon":
            Action(self.on_tray_icon_toggle,
                   type="b",
                   default=self.show_tray_icon),
            "show-side-bar":
            Action(
                self.on_sidebar_state_change,
                type="b",
                default=self.sidebar_visible,
                accel="F9",
            ),
        }

        self.actions = {}
        app = self.props.application
        for name, value in actions.items():
            if not value.type:
                action = Gio.SimpleAction.new(name)
                action.connect("activate", value.callback)
            else:
                default_value = None
                param_type = None
                if value.default is not None:
                    default_value = GLib.Variant(value.type, value.default)
                if value.type != "b":
                    param_type = default_value.get_type()
                action = Gio.SimpleAction.new_stateful(name, param_type,
                                                       default_value)
                action.connect("change-state", value.callback)
            self.actions[name] = action
            if value.enabled is False:
                action.props.enabled = False
            self.add_action(action)
            if value.accel:
                app.add_accelerator(value.accel, "win." + name)
Exemple #7
0
 def on_view_game(self, _widget):
     """Callback to open a game on lutris.net"""
     game = Game(self.view.selected_game)
     open_uri("https://lutris.net/games/%s" % game.slug)