diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index e8a36cc8..5d67c16a 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 (thunar_file_is_trash (file)) + 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); } @@ -3531,6 +3531,27 @@ thunar_file_is_desktop (const ThunarFile *file) } +/** + * thunar_file_is_trash: + * @file : a #ThunarFile. + * + * Checks whether @file refers to the trash directory. + * + * Return value: %TRUE if @file is the trash directory. + **/ +gboolean +thunar_file_is_trash (const ThunarFile *file) +{ + char *uri; + gboolean is_trash; + + uri = g_file_get_uri (file->gfile); + is_trash = g_strcmp0 (uri, "trash:///") == 0; + g_free (uri); + + return is_trash; +} + const gchar * thunar_file_get_thumbnail_path (ThunarFile *file) diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index 73000e4c..5a1865e2 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -262,6 +262,7 @@ GList *thunar_file_list_get_applications (GList GList *thunar_file_list_to_thunar_g_file_list (GList *file_list); gboolean thunar_file_is_desktop (const ThunarFile *file); +gboolean thunar_file_is_trash (const ThunarFile *file); /** * thunar_file_is_root: diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 42326b01..930c6298 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -233,24 +233,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_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 {