Skip to content
Snippets Groups Projects
Commit 5071c3be authored by Simon McVittie's avatar Simon McVittie
Browse files

test-ui: Always offer to unshare home, with a clearer UI


Rephrase it so that in the UI, unsharing the home directory looks like
the active choice ("separate home directory"), with the shared home
directory as the passive/default choice.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent f44918f5
No related branches found
No related tags found
No related merge requests found
......@@ -44,8 +44,21 @@ from gi.repository import Gtk
logger = logging.getLogger('pressure-vessel-test-ui')
# This doesn't fully work yet. Hack at own risk.
CAN_UNSHARE_HOME = (os.getenv('PRESSURE_VESSEL_SHARE_HOME') is not None)
def tristate_environment(name):
# type: (str) -> typing.Optional[bool]
value = os.getenv(name)
if value is None or value == '':
return None
if value == '1':
return True
if value == '0':
return False
logger.warning('Unrecognised value %r for $%s', value, name)
return None
class Gui:
......@@ -129,17 +142,29 @@ class Gui:
row += 1
if CAN_UNSHARE_HOME:
self.share_home_check = Gtk.CheckButton.new_with_label(
'Share real home directory'
)
self.share_home_check.set_active(
bool(os.getenv('PRESSURE_VESSEL_SHARE_HOME')))
self.grid.attach(self.share_home_check, 1, row, 1, 1)
self.unshare_home_check = Gtk.CheckButton.new_with_label(
'Use a separate home directory per game'
)
share_home = tristate_environment('PRESSURE_VESSEL_SHARE_HOME')
self.unshare_home_check.set_active(
share_home is not None and not share_home
)
self.grid.attach(self.unshare_home_check, 1, row, 1, 1)
row += 1
label = Gtk.Label.new('')
label.set_markup(
'<small><i>'
'Creating a separate home directory is experimental, '
'and is likely to break Steam Cloud Auto-Sync, Steam Workshop '
'and probably other features.'
'</i></small>'
)
label.set_halign(Gtk.Align.START)
label.set_line_wrap(True)
self.grid.attach(label, 1, row, 1, 1)
row += 1
row += 1
else:
self.share_home_check = None
self.xterm_check = Gtk.CheckButton.new_with_label('Run in an xterm')
self.xterm_check.set_active(False)
......@@ -334,10 +359,10 @@ class Gui:
argv.append('--runtime')
argv.append(os.path.join(id, 'files'))
if self.share_home_check is None or self.share_home_check.get_active():
argv.append('--share-home')
else:
if self.unshare_home_check.get_active():
argv.append('--unshare-home')
else:
argv.append('--share-home')
if self.xterm_check.get_active():
argv.append('--terminal=xterm')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment