[gtranslator/dl-info: 2/2] Show stored info feedback after DL open
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/dl-info: 2/2] Show stored info feedback after DL open
- Date: Mon, 28 Dec 2020 10:20:05 +0000 (UTC)
commit 3334a770e20bbed74f22c76a992a2a7e35bac516
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Mon Dec 28 11:18:55 2020 +0100
Show stored info feedback after DL open
This patch shows a feedback message to the user with the info-bar to
notify to the user the default file location.
https://gitlab.gnome.org/GNOME/gtranslator/-/issues/124
src/gtr-dl-teams.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index 463a2e960..094bc6287 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -436,6 +436,7 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
GOutputStream *output = NULL;
gsize bytes = 0;
GtkWidget *dialog;
+ char *basename = NULL;
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;
@@ -495,7 +496,8 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
}
/* 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);
+ basename = strrchr (priv->file_path, '/');
+ file_path = g_strconcat ("file://", dest_dir, "/", basename, 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,7 +514,19 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
return;
}
- gtr_open (dest_file, priv->main_window, &error);
+ if (gtr_open (dest_file, priv->main_window, &error)) {
+ GtrTab *tab = gtr_window_get_active_tab (priv->main_window);
+ g_autofree char *info_msg = NULL;
+ if (basename)
+ {
+ info_msg = g_strdup_printf (_("The file '%s' has been stored on %s"),
+ basename + 1, dest_dir);
+ }
+ else
+ info_msg = g_strdup_printf (_("The file has been stored on %s"), dest_dir);
+
+ gtr_tab_set_info (tab, info_msg, NULL);
+ }
g_object_unref (tmp_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]