[gnome-chess] Never open file chooser to /run
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Never open file chooser to /run
- Date: Sun, 6 Dec 2020 15:16:24 +0000 (UTC)
commit d06b74cf38dff50c056fa353fe23a30d854596a1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Dec 6 09:15:07 2020 -0600
Never open file chooser to /run
If we are sandboxed, then any files we save are going to be located
under /run inside the sandbox. But that's not where they are on the host
system, so we should try to avoid exposing this to the user. Sad reality
is that there is no way we can know where the file really exists on the
host, so let's just not preselect the file's location in this case.
Fixes #53
src/gnome-chess.vala | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index ea985cf..2edb413 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -2391,11 +2391,30 @@ Copyright © 2015–2016 Sahil Sareen""";
_("_Save"),
_("_Cancel"));
- if (game_file != null && game_file.get_path () != autosave_filename)
- save_dialog.set_filename (game_file.get_path ());
- else
+ var set_filename = false;
+ if (game_file != null)
+ {
+ /* If the path is under /run, we are probably sandboxed, and the
+ * path we see is entirely different from the path to the file
+ * on the host system. In this case, we should force the user to
+ * navigate the filesystem rather than displaying /run, which
+ * would be meaningless to the user.
+ *
+ * Also, of course we don't want to preselect the autosave file.
+ */
+ var path = game_file.get_path ();
+ if (path != autosave_filename && !path.has_prefix ("/run"))
+ {
+ save_dialog.set_filename (path);
+ set_filename = true;
+ }
+ }
+
+ if (!set_filename)
+ {
save_dialog.set_current_name (/* Default filename for the save game dialog */
_("Untitled Chess Game") + ".pgn");
+ }
/* Filter out non PGN files by default */
var pgn_filter = new FileFilter ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]