From abcf9eeeff05daba05a6cacc51877560c412d4a9 Mon Sep 17 00:00:00 2001 From: Andre Miranda Date: Mon, 12 Feb 2018 22:13:43 -0300 Subject: [PATCH] Do not translate "Trash" files and folders (Bug #14211) --- thunar/thunar-file.c | 8 ++++---- thunar/thunar-gio-extensions.c | 42 +++++++++++++++++++++++++----------------- thunar/thunar-gio-extensions.h | 1 + 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index e8a36cc8..7259527e 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1067,21 +1067,21 @@ thunar_file_info_reload (ThunarFile *file, /* determine the display name */ if (file->display_name == NULL) { - if (G_LIKELY (file->info != NULL)) + if (G_UNLIKELY (thunar_g_file_is_trash (file->gfile))) + file->display_name = g_strdup (_("Trash")); + else if (G_LIKELY (file->info != NULL)) { display_name = g_file_info_get_display_name (file->info); if (G_LIKELY (display_name != NULL)) { if (strcmp (display_name, "/") == 0) file->display_name = g_strdup (_("File System")); - else if (strcmp (display_name, "Trash") == 0) - file->display_name = g_strdup (_("Trash")); else file->display_name = g_strdup (display_name); } } - /* faccl back to a name for the gfile */ + /* fall back to a name for the gfile */ if (file->display_name == NULL) file->display_name = thunar_g_file_get_display_name (file->gfile); } diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 42326b01..629ec018 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -131,6 +131,23 @@ thunar_g_file_is_home (GFile *file) +gboolean +thunar_g_file_is_trash (GFile *file) +{ + char *uri; + gboolean is_trash = FALSE; + + _thunar_return_val_if_fail (G_IS_FILE (file), FALSE); + + uri = g_file_get_uri (file); + is_trash = g_strcmp0 (uri, "trash:///") == 0; + g_free (uri); + + return is_trash; +} + + + GKeyFile * thunar_g_file_query_key_file (GFile *file, GCancellable *cancellable, @@ -233,24 +250,15 @@ thunar_g_file_get_display_name (GFile *file) if (G_LIKELY (base_name != NULL)) { if (strcmp (base_name, "/") == 0) - { - display_name = g_strdup (_("File System")); - g_free (base_name); - } - else if (strcmp (base_name, "Trash") == 0) - { - display_name = g_strdup (_("Trash")); - g_free (base_name); - } + display_name = g_strdup (_("File System")); + else if (thunar_g_file_is_trash (file)) + display_name = g_strdup (_("Trash")); else if (g_utf8_validate (base_name, -1, NULL)) - { - display_name = base_name; - } - else - { - display_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE); - g_free (base_name); - } + display_name = g_strdup (base_name); + else + display_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE); + + g_free (base_name); } else { diff --git a/thunar/thunar-gio-extensions.h b/thunar/thunar-gio-extensions.h index 7d8922d8..053faa6c 100644 --- a/thunar/thunar-gio-extensions.h +++ b/thunar/thunar-gio-extensions.h @@ -34,6 +34,7 @@ GFile *thunar_g_file_new_for_bookmarks (void); gboolean thunar_g_file_is_root (GFile *file); gboolean thunar_g_file_is_trashed (GFile *file); gboolean thunar_g_file_is_home (GFile *file); +gboolean thunar_g_file_is_trash (GFile *file); GKeyFile *thunar_g_file_query_key_file (GFile *file, GCancellable *cancellable, -- 2.16.1