mirror of
https://github.com/lutris/lutris
synced 2024-10-14 11:42:36 +00:00
Add a notification banner that appears if you are using an older client than what Lutris.net says you should have.
This triggers when we check component updates, so every six hours. That's not really a very good policy, but it's a start.
This commit is contained in:
parent
308c9ba404
commit
232225f822
|
@ -1,3 +1,3 @@
|
|||
"""Main Lutris package"""
|
||||
|
||||
__version__ = "0.5.17"
|
||||
__version__ = "0.5.15"
|
||||
|
|
|
@ -204,6 +204,7 @@ class UpdatesBox(BaseConfigBox):
|
|||
def get_updater():
|
||||
updater = RuntimeUpdater()
|
||||
updater.update_runtime = True
|
||||
updater.update_runners = False
|
||||
return updater
|
||||
|
||||
self._trigger_updates(get_updater, self.update_runtime_box)
|
||||
|
|
|
@ -63,9 +63,11 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
viewtype_icon = GtkTemplate.Child()
|
||||
download_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
game_view_spinner: Gtk.Spinner = GtkTemplate.Child()
|
||||
notification_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
login_notification_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
lutris_log_in_label: Gtk.Label = GtkTemplate.Child()
|
||||
turn_on_library_sync_label: Gtk.Label = GtkTemplate.Child()
|
||||
version_notification_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
version_ignore_label: Gtk.Label = GtkTemplate.Child()
|
||||
|
||||
def __init__(self, application, **kwargs):
|
||||
width = int(settings.read_setting("width") or self.default_width)
|
||||
|
@ -847,7 +849,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
else:
|
||||
show_notification = False
|
||||
|
||||
self.notification_revealer.set_reveal_child(show_notification)
|
||||
self.login_notification_revealer.set_reveal_child(show_notification)
|
||||
|
||||
@GtkTemplate.Callback
|
||||
def on_lutris_log_in_label_activate_link(self, _label, _url):
|
||||
|
@ -859,6 +861,9 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
self.sync_library(force=True)
|
||||
self.update_notification()
|
||||
|
||||
def on_version_ignore_label_activate_link(self, _label, _url):
|
||||
self.version_notification_revealer.set_reveal_child(False)
|
||||
|
||||
def on_service_games_updated(self, service):
|
||||
"""Request a view update when service games are loaded"""
|
||||
if self.service and service.id == self.service.id:
|
||||
|
@ -1194,7 +1199,8 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
which can easily block."""
|
||||
runtime_updater = RuntimeUpdater(force=force_updates)
|
||||
component_updaters = runtime_updater.create_component_updaters()
|
||||
return component_updaters, runtime_updater
|
||||
supported_client_version = runtime_updater.check_client_versions()
|
||||
return component_updaters, runtime_updater, supported_client_version
|
||||
|
||||
def create_runtime_updater_cb(result, error):
|
||||
"""Picks up the component updates when we know what they are, and begins the installation.
|
||||
|
@ -1203,7 +1209,11 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
if error:
|
||||
logger.exception("Failed to obtain updates from Lutris.net: %s", error)
|
||||
else:
|
||||
component_updaters, runtime_updater = result
|
||||
component_updaters, runtime_updater, supported_client_version = result
|
||||
|
||||
if supported_client_version:
|
||||
self.version_notification_revealer.set_reveal_child(True)
|
||||
|
||||
if component_updaters:
|
||||
self.install_runtime_component_updates(component_updaters, runtime_updater)
|
||||
else:
|
||||
|
|
|
@ -5,7 +5,7 @@ import os
|
|||
import threading
|
||||
import time
|
||||
from gettext import gettext as _
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from lutris import settings
|
||||
from lutris.api import (
|
||||
|
@ -22,6 +22,7 @@ from lutris.util.extract import extract_archive
|
|||
from lutris.util.jobs import AsyncCall
|
||||
from lutris.util.linux import LINUX_SYSTEM
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import parse_version
|
||||
from lutris.util.wine.d3d_extras import D3DExtrasManager
|
||||
from lutris.util.wine.dgvoodoo2 import dgvoodoo2Manager
|
||||
from lutris.util.wine.dxvk import DXVKManager
|
||||
|
@ -153,6 +154,8 @@ class RuntimeUpdater:
|
|||
"""Class handling the runtime updates"""
|
||||
|
||||
def __init__(self, force: bool = False):
|
||||
self.runtime_versions = None
|
||||
|
||||
if RUNTIME_DISABLED:
|
||||
logger.warning("Runtime disabled by environment variable. Re-enable runtime before submitting issues.")
|
||||
self.update_runtime = False
|
||||
|
@ -172,6 +175,9 @@ class RuntimeUpdater:
|
|||
self.update_runtime = False
|
||||
self.update_runners = False
|
||||
|
||||
if self.has_updates:
|
||||
self.runtime_versions = download_runtime_versions()
|
||||
|
||||
@property
|
||||
def has_updates(self):
|
||||
return self.update_runtime or self.update_runners
|
||||
|
@ -184,20 +190,28 @@ class RuntimeUpdater:
|
|||
|
||||
This method also downloads fresh runner versions on each call, so we call this on a
|
||||
worker thread, instead of blocking the UI."""
|
||||
if not self.has_updates:
|
||||
if not self.runtime_versions:
|
||||
return []
|
||||
|
||||
runtime_versions = download_runtime_versions()
|
||||
updaters: List[ComponentUpdater] = []
|
||||
|
||||
if self.update_runtime:
|
||||
updaters += self._get_runtime_updaters(runtime_versions)
|
||||
updaters += self._get_runtime_updaters(self.runtime_versions)
|
||||
|
||||
if self.update_runners:
|
||||
updaters += self._get_runner_updaters(runtime_versions)
|
||||
updaters += self._get_runner_updaters(self.runtime_versions)
|
||||
|
||||
return [u for u in updaters if u.should_update]
|
||||
|
||||
def check_client_versions(self) -> Optional[str]:
|
||||
if self.runtime_versions and not os.environ.get("LUTRIS_NO_CLIENT_VERSION_CHECK"):
|
||||
client_version = self.runtime_versions.get("client_version")
|
||||
if client_version:
|
||||
if parse_version(client_version) > parse_version(settings.VERSION):
|
||||
return client_version
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _get_runtime_updaters(runtime_versions: Dict[str, Any]) -> List[ComponentUpdater]:
|
||||
"""Launch the update process"""
|
||||
|
|
|
@ -97,18 +97,17 @@
|
|||
<property name="hexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="notification_revealer">
|
||||
<object class="GtkRevealer" id="login_notification_revealer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="transition-type">none</property>
|
||||
<property name="reveal-child">True</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="notification_box">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="notification_label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Login to <a href="https://lutris.net/">Lutris.net</a> to view your game library</property>
|
||||
|
@ -163,6 +162,57 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="version_notification_revealer">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="transition-type">none</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="version_notification_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="label" translatable="yes">This is not the currently supported version of Lutris.</property>
|
||||
<property name="use-markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="version_ignore_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="label" translatable="yes"><a href="">Ignore</a></property>
|
||||
<property name="use-markup">True</property>
|
||||
<signal name="activate-link" handler="on_version_ignore_label_activate_link" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<style>
|
||||
<class name="in-app-notification"/>
|
||||
<class name="app-notification"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkOverlay">
|
||||
<property name="visible">True</property>
|
||||
|
@ -210,7 +260,7 @@
|
|||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -225,7 +275,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue