Launch Steamatcher with the main UI

This commit is contained in:
Mathieu Comandon 2016-08-02 13:51:23 -07:00
parent 5139dc9a7d
commit 295df757c0
4 changed files with 41 additions and 9 deletions

View file

@ -49,6 +49,7 @@ from lutris.game import Game
from lutris.gui.installgamedialog import InstallerDialog
from lutris.settings import VERSION
from lutris.util import service
from lutris.util.steam import get_steamapps_paths
# Support for command line options.
parser = optparse.OptionParser(version="%prog " + VERSION)
@ -111,13 +112,11 @@ if options.list_steam:
print appid
exit()
if options.list_steam_folders:
from lutris.runners import winesteam, steam
winesteam_runner = winesteam.winesteam()
steam_runner = steam.steam()
for folder in steam_runner.get_steamapps_dirs():
print folder
for folder in winesteam_runner.get_steamapps_dirs():
print folder
steamapps_paths = get_steamapps_paths()
for path in steamapps_paths['linux']:
print path
for path in steamapps_paths['windows']:
print path
exit()

View file

@ -14,6 +14,7 @@ from lutris.util import display, resources
from lutris.util.log import logger
from lutris.util.jobs import AsyncCall
from lutris.util import datapath
from lutris.util.steam import SteamWatcher, get_steamapps_paths
from lutris.gui import dialogs
from lutris.gui.sidebar import SidebarTreeView
@ -187,6 +188,8 @@ class LutrisWindow(Gtk.Application):
# Timers
self.timer_ids = [GLib.timeout_add(300, self.refresh_status),
GLib.timeout_add(10000, self.on_sync_timer)]
steamapps_paths = get_steamapps_paths(flat=True)
self.steam_watcher = SteamWatcher(steamapps_paths)
def init_game_store(self):
logger.debug("Getting game list")
@ -212,7 +215,6 @@ class LutrisWindow(Gtk.Application):
def check_update(self):
"""Verify availability of client update."""
pass
def on_version_received(version, error):
if not version:
@ -423,6 +425,7 @@ class LutrisWindow(Gtk.Application):
return True
def on_resize(self, widget, *args):
"""WTF is this doing?"""
self.window_size = widget.get_size()
def on_destroy(self, *args):

View file

@ -137,7 +137,11 @@ class Sync(object):
return updated
def sync_steam_local(self):
"""Sync Steam games in library with Steam and Wine Steam"""
"""Sync Steam games in library with Steam and Wine Steam
FIXME: This is the guilty method that causes grief to everyone, most of it should
probably disappear
"""
steamrunner = steam()
winesteamrunner = winesteam()
installed = set()

View file

@ -201,6 +201,30 @@ def get_app_state_log(steam_data_dir, appid, start_time=None):
return state_log
def get_steamapps_paths(flat=False):
from lutris.runners import winesteam, steam
if flat:
steamapps_paths = []
else:
steamapps_paths = {
'linux': [],
'windows': []
}
winesteam_runner = winesteam.winesteam()
steam_runner = steam.steam()
for folder in steam_runner.get_steamapps_dirs():
if flat:
steamapps_paths.append(folder)
else:
steamapps_paths['linux'].append(folder)
for folder in winesteam_runner.get_steamapps_dirs():
if flat:
steamapps_paths.append(folder)
else:
steamapps_paths['windows'].append(folder)
return steamapps_paths
class SteamWatchHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
path = event.pathname
@ -232,6 +256,8 @@ class SteamWatcher(threading.Thread):
event_handler = SteamWatchHandler()
mask = pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY
notifier = pyinotify.Notifier(watch_manager, event_handler)
logger.info(self.steamapps_paths)
for steamapp_path in self.steamapps_paths:
logger.info('Watching Steam folder %s', steamapp_path)
watch_manager.add_watch(steamapp_path, mask, rec=True)
notifier.loop()