示例#1
0
    def __init__(self):
        super().__init__(
            application_id="net.lutris.Lutris",
            flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
        )
        init_lutris()
        gettext.bindtextdomain("lutris", "/usr/share/locale")
        gettext.textdomain("lutris")

        GLib.set_application_name(_("Lutris"))
        self.running_games = Gio.ListStore.new(Game)
        self.window = None
        self.tray = None
        self.css_provider = Gtk.CssProvider.new()
        self.run_in_background = False

        if os.geteuid() == 0:
            ErrorDialog(
                "Running Lutris as root is not recommended and may cause unexpected issues"
            )

        try:
            self.css_provider.load_from_path(
                os.path.join(datapath.get(), "ui", "lutris.css"))
        except GLib.Error as e:
            logger.exception(e)

        if hasattr(self, "add_main_option"):
            self.add_arguments()
        else:
            ErrorDialog(
                "Your Linux distribution is too old. Lutris won't function properly."
            )
示例#2
0
    def __init__(self):
        super().__init__(
            application_id="net.lutris.Lutris",
            flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
        )

        GObject.add_emission_hook(Game, "game-launch", self.on_game_launch)
        GObject.add_emission_hook(Game, "game-start", self.on_game_start)
        GObject.add_emission_hook(Game, "game-stop", self.on_game_stop)
        GObject.add_emission_hook(Game, "game-install", self.on_game_install)

        GLib.set_application_name(_("Lutris"))
        self.window = None

        self.running_games = Gio.ListStore.new(Game)
        self.app_windows = {}
        self.tray = None
        self.css_provider = Gtk.CssProvider.new()
        self.run_in_background = False

        if os.geteuid() == 0:
            ErrorDialog(_("Running Lutris as root is not recommended and may cause unexpected issues"))

        try:
            self.css_provider.load_from_path(os.path.join(datapath.get(), "ui", "lutris.css"))
        except GLib.Error as e:
            logger.exception(e)

        if hasattr(self, "add_main_option"):
            self.add_arguments()
        else:
            ErrorDialog(_("Your Linux distribution is too old. Lutris won't function properly."))
示例#3
0
 def is_valid(self):
     if not self.runner_name:
         ErrorDialog(_("Runner not provided"))
         return False
     if not self.name_entry.get_text():
         ErrorDialog(_("Please fill in the name"))
         return False
     if (self.runner_name in ("steam", "winesteam") and self.lutris_config.game_config.get("appid") is None):
         ErrorDialog(_("Steam AppId not provided"))
         return False
     invalid_fields = []
     runner_class = import_runner(self.runner_name)
     runner_instance = runner_class()
     for config in ["game", "runner"]:
         for k, v in getattr(self.lutris_config, config + "_config").items():
             option = runner_instance.find_option(config + "_options", k)
             if option is None:
                 continue
             validator = option.get("validator")
             if validator is not None:
                 try:
                     res = validator(v)
                     logger.debug("%s validated successfully: %s", k, res)
                 except Exception:
                     invalid_fields.append(option.get("label"))
     if invalid_fields:
         ErrorDialog(_("The following fields have invalid values: ") + ", ".join(invalid_fields))
         return False
     return True
示例#4
0
    def __init__(self):

        Gtk.Application.__init__(
            self,
            application_id='net.lutris.Lutris',
            flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)

        gettext.bindtextdomain("lutris", "/usr/share/locale")
        gettext.textdomain("lutris")

        check_config()
        migrate()
        update_platforms()

        GLib.set_application_name(_('Lutris'))
        self.window = None
        self.css_provider = Gtk.CssProvider.new()

        if os.geteuid() == 0:
            ErrorDialog(
                "Running Lutris as root is not recommended and may cause unexpected issues"
            )

        try:
            self.css_provider.load_from_path(
                os.path.join(datapath.get(), 'ui', 'lutris.css'))
        except GLib.Error as e:
            logger.exception(e)

        if hasattr(self, 'add_main_option'):
            self.add_arguments()
        else:
            ErrorDialog(
                "Your Linux distribution is too old, Lutris won't function properly"
            )
示例#5
0
 def is_valid(self):
     name = self.name_entry.get_text()
     if not self.runner_name:
         ErrorDialog("Runner not provided")
         return False
     if not name:
         ErrorDialog("Please fill in the name")
         return False
     return True
