[gtranslator/dl-download-folder] Download DL files to Download folder




commit 365e05d85c3e0fedede36be47998291fcdebc818
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Thu Sep 3 09:22:11 2020 +0200

    Download DL files to Download folder
    
    We shouldn't use the /tmp folder directly because if the app is
    flatpaked the /tmp folder is not accessible by the host.
    
    This patch changes the default DL file location to the Download folder,
    so it's not possible to loose the work when the user closes the app
    without changing the file location. By default downloaded po files will
    be stored on $HOME/Downloads.
    
    With this new behavior we don't need to ask to the user for a new
    location just after the file is downloaded. We just stored the file in
    Downloads by default and the user can do a normal app usage.
    
    Fix https://gitlab.gnome.org/GNOME/gtranslator/-/issues/117

 build-aux/flatpak/org.gnome.Gtranslator.json |  1 +
 src/gtr-dl-teams.c                           | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Gtranslator.json b/build-aux/flatpak/org.gnome.Gtranslator.json
index 2d32776d..a23f7b40 100644
--- a/build-aux/flatpak/org.gnome.Gtranslator.json
+++ b/build-aux/flatpak/org.gnome.Gtranslator.json
@@ -16,6 +16,7 @@
         "--filesystem=home",
         "--filesystem=xdg-run/dconf",
         "--filesystem=~/.config/dconf:ro",
+        "--filesystem=xdg-download",
         "--talk-name=ca.desrt.dconf",
         "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
     ],
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index 30cbdde2..463a2e96 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -436,6 +436,8 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
   GOutputStream *output = NULL;
   gsize bytes = 0;
   GtkWidget *dialog;
+  const char *dest_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+  g_autofree char *file_path = NULL;
   g_autoptr(GFile) dest_file = NULL;
 
   /* Load the file, save as temp; path to file is https://l10n.gnome.org/[priv->file_path] */
@@ -492,8 +494,9 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
       return;
     }
 
-  /* Save file to /tmp; file basename is the part from last / character on */
-  dest_file = g_file_new_for_uri (g_strconcat ("file:///tmp", strrchr (priv->file_path, '/'), NULL));
+  /* Save file to Downloads; file basename is the part from last / character on */
+  file_path = g_strconcat ("file://", dest_dir, "/", strrchr (priv->file_path, '/'), NULL);
+  dest_file = g_file_new_for_uri (file_path);
 
   g_file_copy (tmp_file, dest_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
 
@@ -512,9 +515,6 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
   gtr_open (dest_file, priv->main_window, &error);
 
   g_object_unref (tmp_file);
-
-  /* Show Save As dialog to asve file in another path than /tmp */
-  gtr_save_file_as_dialog (NULL, priv->main_window);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]