mirror of
https://github.com/lutris/lutris
synced 2024-10-14 11:42:36 +00:00
Run initial sync when first enabled
This commit is contained in:
parent
85bfd70a99
commit
84dfd9514f
|
@ -142,7 +142,7 @@ def fetch_user_info():
|
|||
def read_user_info():
|
||||
if not os.path.exists(USER_INFO_FILE_PATH):
|
||||
return {}
|
||||
with open(USER_INFO_FILE_PATH) as user_info_file:
|
||||
with open(USER_INFO_FILE_PATH, encoding="utf-8") as user_info_file:
|
||||
user_info = json.load(user_info_file)
|
||||
return user_info
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from gi.repository import Gtk
|
|||
from lutris import settings
|
||||
from lutris.api import disconnect, read_user_info
|
||||
from lutris.gui.config.base_config_box import BaseConfigBox
|
||||
from lutris.gui.dialogs import ClientLoginDialog
|
||||
from lutris.gui.dialogs import ClientLoginDialog, QuestionDialog
|
||||
from lutris.util.jobs import AsyncCall
|
||||
from lutris.util.library_sync import sync_local_library
|
||||
from lutris.util.steam.config import STEAM_ACCOUNT_SETTING, get_steam_users
|
||||
|
@ -94,17 +94,12 @@ class AccountsBox(BaseConfigBox):
|
|||
_(
|
||||
"<i>This will send play time, last played, runner, platform \n"
|
||||
"and store information to the lutris website so you can \n"
|
||||
"sync this data on multiple devices (this is currently being implemented)</i>"
|
||||
"sync this data on multiple devices</i>"
|
||||
)
|
||||
)
|
||||
self.space_widget(label, top=0)
|
||||
box.add(label)
|
||||
|
||||
button = Gtk.Button(_("Sync now"), visible=True)
|
||||
button.connect("clicked", self.on_sync_clicked)
|
||||
self.space_widget(button)
|
||||
box.add(button)
|
||||
|
||||
return box
|
||||
|
||||
def populate_steam_accounts(self):
|
||||
|
@ -155,11 +150,13 @@ class AccountsBox(BaseConfigBox):
|
|||
settings.write_setting(STEAM_ACCOUNT_SETTING, steamid64)
|
||||
|
||||
def on_sync_toggled(self, checkbutton):
|
||||
settings.write_setting("library_sync_enabled", checkbutton.get_active())
|
||||
|
||||
def on_sync_clicked(self, button):
|
||||
def sync_cb(result, error):
|
||||
button.set_sensitive(True)
|
||||
|
||||
button.set_sensitive(False)
|
||||
AsyncCall(sync_local_library, sync_cb)
|
||||
if not settings.read_setting("last_library_sync_at"):
|
||||
sync_warn_dialog = QuestionDialog({
|
||||
"title": _("Synchronize library?"),
|
||||
"question": _("Enable library sync and run a full sync with lutris.net?")
|
||||
})
|
||||
if sync_warn_dialog.result == Gtk.ResponseType.YES:
|
||||
AsyncCall(sync_local_library, None)
|
||||
settings.write_setting("library_sync_enabled", checkbutton.get_active())
|
||||
else:
|
||||
settings.write_setting("library_sync_enabled", checkbutton.get_active())
|
||||
|
|
|
@ -6,8 +6,6 @@ from math import floor
|
|||
|
||||
import gi
|
||||
|
||||
from lutris.services.service_media import resolve_media_path
|
||||
|
||||
gi.require_version('PangoCairo', '1.0')
|
||||
|
||||
import cairo
|
||||
|
@ -17,6 +15,7 @@ from lutris.exceptions import MissingMediaError
|
|||
from lutris.gui.widgets.utils import (
|
||||
MEDIA_CACHE_INVALIDATED, get_default_icon_path, get_runtime_icon_path, get_scaled_surface_by_path, get_surface_size
|
||||
)
|
||||
from lutris.services.service_media import resolve_media_path
|
||||
from lutris.util.path_cache import MISSING_GAMES
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue