Restrict the warning about non-writable directories to those paths you will be writing to.

Or at least my best guess at this.

Resolves #5180
This commit is contained in:
Daniel Johnson 2023-12-11 16:46:05 -05:00
parent 37fc312800
commit 24c04719e1
12 changed files with 32 additions and 10 deletions

View file

@ -479,9 +479,12 @@ class ConfigBox(VBox):
option_name = option["option"]
label = Label(option["label"])
default_path = option.get("default_path") or (self.runner.default_path if self.runner else "")
warn_if_non_writable_parent = bool(option.get("warn_if_non_writable_parent"))
file_chooser = FileChooserEntry(
title=_("Select file"),
action=Gtk.FileChooserAction.OPEN,
warn_if_non_writable_parent=warn_if_non_writable_parent,
text=text,
default_path=default_path,
shell_quoting=shell_quoting
@ -514,11 +517,17 @@ class ConfigBox(VBox):
"""Generate a file chooser button to select a directory."""
label = Label(option["label"])
option_name = option["option"]
warn_if_non_writable_parent = bool(option.get("warn_if_non_writable_parent"))
default_path = None
if not path and self.game and self.game.runner:
default_path = self.game.runner.working_dir
directory_chooser = FileChooserEntry(
title=_("Select folder"), action=Gtk.FileChooserAction.SELECT_FOLDER, text=path, default_path=default_path
title=_("Select folder"),
action=Gtk.FileChooserAction.SELECT_FOLDER,
warn_if_non_writable_parent=warn_if_non_writable_parent,
text=path,
default_path=default_path
)
directory_chooser.connect("changed", self._on_chooser_file_set, option_name)
directory_chooser.set_valign(Gtk.Align.CENTER)

View file

@ -53,6 +53,7 @@ class StorageBox(BaseConfigBox):
directory_chooser = FileChooserEntry(
title=_("Select folder"),
action=Gtk.FileChooserAction.SELECT_FOLDER,
warn_if_non_writable_parent=True,
text=path_setting["value"],
default_path=default_path
)

View file

@ -42,6 +42,7 @@ class CacheConfigurationDialog(ModalDialog):
path_chooser = FileChooserEntry(
title=_("Set the folder for the cache path"),
action=Gtk.FileChooserAction.SELECT_FOLDER,
warn_if_non_writable_parent=True,
text=self.cache_path,
activates_default=True
)

View file

@ -130,6 +130,7 @@ class InstallerWindow(ModelessDialog,
"Select folder",
Gtk.FileChooserAction.SELECT_FOLDER,
warn_if_non_empty=True,
warn_if_non_writable_parent=True,
warn_if_ntfs=True
)
self.location_entry.connect("changed", self.on_location_entry_changed)

View file

@ -64,10 +64,11 @@ class FileChooserEntry(Gtk.Box):
text=None,
default_path=None,
warn_if_non_empty=False,
warn_if_non_writable_parent=False,
warn_if_ntfs=False,
activates_default=False,
shell_quoting=False
):
): # pylint: disable=too-many-arguments
super().__init__(
orientation=Gtk.Orientation.VERTICAL,
spacing=0,
@ -76,6 +77,7 @@ class FileChooserEntry(Gtk.Box):
self.title = title
self.action = action
self.warn_if_non_empty = warn_if_non_empty
self.warn_if_non_writable_parent = warn_if_non_writable_parent
self.warn_if_ntfs = warn_if_ntfs
self.shell_quoting = shell_quoting
@ -252,14 +254,15 @@ class FileChooserEntry(Gtk.Box):
"contains files. Installation will not work properly."
))
self.pack_end(non_empty_label, False, False, 10)
parent = system.get_existing_parent(path)
if parent is not None and not os.access(parent, os.W_OK):
non_writable_destination_label = Gtk.Label(visible=True)
non_writable_destination_label.set_markup(_(
"<b>Warning</b> The destination folder "
"is not writable by the current user."
))
self.pack_end(non_writable_destination_label, False, False, 10)
if self.warn_if_non_writable_parent:
parent = system.get_existing_parent(path)
if parent is not None and not os.access(parent, os.W_OK):
non_writable_destination_label = Gtk.Label(visible=True)
non_writable_destination_label.set_markup(_(
"<b>Warning</b> The destination folder "
"is not writable by the current user."
))
self.pack_end(non_writable_destination_label, False, False, 10)
self.open_button.set_sensitive(bool(self.get_open_directory()))

View file

@ -42,6 +42,7 @@ class dolphin(Runner):
{
"option": "user_directory",
"type": "directory_chooser",
"warn_if_non_writable_parent": True,
"advanced": True,
"label": _("Custom Global User Directory"),
},

View file

@ -50,6 +50,7 @@ class dosbox(Runner):
"option": "working_dir",
"type": "directory_chooser",
"label": _("Working directory"),
"warn_if_non_writable_parent": True,
"help": _(
"The location where the game is run from.\n"
"By default, Lutris uses the directory of the "

View file

@ -97,6 +97,7 @@ class easyrpg(Runner):
"option": "save_path",
"type": "directory_chooser",
"label": _("Save path"),
"warn_if_non_writable_parent": True,
"help": _(
"Instead of storing save files in the game directory they are stored in the specified path. "
"The directory must exist."

View file

@ -75,6 +75,7 @@ class flatpak(Runner):
"option": "working_dir",
"type": "directory_chooser",
"label": _("Working directory"),
"warn_if_non_writable_parent": True,
"help": _("The directory to run the command in. Note that this must be a directory inside the sandbox."),
"advanced": True
},

View file

@ -549,6 +549,7 @@ class wine(Runner):
"type": "directory_chooser",
"section": _("Sandbox"),
"label": _("Sandbox directory"),
"warn_if_non_writable_parent": True,
"help": _("Custom directory for desktop integration folders."),
"advanced": True,
},

View file

@ -45,6 +45,7 @@ class zdoom(Runner):
"option": "savedir",
"type": "directory_chooser",
"label": _("Save path"),
"warn_if_non_writable_parent": True,
"help": _("User-specified path where save files should be located."),
},
]

View file

@ -120,6 +120,7 @@ system_options = [ # pylint: disable=invalid-name
"option": "game_path",
"type": "directory_chooser",
"label": _("Default installation folder"),
"warn_if_non_writable_parent": True,
"default": os.path.expanduser("~/Games"),
"scope": ["runner"],
"help": _("The default folder where you install your games.")