示例#6
0
文件: wine.py 项目: rcpoison/lutris
 def esync_limit_callback(config):
     if not is_esync_limit_set():
         ErrorDialog("Your limits are not set correctly."
                     " Please increase them as described here:"
                     " <a href='https://github.com/lutris/lutris/wiki/How-to:-Esync'>"
                     "https://github.com/lutris/lutris/wiki/How-to:-Esync</a>")
         return False
     if is_version_esync(config['version']):
         ErrorDialog("Your wine version may not support esync, if you are unsure please check.")
     return True
示例#7
0
 def is_valid(self):
     if not self.runner_name:
         ErrorDialog("Runner not provided")
         return False
     if not self.name_entry.get_text():
         ErrorDialog("Please fill in the name")
         return False
     if (self.runner_name in ("steam", "winesteam")
             and self.lutris_config.game_config.get("appid") is None):
         ErrorDialog("Steam AppId not provided")
         return False
     return True
示例#8
0
 def is_valid(self):
     name = self.name_entry.get_text()
     if not self.runner_name:
         ErrorDialog("Runner not provided")
         return False
     if not name:
         ErrorDialog("Please fill in the name")
         return False
     if self.runner_name in ('steam', 'winesteam') and self.lutris_config.game_config.get('appid') is None:
         ErrorDialog("Steam AppId not provided")
         return False
     return True
示例#9
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service and game.service != "lutris":
            service = get_enabled_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)

            try:
                game_id = service.install(db_game)
            except ValueError as e:
                logger.debug(e)
                game_id = None

            if game_id:
                game = Game(game_id)
                game.launch()
            return True
        if not game.slug:
            raise ValueError("Invalid game passed: %s" % game)
            # return True
        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            ErrorDialog(_("There is no installer available for %s.") %
                        game.name,
                        parent=self.window)
        return True
示例#10
0
    def update_search_results_cb(self, api_games, error):
        if error:
            ErrorDialog(error)
            return

        self.search_spinner.stop()
        self.search_spinner.hide()
        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()
示例#11
0
    def _on_folder_scanned(self, result, error):
        if error:
            ErrorDialog(error)
            self.destroy()
            return
        for child in self.vbox.get_children():
            child.destroy()
        installed, missing = result
        installed_label = self._get_label("Installed games")
        self.vbox.add(installed_label)
        installed_listbox = Gtk.ListBox(visible=True)
        installed_scroll = Gtk.ScrolledWindow(visible=True)
        installed_scroll.set_vexpand(True)
        installed_scroll.add(installed_listbox)
        self.vbox.add(installed_scroll)
        for folder in installed:
            installed_listbox.add(self.build_row("", gtk_safe(folder), ""))

        missing_label = self._get_label("No match found")
        self.vbox.add(missing_label)
        missing_listbox = Gtk.ListBox(visible=True)
        missing_scroll = Gtk.ScrolledWindow(visible=True)
        missing_scroll.set_vexpand(True)
        missing_scroll.add(missing_listbox)
        self.vbox.add(missing_scroll)
        for folder in missing:
            missing_listbox.add(self.build_row("", gtk_safe(folder), ""))
示例#12
0
def esync_display_limit_warning():
    ErrorDialog(
        _("Your limits are not set correctly."
          " Please increase them as described here:"
          " <a href='https://github.com/lutris/lutris/wiki/How-to:-Esync'>"
          "How-to:-Esync (https://github.com/lutris/lutris/wiki/How-to:-Esync)</a>"
          ))
    def __init__(self, title, parent, runner):
        super(RunnerInstallDialog, self).__init__(title, parent, 0,
                                                  ('_OK', Gtk.ResponseType.OK))
        width, height = (460, 380)
        self.dialog_size = (width, height)
        self.set_default_size(width, height)

        self.runner = runner
        self.runner_info = api.get_runners(self.runner)
        if not self.runner_info:
            ErrorDialog(
                'Unable to get runner versions, check your internet connection',
                parent=parent)
            return
        label = Gtk.Label("%s version management" % self.runner_info['name'])
        self.vbox.add(label)
        self.runner_store = self.get_store()
        scrolled_window = Gtk.ScrolledWindow()
        self.treeview = self.get_treeview(self.runner_store)
        self.installing = {}
        self.connect('response', self.on_response)

        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        scrolled_window.add(self.treeview)

        self.vbox.pack_start(scrolled_window, True, True, 14)
        self.show_all()
示例#14
0
    def display_all_versions(self, runner_info, error):
        """Clear the box and display versions from runner_info"""
        if error:
            logger.error(error)

        self.runner_info = runner_info
        if not self.runner_info:
            ErrorDialog(
                "Unable to get runner versions. Check your internet connection."
            )
            return

        for child_widget in self.vbox.get_children():
            if child_widget.get_name() not in "GtkBox":
                child_widget.destroy()

        self.populate_store()

        label = Gtk.Label.new("%s version management" %
                              self.runner_info["name"])
        self.vbox.add(label)
        scrolled_window = Gtk.ScrolledWindow()
        treeview = self.get_treeview(self.runner_store)
        self.installing = {}
        self.connect("response", self.on_destroy)

        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        scrolled_window.add(treeview)

        self.vbox.pack_start(scrolled_window, True, True, 14)
        self.show_all()
