[gtranslator/dl-info: 5/6] Add the module name to files downloaded from DL
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/dl-info: 5/6] Add the module name to files downloaded from DL
- Date: Mon, 4 Jan 2021 08:06:04 +0000 (UTC)
commit b234e6356adc2164f14679995b241b2386078fe2
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Mon Dec 28 12:57:11 2020 +0100
Add the module name to files downloaded from DL
https://gitlab.gnome.org/GNOME/gtranslator/-/issues/124
src/gtr-dl-teams.c | 10 ++++++----
src/gtr-utils.c | 12 ++++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/gtr-dl-teams.c b/src/gtr-dl-teams.c
index 22ee8a3b..6d015b99 100644
--- a/src/gtr-dl-teams.c
+++ b/src/gtr-dl-teams.c
@@ -501,19 +501,22 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
/* Save file to Downloads; file basename is the part from last / character on */
basename = g_path_get_basename (priv->file_path);
// Remove the extension
- filename = gtr_utils_get_filename (basename);
+ filename = g_strdup_printf ("%s.%s.%s", priv->selected_module, priv->selected_branch, basename);
+ g_free (basename);
+ basename = g_strdup (filename);
file_path = g_strconcat ("file://", dest_dir, "/", basename, NULL);
dest_file = g_file_new_for_uri (file_path);
ret = g_file_copy (tmp_file, dest_file, G_FILE_COPY_NONE, NULL, NULL, NULL, &error);
while (!ret && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
{
+ g_autofree char *tmpname = gtr_utils_get_filename (filename);
g_free (basename);
g_free (file_path);
g_object_unref (dest_file);
g_clear_error (&error);
- basename = g_strdup_printf ("%s (%d).po", filename, ++file_index);
+ basename = g_strdup_printf ("%s (%d).po", tmpname, ++file_index);
file_path = g_strconcat ("file://", dest_dir, "/", basename, NULL);
dest_file = g_file_new_for_uri (file_path);
ret = g_file_copy (tmp_file, dest_file, G_FILE_COPY_NONE, NULL, NULL, NULL, &error);
@@ -534,9 +537,8 @@ gtr_dl_teams_load_po_file (GtkButton *button, GtrDlTeams *self)
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;
- g_autofree char *filename = g_file_get_basename (dest_file);
info_msg = g_strdup_printf (_("The file '%s' has been stored on %s"),
- filename, dest_dir);
+ basename, dest_dir);
gtr_tab_set_info (tab, info_msg, NULL);
}
diff --git a/src/gtr-utils.c b/src/gtr-utils.c
index e961de2f..994cd0a6 100644
--- a/src/gtr-utils.c
+++ b/src/gtr-utils.c
@@ -574,11 +574,15 @@ gtr_utils_get_filename (const gchar * filename)
array = g_strsplit (filename, ".", -1);
l = g_strv_length (array);
+ new_str = g_strdup (array[0]);
// Remove the extension
- g_free (array[l]);
- array[l] = NULL;
-
- new_str = g_strjoinv (".", array);
+ for (int i=1; i < l-1; i++)
+ {
+ char *tmp = NULL;
+ tmp = new_str;
+ new_str = g_strjoin (".", tmp, array[i], NULL);
+ g_free (tmp);
+ }
g_strfreev (array);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]