mirror of
https://github.com/lutris/lutris
synced 2024-09-04 23:13:35 +00:00
Use Python 3.7 compatible log handler stream switching
This commit is contained in:
parent
b92f6ed0f1
commit
181f48d64b
|
@ -423,15 +423,7 @@ class Application(Gtk.Application):
|
|||
if not argc:
|
||||
# Switch back the log output to stderr (the default in Python)
|
||||
# to avoid messing with any output from command line options.
|
||||
|
||||
# Use when targeting Python 3.7 minimum
|
||||
# console_handler.setStream(sys.stderr)
|
||||
|
||||
# Until then...
|
||||
logger.removeHandler(log.console_handler)
|
||||
log.console_handler = logging.StreamHandler(stream=sys.stdout)
|
||||
log.console_handler.setFormatter(log.SIMPLE_FORMATTER)
|
||||
logger.addHandler(log.console_handler)
|
||||
log.console_handler.setStream(sys.stderr)
|
||||
|
||||
# Set up logger
|
||||
if options.contains("debug"):
|
||||
|
|
66
lutris/gui/config/accounts_box.py
Normal file
66
lutris/gui/config/accounts_box.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
from gettext import gettext as _
|
||||
|
||||
from gi.repository import Gio, Gtk
|
||||
|
||||
from lutris import settings
|
||||
from lutris.gui.widgets.common import VBox
|
||||
|
||||
|
||||
class AccountsBox(VBox):
|
||||
settings_options = {}
|
||||
|
||||
def _get_section_label(self, text):
|
||||
label = Gtk.Label(visible=True)
|
||||
label.set_markup("<b>%s</b>" % text)
|
||||
label.set_alignment(0, 0.5)
|
||||
return label
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(visible=True)
|
||||
self.accelerators = accelerators
|
||||
self.set_margin_top(50)
|
||||
self.set_margin_bottom(50)
|
||||
self.set_margin_right(80)
|
||||
self.set_margin_left(80)
|
||||
self.add(self._get_section_label(_("Interface options")))
|
||||
frame = Gtk.Frame(visible=True, shadow_type=Gtk.ShadowType.ETCHED_IN)
|
||||
listbox = Gtk.ListBox(visible=True)
|
||||
frame.add(listbox)
|
||||
self.pack_start(frame, False, False, 12)
|
||||
for setting_key, label in self.settings_options.items():
|
||||
list_box_row = Gtk.ListBoxRow(visible=True)
|
||||
list_box_row.set_selectable(False)
|
||||
list_box_row.set_activatable(False)
|
||||
list_box_row.add(self._get_setting_box(setting_key, label))
|
||||
listbox.add(list_box_row)
|
||||
|
||||
def _get_setting_box(self, setting_key, label):
|
||||
box = Gtk.Box(
|
||||
spacing=12,
|
||||
margin_top=12,
|
||||
margin_bottom=12,
|
||||
visible=True
|
||||
)
|
||||
label = Gtk.Label(label, visible=True)
|
||||
label.set_alignment(0, 0.5)
|
||||
box.pack_start(label, True, True, 12)
|
||||
checkbox = Gtk.Switch(visible=True)
|
||||
if settings.read_setting(setting_key).lower() == "true":
|
||||
checkbox.set_active(True)
|
||||
checkbox.connect("state-set", self._on_setting_change, setting_key)
|
||||
|
||||
box.pack_start(checkbox, False, False, 12)
|
||||
return box
|
||||
|
||||
def _on_setting_change(self, widget, state, setting_key):
|
||||
"""Save a setting when an option is toggled"""
|
||||
settings.write_setting(setting_key, state)
|
||||
application = Gio.Application.get_default()
|
||||
|
||||
if setting_key == "dark_theme":
|
||||
application.style_manager.is_config_dark = state
|
||||
elif setting_key == "show_tray_icon":
|
||||
if application.window.get_visible():
|
||||
application.set_tray_icon()
|
||||
|
||||
self.get_toplevel().emit("settings-changed", setting_key)
|
|
@ -6,7 +6,7 @@ from lutris import settings
|
|||
from lutris.gui.widgets.common import VBox
|
||||
|
||||
|
||||
class PreferencesBox(VBox):
|
||||
class InterfacePreferencesBox(VBox):
|
||||
settings_options = {
|
||||
"hide_client_on_game_start": _("Minimize client when a game is launched"),
|
||||
"hide_text_under_icons": _("Hide text under icons"),
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
"""Configuration dialog for client and system options"""
|
||||
# pylint: disable=no-member
|
||||
from gettext import gettext as _
|
||||
|
||||
from gi.repository import GObject, Gtk
|
||||
|
||||
from lutris.config import LutrisConfig
|
||||
from lutris.gui.config.accounts_box import AccountsBox
|
||||
from lutris.gui.config.boxes import SystemBox
|
||||
from lutris.gui.config.common import GameDialogCommon
|
||||
from lutris.gui.config.preferences_box import PreferencesBox
|
||||
from lutris.gui.config.preferences_box import InterfacePreferencesBox
|
||||
from lutris.gui.config.runners_box import RunnersBox
|
||||
from lutris.gui.config.services_box import ServicesBox
|
||||
from lutris.gui.config.sysinfo_box import SysInfoBox
|
||||
|
||||
|
||||
# pylint: disable=no-member
|
||||
class PreferencesDialog(GameDialogCommon):
|
||||
__gsignals__ = {
|
||||
"settings-changed": (GObject.SIGNAL_RUN_LAST, None, (str, )),
|
||||
|
@ -34,6 +35,7 @@ class PreferencesDialog(GameDialogCommon):
|
|||
sidebar.add(self.get_sidebar_button("prefs-stack", _("Interface"), "view-grid-symbolic"))
|
||||
sidebar.add(self.get_sidebar_button("runners-stack", _("Runners"), "applications-utilities-symbolic"))
|
||||
sidebar.add(self.get_sidebar_button("services-stack", _("Sources"), "application-x-addon-symbolic"))
|
||||
sidebar.add(self.get_sidebar_button("accounts-stack", _("Accounts"), "system-users-symbolic"))
|
||||
sidebar.add(self.get_sidebar_button("sysinfo-stack", _("Hardware information"), "computer-symbolic"))
|
||||
sidebar.add(self.get_sidebar_button("system-stack", _("Global options"), "emblem-system-symbolic"))
|
||||
hbox.pack_start(sidebar, False, False, 0)
|
||||
|
@ -44,7 +46,7 @@ class PreferencesDialog(GameDialogCommon):
|
|||
self.vbox.pack_start(hbox, True, True, 0)
|
||||
self.vbox.set_border_width(0) # keep everything flush with the window edge
|
||||
self.stack.add_named(
|
||||
self.build_scrolled_window(PreferencesBox(self.accelerators)),
|
||||
self.build_scrolled_window(InterfacePreferencesBox(self.accelerators)),
|
||||
"prefs-stack"
|
||||
)
|
||||
|
||||
|
@ -59,6 +61,11 @@ class PreferencesDialog(GameDialogCommon):
|
|||
"services-stack"
|
||||
)
|
||||
|
||||
self.stack.add_named(
|
||||
self.build_scrolled_window(AccountsBox()),
|
||||
"accounts-stack"
|
||||
)
|
||||
|
||||
sysinfo_box = SysInfoBox()
|
||||
self.page_generators["sysinfo-stack"] = sysinfo_box.populate
|
||||
self.stack.add_named(
|
||||
|
|
|
@ -177,12 +177,10 @@ class SteamID:
|
|||
raise SteamIDError("Invalid Steam community URL ({})".format(url))
|
||||
|
||||
@classmethod
|
||||
def from_steamid64(cls, steamid):
|
||||
def from_steamid64(cls, steamid, account_type=TYPE_INDIVIDUAL, universe=UNIVERSE_INDIVIDUAL):
|
||||
"""Create an instance of SteamID from a SteamID64. Only for normal user accounts."""
|
||||
instance = steamid & 1
|
||||
account_number = cls.get_account_number_from_steamid(steamid)
|
||||
account_type = TYPE_INDIVIDUAL
|
||||
universe = UNIVERSE_INDIVIDUAL
|
||||
return cls(account_number, instance, account_type, universe)
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in a new issue