示例#15
0
    def install_dialog(self):
        """Ask the user if she wants to install the runner.

        Return success of runner installation.
        """
        dialog = dialogs.QuestionDialog({
            "question": ("The required runner is not installed.\n"
                         "Do you wish to install it now?"),
            "title":
            "Required runner unavailable",
        })
        if Gtk.ResponseType.YES == dialog.result:

            from lutris.gui.dialogs.runners import simple_downloader
            from lutris.gui.dialogs import ErrorDialog
            try:
                if hasattr(self, "get_version"):
                    self.install(downloader=simple_downloader,
                                 version=self.get_version(use_default=False))
                else:
                    self.install(downloader=simple_downloader)
            except RunnerInstallationError as ex:
                ErrorDialog(ex.message)

            return self.is_installed()
        return False
示例#16
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service and game.service != "lutris":
            service = get_enabled_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)

            try:
                game_id = service.install(db_game)
            except ValueError as e:
                logger.debug(e)
                game_id = None

            if game_id:
                game = Game(game_id)
                game.launch()
            else:
                ErrorDialog(message=_("Could not retrieve game installer."),
                            parent=self.window)
            return True
        if not game.slug:
            raise ValueError("Invalid game passed: %s" % game)
            # return True
        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            logger.debug("Should generate automagical installer here but....")
            logger.debug("Wait? how did you get here?")
        return True
示例#17
0
文件: sidebar.py 项目: Vistaus/lutris
 def service_load_cb(self, _result, error):
     if error:
         if isinstance(error, AuthTokenExpired):
             self.service.logout()
             self.service.login()
         else:
             ErrorDialog(str(error))
     GLib.timeout_add(2000, self.enable_refresh_button)
示例#18
0
    def runner_fetch_cb(self, runner_info, error):
        """Clear the box and display versions from runner_info"""
        if error:
            logger.error(error)
            ErrorDialog(_("Unable to get runner versions: %s") % error)
            return

        self.runner_info = runner_info
        remote_versions = {(v["version"], v["architecture"])
                           for v in self.runner_info["versions"]}
        local_versions = self.get_installed_versions()
        for local_version in local_versions - remote_versions:
            self.runner_info["versions"].append({
                "version":
                local_version[0],
                "architecture":
                local_version[1],
                "url":
                "",
            })

        if not self.runner_info:
            ErrorDialog(_("Unable to get runner versions from lutris.net"))
            return

        for child_widget in self.vbox.get_children():
            if child_widget.get_name() not in "GtkBox":
                child_widget.destroy()

        self.populate_store()

        label = Gtk.Label.new(
            _("%s version management") % self.runner_info["name"])
        self.vbox.add(label)
        scrolled_window = Gtk.ScrolledWindow()
        treeview = self.get_treeview(self.runner_store)
        self.installing = {}
        self.connect("response", self.on_destroy)

        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        scrolled_window.add(treeview)

        self.vbox.pack_start(scrolled_window, True, True, 14)
        self.show_all()
示例#19
0
文件: sidebar.py 项目: qmatias/lutris
 def service_load_cb(self, games, error):
     if not error and not games:
         error = _(
             "Failed to load games. Check that your profile is set to public during the sync."
         )
     if error:
         ErrorDialog(error)
     GLib.timeout_add(5000, self.enable_refresh_button)
示例#20
0
def error_handler(error_type, value, traceback):
    if error_type == ScriptingError:
        message = value.message
        if value.faulty_data:
            message += "\n<b>" + str(value.faulty_data) + "</b>"
        ErrorDialog(message)
    else:
        _excepthook(error_type, value, traceback)
示例#21
0
 def service_load_cb(self, games, error):
     if games is None:
         logger.warning("No game returned from the service")
     if not error and not games and self.service.id == "steam":
         # This should not be handled here, the steam service should raise an error
         error = _("Failed to load games. Check that your profile is set to public during the sync.")
     if error:
         ErrorDialog(str(error))
     GLib.timeout_add(5000, self.enable_refresh_button)
