mirror of
https://github.com/lutris/lutris
synced 2024-09-05 07:23:32 +00:00
Add LogWindow to view stdout of last game
This commit is contained in:
parent
5f770d4e38
commit
0e5ce772ca
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-media-play</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-file</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkRadioAction" id="radioaction1">
|
||||
<property name="hide_if_empty">False</property>
|
||||
<property name="draw_as_radio">True</property>
|
||||
|
@ -306,6 +312,22 @@
|
|||
<signal name="activate" handler="on_remove_game" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separator2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="view_game_log">
|
||||
<property name="label" translatable="yes">View log of last game</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image2</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_view_game_log_activate" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue