diff --git a/lutris/game.py b/lutris/game.py index cf613ccfa..eff4b6aef 100644 --- a/lutris/game.py +++ b/lutris/game.py @@ -49,6 +49,7 @@ class Game(object): self.config = None self.killswitch = None self.state = self.STATE_IDLE + self.game_log = '' game_data = pga.get_game_by_slug(slug) self.runner_name = game_data.get('runner') or '' @@ -260,7 +261,7 @@ class Game(object): quit_time = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) logger.debug("game has quit at %s" % quit_time) self.state = self.STATE_STOPPED - + self.game_log = self.game_thread.stdout if self.resolution_changed\ or self.runner.system_config.get('reset_desktop'): display.change_resolution(self.original_outputs) diff --git a/lutris/gui/logwindow.py b/lutris/gui/logwindow.py index dfc8d208e..727b8cde5 100644 --- a/lutris/gui/logwindow.py +++ b/lutris/gui/logwindow.py @@ -5,7 +5,7 @@ from lutris.gui.widgets import Dialog class LogTextView(Gtk.TextView): bg_rgb = 'rgb(47,47,47)' fg_rgb = 'rgb(255, 199, 116)' - font_face = 'Monospace 11' + font_face = 'Monospace 10' def __init__(self): super(LogTextView, self).__init__() @@ -24,7 +24,7 @@ class LogTextView(Gtk.TextView): self.set_editable(False) self.override_font(font_description) - self.textbuffer = self.textview.get_buffer() + self.textbuffer = self.get_buffer() def set_text(self, content): self.textbuffer.set_text(content) @@ -32,9 +32,13 @@ class LogTextView(Gtk.TextView): class LogWindow(Dialog): def __init__(self, title, parent): + super(LogWindow, self).__init__(title, parent) + self.set_size_request(640, 480) + self.grid = Gtk.Grid() + self.logtextview = LogTextView() scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_hexpand(True) scrolledwindow.set_vexpand(True) - self.logtextview = LogTextView() - self.add(scrolledwindow) - self.add(self.logtextview) + scrolledwindow.add(self.logtextview) + self.vbox.add(scrolledwindow) + self.show_all() diff --git a/lutris/gui/lutriswindow.py b/lutris/gui/lutriswindow.py index 25aa93749..56225259d 100644 --- a/lutris/gui/lutriswindow.py +++ b/lutris/gui/lutriswindow.py @@ -9,7 +9,6 @@ from gi.repository import Gtk, Gdk, GLib from lutris import api, pga, settings from lutris.game import Game, get_game_list from lutris.shortcuts import create_launcher -from lutris.gui.installgamedialog import InstallerDialog from lutris.sync import Sync from lutris.util import runtime @@ -22,8 +21,10 @@ from lutris.util import datapath from lutris.gui import dialogs from lutris.gui.sidebar import SidebarTreeView -from lutris.gui.uninstallgamedialog import UninstallGameDialog +from lutris.gui.logwindow import LogWindow from lutris.gui.runnersdialog import RunnersDialog +from lutris.gui.installgamedialog import InstallerDialog +from lutris.gui.uninstallgamedialog import UninstallGameDialog from lutris.gui.config_dialogs import ( AddGameDialog, EditGameConfigDialog, SystemConfigDialog ) @@ -442,6 +443,13 @@ class LutrisWindow(object): if add_game_dialog.saved: self.view.set_installed(game) + def on_view_game_log_activate(self, widget): + if not self.running_game: + dialogs.ErrorDialog('No game log available') + log_title = "Log for {}".format(self.running_game) + log_window = LogWindow(log_title, self.window) + log_window.logtextview.set_text(self.running_game.game_log) + def add_game(self, _widget, _data=None): """Add a new game.""" add_game_dialog = AddGameDialog(self) diff --git a/lutris/thread.py b/lutris/thread.py index 5b00d7f61..65a08f307 100644 --- a/lutris/thread.py +++ b/lutris/thread.py @@ -26,7 +26,7 @@ class LutrisThread(threading.Thread): self.return_code = None self.rootpid = rootpid or os.getpid() self.is_running = True - self.stdout = [] + self.stdout = '' self.attached_threads = [] logger.debug('Running thread from %s', self.path) @@ -43,7 +43,7 @@ class LutrisThread(threading.Thread): stderr=subprocess.STDOUT, cwd=self.path, env=self.env) for line in iter(self.game_process.stdout.readline, ''): - self.stdout.append(line) + self.stdout += line sys.stdout.write(line) def iter_children(self, process, topdown=True): diff --git a/share/lutris/ui/LutrisWindow.ui b/share/lutris/ui/LutrisWindow.ui index 2e188e013..23aa76e1b 100644 --- a/share/lutris/ui/LutrisWindow.ui +++ b/share/lutris/ui/LutrisWindow.ui @@ -8,6 +8,12 @@ False gtk-media-play + + True + False + gtk-file + 1 + False True @@ -306,6 +312,22 @@ + + + True + False + + + + + View log of last game + True + False + image2 + False + + +