示例#22
0
 def on_game_install_dlc(self, game):
     service = get_enabled_services()[game.service]()
     db_game = games_db.get_game_by_field(game.id, "id")
     installers = service.get_dlc_installers(db_game)
     if installers:
         self.show_installer_window(installers, service, game.appid)
     else:
         ErrorDialog(_("No DLC found"))
     return True
示例#23
0
def error_handler(error_type, value, traceback):
    """Intercept all possible exceptions and raise them as ScriptingErrors"""
    if error_type == ScriptingError:
        message = value.message
        if value.faulty_data:
            message += "\n<b>%s</b>" % gtk_safe(value.faulty_data)
        ErrorDialog(message)
    else:
        _excepthook(error_type, value, traceback)
示例#24
0
    def __init__(self):
        super().__init__(
            application_id="net.lutris.Lutris",
            flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
        )
        logger.info("Running Lutris %s", settings.VERSION)
        set_child_subreaper()
        gettext.bindtextdomain("lutris", "/usr/share/locale")
        gettext.textdomain("lutris")

        check_config()
        migrate()
        update_platforms()
        check_driver()
        check_libs()
        check_vulkan()

        GLib.set_application_name(_("Lutris"))
        self.running_games = []
        self.window = None
        self.help_overlay = None
        self.tray = None
        self.css_provider = Gtk.CssProvider.new()

        if os.geteuid() == 0:
            ErrorDialog(
                "Running Lutris as root is not recommended and may cause unexpected issues"
            )

        try:
            self.css_provider.load_from_path(
                os.path.join(datapath.get(), "ui", "lutris.css")
            )
        except GLib.Error as e:
            logger.exception(e)

        if hasattr(self, "add_main_option"):
            self.add_arguments()
        else:
            ErrorDialog(
                "Your Linux distribution is too old, Lutris won't function properly"
            )
示例#25
0
 def install_runner(self, row):
     """Download and install a runner version"""
     dest_path = self.get_dest_path(row)
     url = row[self.COL_URL]
     if not url:
         ErrorDialog("Version %s is not longer available" %
                     row[self.COL_VER])
         return
     downloader = Downloader(row[self.COL_URL], dest_path, overwrite=True)
     GLib.timeout_add(100, self.get_progress, downloader, row)
     self.installing[row[self.COL_VER]] = downloader
     downloader.start()
示例#26
0
 def on_install_clicked(self, widget):
     """Install a runner."""
     try:
         self.runner.install(downloader=simple_downloader)
     except (
             runners.RunnerInstallationError,
             runners.NonInstallableRunnerError,
     ) as ex:
         ErrorDialog(ex.message)
         return
     if self.runner.is_installed():
         self.emit("runner-installed")
示例#27
0
文件: widgets.py 项目: ERIIX/lutris
 def start(self):
     """Start downloading a file."""
     try:
         self.downloader = Downloader(self.url, self.dest)
     except RuntimeError as ex:
         from lutris.gui.dialogs import ErrorDialog
         ErrorDialog(ex.message)
         self.emit('cancelrequested', {})
         return
     timer_id = GLib.timeout_add(100, self.progress)
     self.cancel_button.set_sensitive(True)
     self.downloader.start()
     return timer_id
示例#28
0
 def on_install_clicked(self, widget, runner, runner_label):
     """Install a runner."""
     if runner.depends_on is not None:
         dependency = runner.depends_on()
         dependency.install()
     try:
         runner.install()
     except (runners.RunnerInstallationError,
             runners.NonInstallableRunnerError) as ex:
         ErrorDialog(ex.message, parent=self)
     if runner.is_installed():
         self.emit('runner-installed')
         self.refresh_button.emit('clicked')
示例#29
0
 def install_runner(self, row):
     """Download and install a runner version"""
     runner = row.runner
     row.install_progress.set_fraction(0.0)
     dest_path = self.get_dest_path(runner)
     url = runner[self.COL_URL]
     if not url:
         ErrorDialog(_("Version %s is not longer available") % runner[self.COL_VER])
         return
     downloader = Downloader(runner[self.COL_URL], dest_path, overwrite=True)
     GLib.timeout_add(100, self.get_progress, downloader, row)
     self.installing[runner[self.COL_VER]] = downloader
     downloader.start()
     self.update_listboxrow(row)
示例#30
0
 def on_install_clicked(self, widget, runner, runner_label):
     """Install a runner."""
     if runner.depends_on is not None:
         dependency = runner.depends_on()
         dependency.install()
     try:
         runner.install()
     except (runners.RunnerInstallationError,
             runners.NonInstallableRunnerError) as ex:
         ErrorDialog(ex.message)
     if runner.is_installed():
         self.emit('runner-installed')
         widget.hide()
         runner_label.set_sensitive(True)